Coder Social home page Coder Social logo

fcos's Introduction

FCOS in Pytorch

An unofficial implementation of FCOS in Pytorch. FCOS: Fully Convolutional One-Stage Object Detection.

https://arxiv.org/abs/1904.01355

Some modifies are adopted:

  • Remove center-ness branch for simplicity.
  • Add center sample mechanism to improve performance.
  • Predect yxhw instead of tlbr +0.3Map.
  • Note: GPU Compute Capability >= 6.1 (pytorch>=1.0.0)

Download:

paper (800px) official (800px) ours (nearly 700px)
36.6 38.7 37.3

Some cuda operations are provided for acceleration.

cd libs/nms_cuda
python setup.py install
cd libs/sigmoid_focal_loss_cuda
python setup.py install
cd libs/assign_box_cuda
python setup.py install

Inference

  1. Copy your images (xxx.jpg) to /images.
  2. Command: python run_demo.py

COCO (2x)

  1. Copy configs/detector_coco.py to ./detector.py
  2. Copy configs/train_coco_2x.json to ./train.json
  3. Configure train.json file, add your root.
  4. Command: python run_train.py to start schedule, it takes about 30 hours with 8x Titan-XP.
  5. Command: python run_analyze.py to get mAP curves.
  6. Command: python run_cocoeval.py to get mAP.
map_mean
[0.1345 0.1984 0.2192 0.2468 0.2496 0.2606 0.2729 0.2708 0.2768 0.2872
 0.2924 0.295  0.2973 0.3041 0.2927 0.3027 0.3565 0.3583 0.3622 0.3642
 0.3659 0.3679 0.3689 0.37  ]
map_50
[0.2482 0.3404 0.3749 0.3997 0.4059 0.4182 0.4401 0.4393 0.4389 0.4496
 0.4584 0.4646 0.4618 0.4719 0.4584 0.4741 0.535  0.5385 0.5405 0.5436
 0.5457 0.5489 0.5497 0.5511]
map_75
[0.1304 0.2044 0.2265 0.2596 0.2595 0.2758 0.2895 0.283  0.2914 0.3037
 0.311  0.315  0.3145 0.3246 0.3136 0.3232 0.3804 0.3829 0.3869 0.3906
 0.3917 0.3924 0.3943 0.3962]
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.373
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.556
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.398
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.198
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.411
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.486
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.303
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.482
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.525
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.326
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.575
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.639

VOC0712 (30 epoches)

  1. Copy configs/detector_voc.py to ./detector.py
  2. Copy configs/train_voc.json to ./train.json
  3. Configure train.json file, add your root.
  4. Command: python run_train.py to start schedule.
  5. Command: python run_analyze.py to get mAP curves.
map_mean
[0.0315 0.174  0.2992 0.3442 0.3567 0.3983 0.4329 0.4475 0.44   0.4525
 0.4397 0.472  0.4743 0.475  0.464  0.4885 0.4855 0.4908 0.4923 0.4776
 0.529  0.5331 0.535  0.5375 0.5371 0.5348 0.538  0.537  0.5378 0.5368]
map_50
[0.0721 0.3466 0.5524 0.594  0.6051 0.6488 0.6968 0.7062 0.7001 0.7205
 0.6982 0.7211 0.7258 0.7276 0.7092 0.7408 0.7381 0.7362 0.7295 0.7246
 0.7682 0.7718 0.7736 0.7771 0.7741 0.7725 0.7767 0.7737 0.7744 0.7732]
map_75
[0.0219 0.1561 0.2932 0.3555 0.3639 0.4224 0.4618 0.4781 0.4718 0.4849
 0.479  0.5084 0.5147 0.5116 0.4989 0.5293 0.5259 0.5244 0.5292 0.5174
 0.574  0.5789 0.5797 0.5792 0.5794 0.5805 0.5858 0.5814 0.5829 0.5819]

How to change resolution ?

To change the prediction resolution, you need to modify the following parameters. Note that the resolution must be 128*n+1 (n=1,2,3...).

