I had ever tried other version implementation of EfficientDet, results seemed very bad, ( BTW,I'm sure my dataset is OK as training and testing were successfully done with different network, such as Faster-RCNN(ZF,VGG) and Cascade-RCNN (Resnet101,ResneXt101,HRnet) and CenterNet, and results were considerably good ), that code implementation seems something wrong, and finally came across Signatrix's this code implementation, training and testing results are OK with my own dataset, but I think there are some flaws that need to be patched up, so, I forked Signatrix's project and had a try to revamp some code lines, I have done the following improvements in my this branch:
(1)As of now,the original version only works well with network efficientdet-d0 and efficientdet-d1, errors will happen with other level of Efficientdet, I added some changes to make d2-d7 also supported, now weights can be correctly loaded form Efficientnet b2-b7(b0-b8 for adv-efficientnet) pretrained model file for Efficientnet backbone, and training with Efficientdet d2-d7(d8 works well for adv-eifficientdet) works fine.
(2)The original code downloads the corresponding Efficientnet pretrained model files from https://github.com/lukemelas/EfficientNet-PyTorch/releases, this is easy to maintain, but when you are in a bad network with very poor network speed, you will suffer from the slow direct downloading without speedup tool. We can download those pretrained model files in advance with speedup tools to local directory and load the corresponding weights locally, this will improve user experience very much, I add some code to support loading pretrained weights locally, you can set the loading mode with the command line argument --remote-loading = True or False, when using the default loading mode,i.e., loading weights locally from ./pretrained_models, you should make the directory ./pretrained_models in advance under the root directory of project, and download the pretrained model files from https://github.com/lukemelas/EfficientNet-PyTorch/releases into it.
(3)Signatrix's code doesn't support resuming training from a epoch where training stopped unexpectedly, this is of a little bitter if you have run the training for long time and stopped occasionally due to unexpected disturbing such as power cut, so,I added some statements to support resuming.
You can set arguments on the command line or in train.py, the new arguments added by me are the following ones: --save_interval default=10, the number of epoches between two operations for saving weights --backbone_network default='efficientnet-b0', the value is one of efficientnet-b0/efficientnet-b1/.../efficientnet-b7 --remote_loading default=False, if this option is enabled, it will download and load the backbone weights from https://github.com/lukemelas/EfficientNet-PyTorch, otherwise, load the weights locally from ./pretrained_models --advprop default=False, if this option is enabled, the adv_efficientnet_b* backbone will be used instead of efficientnet_b* --resume action='store_true',if resume training from the last model file saved by the last stopped training --start_epoch default=0, the start_epoch where you restart training by resuming from a model generated recently
I think a very important argument is batch_size you need to tune, the default value is 32, OOM error will often happen with many type of GPUs unless your GPU has very big memory, I trained EfficientDet-d7 with 4 RTX 2080TI GPUs, whose memory is 11G per one, if I set batch_size greater than 3, Out-of-Memory error always occurred, I also got the OOM error with batch_size=3 when I was starting adv-efficientDet-d8, so, if you want to train with adv-efficient,batch_size might be bigger than expected, and needs to be reduced.
Comannd Examples:
1) python train.py
2) python train.py --batch_size 3
3) python train.py --save_interval 50 --backbone_network 'efficientnet-b7' --resume --start_epoch 101
1)I made changes with efficientnet_pytorch's model.py and utils.py to support loading weights locally, and integrate them here, so, you don't need to install the efficientnet_pytorch package as prerequisite any more.
2)I made changes in src/dataset.py according to my coco dataset, its num_class is 1 and paths are:
COCO
├── annotations
│ ├── instances_train2017.json
│ └── instances_val2017.json
│
├── train2017
└── val2017
You need to change the code in dataset.py according to your dataset.
For Chinese guide, please refer to my csdn blog. 中文版指南请参考我的CSDN博文:https://blog.csdn.net/XCCCCZ/article/details/105477376
Here is our pytorch implementation of the model described in the paper EfficientDet: Scalable and Efficient Object Detection paper (Note: We also provide pre-trained weights, which you could see at ./trained_models)
An example of our model's output.
Dataset | Classes | #Train images | #Validation images |
---|---|---|---|
COCO2017 | 80 | 118k | 5k |
Create a data folder under the repository,
cd {repo_root}
mkdir data
COCO
├── annotations
│ ├── instances_train2017.json
│ └── instances_val2017.json
│── images
├── train2017
└── val2017
With our code, you can:
We trained our model by using 3 NVIDIA GTX 1080Ti. Below is mAP (mean average precision) for COCO val2017 dataset
Average Precision | IoU=0.50:0.95 | area= all | maxDets=100 | 0.314 |
---|---|---|---|---|
Average Precision | IoU=0.50 | area= all | maxDets=100 | 0.461 |
Average Precision | IoU=0.75 | area= all | maxDets=100 | 0.343 |
Average Precision | IoU=0.50:0.95 | area= small | maxDets=100 | 0.093 |
Average Precision | IoU=0.50:0.95 | area= medium | maxDets=100 | 0.358 |
Average Precision | IoU=0.50:0.95 | area= large | maxDets=100 | 0.517 |
Average Recall | IoU=0.50:0.95 | area= all | maxDets=1 | 0.268 |
Average Recall | IoU=0.50:0.95 | area= all | maxDets=10 | 0.382 |
Average Recall | IoU=0.50:0.95 | area= all | maxDets=100 | 0.403 |
Average Recall | IoU=0.50:0.95 | area= small | maxDets=100 | 0.117 |
Average Recall | IoU=0.50:0.95 | area= medium | maxDets=100 | 0.486 |
Average Recall | IoU=0.50:0.95 | area= large | maxDets=100 | 0.625 |
Some predictions are shown below:
@article{EfficientDetSignatrix,
Author = {Signatrix GmbH},
Title = {A Pytorch Implementation of EfficientDet Object Detection},
Journal = {https://github.com/signatrix/efficientdet},
Year = {2020}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。