Giter Club home page Giter Club logo

fcos-pytorch-37.2ap's Introduction

FCOS: Pytorch Implementation Support PASCAL VOC and MS COCO

RetinaNet code which is similar with this repo :https://github.com/ChingHo97/RetinaNet-Pytorch-36.4AP you can find difference between the anchor free and anchor base.

AP Result

PASCAL VOC (800px) COCO(800px)
78.7 (IoU.5) 37.2

Requirements

  • opencv-python
  • pytorch >= 1.0
  • torchvision >= 0.4.
  • matplotlib
  • cython
  • numpy == 1.17
  • Pillow
  • tqdm
  • pycocotools

Results in coco

Train coco2017 on 4 Tesla-V100, 4 imgs for each gpu, init lr=1e-2 using GN,central sampling,GIou.

You can download the 37.2 ap result in Baidu driver link, password: cnwm,then put it in checkpoint folder, then run the coco_eval.py you can get the result as follows:

Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.372
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.559
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.399
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.207
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.410
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.495
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.311
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.503
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.553
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.358
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.597
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.687

there are some details you neet to notice:

as for the data-augument, I only use flip, color jitter and rotate ,the random crop I also use for my training, but the ap is lower. so I suggest you turn off the random crop.

do NMS the scores needs to sqrt, which reference to the offical.

the offical use BGR to training and pixel is not normalized to 0~1 , I use RGB and do the normalization.

Results in Pascal Voc

Train Voc07+12 on 2 Tesla-V100 , 8 imgs for each gpu, init lr=1e-2 using GN,central sampling,GIou.

You can download the 78.7 ap result in Baidu driver link, password:s4cp, then put it in checkpoint folder, then run the eval_voc.py and you can get the result as follows:

ap for aeroplane is 0.8404275844161726
ap for bicycle is 0.8538414069634157
ap for bird is 0.8371043868766486
ap for boat is 0.6867630943895144
ap for bottle is 0.7039276923755678
ap for bus is 0.8585650817738049
ap for car is 0.8993155911437366
ap for cat is 0.919100484692941
ap for chair is 0.5575814527810952
ap for cow is 0.8429926423801004
ap for diningtable is 0.6596296818110386
ap for dog is 0.8896160095323242
ap for horse is 0.8436443710873067
ap for motorbike is 0.8114359299817884
ap for person is 0.8525903122141745
ap for pottedplant is 0.47628914937925404
ap for sheep is 0.8257834833986701
ap for sofa is 0.7000391892293902
ap for train is 0.8664281745198105
ap for tvmonitor is 0.8186715890179656
mAP=====>0.787

I also use the cosine lr to train the voc, and it got 76.7mAP, which is lower than linear. I think the cosine lr matches Adam is better.

train for coco

You can run the train_coco.py, train 24 epoch and you can get the result. You need to change the coco2017 path.

train for PASCAL VOC

You can run the train_voc.py, train 30 epoch and you can get the result. You need to change the PASCAL07+12 path, you can reference to this repo:https://github.com/YuwenXiong/py-R-FCN

Detect Image

You can run the detect.py to detect images , this repo provides PASCAL VOC Images detection demo. test1
test1

thanks to @VectXmy, I referenced some codes.

fcos-pytorch-37.2ap's People

Contributors

zhenghao977 avatar

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  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

fcos-pytorch-37.2ap's Issues

0it [00:00, ?it/s]

when I give the COCOGenerator the path of coco test2017 and image_info_test-dev2017.json.the coco_eval.py can't run normally。and there are not error info
when I add a line to show the len of generator,it's 0
below is the output of the terminal:
(BorderDet) PS \FCOS-PyTorch-37.2AP-master> python -u "\FCOS-PyTorch-37.2AP-master\coco_eval.py"
loading annotations into memory...
Done (t=0.08s)
creating index...
index created!
INFO====>check annos, filtering invalid data......
INFO===>success frozen BN
INFO===>success frozen backbone stage1
0
0it [00:00, ?it/s]

A confusing line of code, which may have to be modified

Hi zhenghao,
the train/eval mode of the fcos model is written in your code [path/model/fcos.py], however, in the line 26
'super().train(mode=True)', the model mode is fixed as training mode.
That leads to some unexpected inference results when doing inference by set model to eval(). So, I suggest
modify 'super().train(mode=True)' to 'super().train(mode=mode)'.
Otherwise, the dropout/bn is not locked in the inference procedure. At the same time, the dropout/bn status
can be affected by the [path/model/config.py] configurations: freeze_stage1/freeze_bn

你好 我改了原文网络 用这个数据集 map达到了0.897 请问算是很大的提升吗?

ap for aeroplane is 0.9380567591582296
ap for bicycle is 0.9023500291689587
ap for bird is 0.9437036916098254
ap for boat is 0.8359743513566958
ap for bottle is 0.8032454349459615
ap for bus is 0.9342764262934609
ap for car is 0.8585514817842739
ap for cat is 0.9925084130423817
ap for chair is 0.7292643574182338
ap for cow is 0.9375359094086273
ap for diningtable is 0.6475493395647764
ap for dog is 0.9876765272418895
ap for horse is 0.9666172732613725
ap for motorbike is 0.9114585891450979
ap for person is 0.8979392369795223
ap for pottedplant is 0.7230285310500533
ap for sheep is 0.902755284427134
ap for sofa is 0.8116387496591522
ap for train is 0.9630694195465596
ap for tvmonitor is 0.8966949641025459
mAP=====>0.879

测试代码问题

在fcos.py中,第83行,测试进行前传的时候,为什么要把测试得到的类别结果+1,这一块不是很明白。
cls_classes=cls_classes+1#[batch_size,sum(_h*_w)]