# ---------------------------
self.view_size = 1025 # 128*n+1
self.phpw = [[129, 129], [65, 65], [33, 33], [17, 17], [9, 9]]
# [[16n+1, 16n+1], [8n+1, 8n+1], [4n+1, 4n+1], [2n+1, 2n+1], [n+1, n+1]]
# ---------------------------

How to train your own data ?

  1. Create data_name.txt
background
classname1
classname2
classname3
  1. Create data_train.txt
xxx1.jpg 237 411 480 504 1 313 9 391 151 3
xxx2.jpg 261 234 553 134 2
# img_name ymin xmin ymax xmax class_id ymin xmin ymax xmax class_id ... \n 
  1. Create data_eval.txt (same format as data_train.txt)
  2. Config train.json file, add your root.

Call for suggestions !

We can't achieve the above results in standard 12-epoch training, even if we add the center branch. The possible reasons are: 1. Instead of set minimum side to 800, we set the maxmal side to 1025. 2. There are some tricks we haven't adopted.

fcos's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fcos's Issues

Train on the VOC dataset

If using VOC to train ,how can I set the learning rate(2 GPUs)? Looking forward for your reply,thank you very much

警告问题 warning problem

indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.
how to avoid this warning when training?

映射回原图操作的问题

你好,请问映射回原图的操作是在代码哪里体现的?我看到之前有人提问提到过c_y, c_x = h * float(stride), w * float(stride),请问在代码哪个部分?

关于centerness

您好,请问你把centerness去掉后,不会引起误检测变多么?我看原文中这是一个创新点

assign box中的参数

你好,请问如果修改训练时候图像的输入尺寸,1024,200,5这几个数字需要修改吗?比如要修改成256*896大小训练
微信截图_20191226165800

About the assign_box()

Hello author, I found that in the assign_box.py, the code without the assign_box_cuda is not given, can I ask for the function assign_box(), and the code that can be used without cuda.
Thanks a lot!

about training setting

I find that the official code get 38.7%AP(80k, about 12 epoch)
I modify your train.json by following official training instructions(12 epoch) and then only get 30%AP

Segmentation fault (core dumped)

运行run_train.py后,提示

use lib assign_box_cuda
use lib sigmoid_focal_loss_cuda
use lib nms_cuda
Segmentation fault (core dumped)

调试后定位到net = net.cuda(cfg['device'][0])
这是CUDA的版本问题吗?

fcos for geospatial

Hello, I'm trying to your FCOS implementaitn on my own geospatial dataset (I guess it's similar to the spacenet dataset) to detect buildings. I've followed your instructions for setting up the training and evaluation datasets, but I get no output, (the loss seems to go down but i'm guessing it's converging on predicting nothing).

Just to confirm a few silly things. Your xmin, xmax, ymin, ymax are defined in the standard format right? So left, right, top, bottom.

The typical image i'm training on looks like this:

train2

Do you have any ideas of what parameters I might need to adjust to get good output?

Thanks a lot!
Roger

关于精度和训练问题

readme 里的37的精度是 2x 的训练结果?还有4 GPU 的精度是多少,我看跑了官方的源码resnet50 4GPU训练1x 有38+的精度

映射回原图的坐标问题

请问c_y, c_x = h * float(stride), w * float(stride)在映射回原图的方法为什么和fcos论文提到的ws+1/2s和hs+1/2s不一样呢?

训练coco时候,focal loss不能正常收敛

你好,我用这个代码,训练coco2017数据集,发现focal loss不能正常收敛,完全偏向了负样本,正样本的分类准确率为0。我使用python3.7和pytorch1.0,batch size为8。请问你有什么经验和建议么
微信截图_20191228201806

关于run_train.py中net指定gpu的问题

net = torch.nn.DataParallel(net, device_ids=cfg['device'])
net = net.cuda(cfg['device'][0])
net.train()
这是在run_train.py中准备model时候的操作。
想请问,为什么先分配到所有的gpu上net = torch.nn.DataParallel(net, device_ids=cfg['device']),然后再单独指定一块net = net.cuda(cfg['device'][0])?不太清楚其中意义。

希望能够获得答复,谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.