几处不明白的地方

我有几处不明白的地方,希望您不吝赐教。
1.readme写的78.7map,百度云盘链接实际却是77.8map
2.我用voc_77.8.pth进行detect.py,不匹配,没办法跑起来。voc_77.8.pth只能用来验证,不能推理?
3.我下载了VectXmy的voc推理权重,可以跑起来,可是图片没有任何预测的结果
我是小白,很多不懂,希望您能解答一下

voc dataset

您好,博主,请问使用voc数据集时,path指的是所有数据的路径嘛, 数据集的各个文件夹的层次关系是什么,即数据集的格式是什么样子的,希望您有空可以指点一下我

训练自己数据集,loss不下降但是正确率很高

你好,想请教一下,我训练自己的数据集,totalloss一直在0.6-0.76之间波动,但是验证map最终达到0.99,这和在mmdetection上训练验证结果不同,想请教loss这样合理么?代码中有加入正则化防止过拟合么?非常感谢!

输入图像预处理

您好,我想问一下您代码中的图像预处理设置为[800,1333],这个如果我换数据集的话是要进行相对应的更改吗,如果不改,会影响精度吗?期待您的回复。

pretrained weight

Hi, I am using the pretrained voc weights, and it turns out that class outputs contain indexes out of range(it is supposed to be from 0-20). I am not sure if you uploaded a wrong weight file or not.

不能使用多卡训练

修改这行代码后仍然只使用编号为“1”的gpu进行训练parser.add_argument("--n_gpu", type=str, default='0,1', help="number of pu threads to use during batch generation")

执行detect出错。

当我执行detect.py时,出现如下错误。使用的是voc训练权重.。
`
Traceback (most recent call last):
File "detect.py", line 86, in
model.load_state_dict(torch.load("./checkpoint/model_1.pth",map_location=torch.device('cpu')), strict=True)
File "/home/zhangpan/anaconda3/envs/torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for DataParallel:
size mismatch for module.fcos_body.head.cls_logits.weight: copying a param with shape torch.Size([80, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 256, 3, 3]).
size mismatch for module.fcos_body.head.cls_logits.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([20]).

`

Error in loading resnet model

I am using model_zoo.load_url to load resnet50 model,however when I use the downloaded model,I end up recieivng the error message as shown below

loading annotations into memory...
Done (t=18.10s)
creating index...
index created!
INFO====>check annos, filtering invalid data......
Traceback (most recent call last):
  File "train_coco.py", line 39, in <module>
    model=FCOSDetector(mode="training").cuda()
  File "/content/fcos/model/fcos.py", line 217, in __init__
    self.fcos_body=FCOS(config=config)
  File "/content/fcos/model/fcos.py", line 22, in __init__
    self.backbone=resnet34(pretrained=True,if_include_top=False)
  File "/content/fcos/model/backbone/resnet.py", line 194, in resnet34
    model.load_state_dict(model_zoo.load_url(model_urls['resnet34']))
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1483, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ResNet:
	Unexpected key(s) in state_dict: "fc.weight", "fc.bias"

Would it be possible for you to share the resnet50.pth file,if not then any suggestions on what can be done to resolve this.

训练的模型测试只有66.9%的mAP

我使用ResNet50预训练模型在PASCOVOC数据集上训练,但测试时只得到了66.9%的mAP.
使用博主网盘公布的训练后的模型参数去测试,可以达到博主公布的mAP值。。。
想请教一下这种情况该从哪些方面去寻找问题的原因呢?
感谢!!!!

测试问题

您好,我在使用eval_voc进行测试时,发现还要重载预训练模型resent,这是正确的么?根据print输出看到同时加载了CNN预训练模型和在自己数据集上训练好的model.pth。

学习率调整

请问一下作者学习率的调整和batch_size有没有关系?因为我发现设置不同的batch_size,GLOBAL_STEPS总数是变化的,但代码里面把lr调整步数固定了,这样会不会有问题?我是不是要根据自己的batch_size改lr_schedule?

About voc_dataset.py

Hi, If an image has no objects, the corresponding tag file is empty .In the preprocess_img_boxes function, boxes=array([]). In the later collect_fn function, an error is reported. Because it's an empty array. How to modify this bug? Or how to tag background images, including classes and boxes. I look forward to hearing from you soon.

关于代码中的小细节

非常感谢您分享代码!有个小问题向您请教

cls_classes=cls_classes+1#[batch_size,sum(_h*_w)]

  1. fcos.py的forward函数 line83中为何要对classes做+1处理?
  2. 还是这个函数, 为什么没有过滤掉背景标签对应的boxes和scores?
    期待您的回复!感谢!

训练结束后模型权重的保存

您好,博主,我的训练结束后模型权重文件并没有保存到指定文件夹中,这时如何修改呀。
torch.save(model.state_dict(),"pytorchDebug/FCOS-PyTorch-37.2AP/output/model_{}.pth".format(epoch + 1))
这句话感觉没有问题呀

About APs,APm,APL

Hello. I'm looking at your code and the performance you posted on Readme is as below.

Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.207
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.410
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.495

But when I actually turned it around, the performance isn't that good, is the parameter setting different from the one posted on GitHub?

And what kind of backbone network is the performance that comes from?

And one more could you tell me the difference from the official fcos code?

Thank you.

Can you give me some advice

You did a great job. When I calculate the mAP on COCO Dataset, it seems to be lower then you do. Can you give me some advice about the hyper-parameter,such as batch-szie, lr and so on. I have two GPUS(2080ti). Thanks you.

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.