实时官方官方效率的官方效率重新实现,原始纸张链接:https://arxiv.org/abs/1911.09070
如果您有麻烦培训数据集,并且如果您愿意与公众共享您的数据集或已经开放,请将其发布在help wanted Tag上的问题上,我可能会尝试为您提供帮助,如果我有空,这是无法保证的。
要求:
数据集的图像总数不应大于10K,容量应低于5GB,并且应该免费下载,即Baiduyun。
该数据集应为该存储库的格式。
如果您将数据集发布在此存储库中,则向世界开放。因此,请不要上传您的机密数据集!
如果数据集违反法律或侵犯了一个人的隐私,请随时与我联系以删除它。
最重要的是,除非我愿意,否则您不能要求我训练。
我将在此存储库中发布训练有素的权重,以及评估结果。
希望它能帮助想要在Pytorch中尝试有效的人。
培训示例可以在这里找到。教程。训练有素的权重可以在这里找到。权重
表演非常接近纸张,它仍然是sota。
速度/FPS测试包括没有JIT/数据精度技巧的后处理时间。
| 系数 | pth_download | GPU MEM(MB) | FPS | 极端FPS(批处理32) | 地图0.5:0.95(此存储库) | 地图0.5:0.95(官方) |
|---|---|---|---|---|---|---|
| D0 | 有效det-d0.pth | 1049 | 36.20 | 163.14 | 33.1 | 33.8 |
| D1 | 有效det-d1.pth | 1159 | 29.69 | 63.08 | 38.8 | 39.6 |
| D2 | 有效det22.pth | 1321 | 26.50 | 40.99 | 42.1 | 43.0 |
| D3 | 有效det-d3.pth | 1647年 | 22.73 | - | 45.6 | 45.8 |
| D4 | 有效det-d4.pth | 1903年 | 14.75 | - | 48.8 | 49.4 |
| D5 | 有效det-d5.pth | 2255 | 7.11 | - | 50.2 | 50.7 |
| D6 | 有效det-d6.pth | 2985 | 5.30 | - | 50.7 | 51.7 |
| D7 | 有效det-d7.pth | 3819 | 3.73 | - | 52.7 | 53.7 |
| D7X | 有效det-d8.pth | 3983 | 2.39 | - | 53.9 | 55.1 |
[2020-07-23]使用效率网络B7作为其主链和更深的BIFPN金字塔水平,支持有效的D7X,MAP 53.9。为了简单起见,让我们称其为效率det-d8。
[2020-07-15]更新效率D7权重,地图52.7
[2020-05-11]添加布尔字符串转换以确保head_only有效
[2020-05-10]用batched_nms替换NMS,以进一步将映射提高0.5〜0.7,感谢laghing-Q。
[2020-05-04]修复了可可类别ID不匹配错误,但它不应影响自定义数据集的培训。
[2020-04-14]固定损失功能错误。请提取最新的代码。
[2020-04-14]对于那些需要帮助或无法在几个时期获得好结果的人,请查看本教程。您可以在GPU支持的情况下在Colab上运行它。
[2020-04-10]在训练模型中扭曲损失功能,以便在使用多个GPU训练时保持内存使用量,从而使较大的批次化培训。
[2020-04-10]添加D7(具有较大输入尺寸和较大锚尺的D6)支持并测试其地图
[2020-04-09]允许自定义锚量表和比例
[2020-04-08]添加D6支持并测试其地图
[2020-04-08]添加培训脚本及其文档;更新评估脚本和简单推理脚本。
[2020-04-07]测试的D0-D5地图,结果似乎不错,可以在此处找到详细信息
[2020-04-07]修复锚策略。
[2020-04-06]适应锚策略。
[2020-04-05]创建此存储库。
# install requirements
pip install pycocotools numpy opencv-python tqdm tensorboard tensorboardX pyyaml webcolors
pip install torch==1.4.0
pip install torchvision==0.5.0
# run the simple inference script
python efficientdet_test.py
培训有效核心是一项痛苦且耗时的任务。您不应该期望在一两天内取得好成绩。请耐心等待。
如果您是新手,请查看本教程。您可以在GPU支持的情况下在Colab上运行它。
# your dataset structure should be like this
datasets/
-your_project_name/
-train_set_name/
-*.jpg
-val_set_name/
-*.jpg
-annotations
-instances_{train_set_name}.json
-instances_{val_set_name}.json
# for example, coco2017
datasets/
-coco2017/
-train2017/
-000000000001.jpg
-000000000002.jpg
-000000000003.jpg
-val2017/
-000000000004.jpg
-000000000005.jpg
-000000000006.jpg
-annotations
-instances_train2017.json
-instances_val2017.json
# create a yml file {your_project_name}.yml under 'projects'folder
# modify it following 'coco.yml'
# for example
project_name: coco
train_set: train2017
val_set: val2017
num_gpus: 4 # 0 means using cpu, 1-N means using gpus
# mean and std in RGB order, actually this part should remain unchanged as long as your dataset is similar to coco.
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
# this is coco anchors, change it if necessary
anchors_scales: '[2 ** 0, 2 ** (1.0 / 3.0), 2 ** (2.0 / 3.0)]'
anchors_ratios: '[(1.0, 1.0), (1.4, 0.7), (0.7, 1.4)]'
# objects from all labels from your dataset with the order from your annotations.
# its index must match your dataset's category_id.
# category_id is one_indexed,
# for example, index of 'car' here is 2, while category_id of is 3
obj_list: ['person', 'bicycle', 'car', ...]
# train efficientdet-d0 on coco from scratch
# with batchsize 12
# This takes time and requires change
# of hyperparameters every few hours.
# If you have months to kill, do it.
# It's not like someone going to achieve
# better score than the one in the paper.
# The first few epoches will be rather unstable,
# it's quite normal when you train from scratch.
python train.py -c 0 --batch_size 64 --optim sgd --lr 8e-2
# train efficientdet-d1 on a custom dataset
# with batchsize 8 and learning rate 1e-5
python train.py -c 1 -p your_project_name --batch_size 8 --lr 1e-5
# train efficientdet-d2 on a custom dataset with pretrained weights
# with batchsize 8 and learning rate 1e-3 for 10 epoches
python train.py -c 2 -p your_project_name --batch_size 8 --lr 1e-3 --num_epochs 10
--load_weights /path/to/your/weights/efficientdet-d2.pth
# with a coco-pretrained, you can even freeze the backbone and train heads only
# to speed up training and help convergence.
python train.py -c 2 -p your_project_name --batch_size 8 --lr 1e-3 --num_epochs 10
--load_weights /path/to/your/weights/efficientdet-d2.pth
--head_only True
# while training, press Ctrl+c, the program will catch KeyboardInterrupt
# and stop training, save current checkpoint.
# let says you started a training session like this.
python train.py -c 2 -p your_project_name --batch_size 8 --lr 1e-3
--load_weights /path/to/your/weights/efficientdet-d2.pth
--head_only True
# then you stopped it with a Ctrl+c, it exited with a checkpoint
# now you want to resume training from the last checkpoint
# simply set load_weights to 'last'
python train.py -c 2 -p your_project_name --batch_size 8 --lr 1e-3
--load_weights last
--head_only True
# eval on your_project, efficientdet-d5
python coco_eval.py -p your_project_name -c 5
-w /path/to/your/weights
# when you get bad result, you need to debug the training result.
python train.py -c 2 -p your_project_name --batch_size 8 --lr 1e-3 --debug True
# then checkout test/ folder, there you can visualize the predicted boxes during training
# don't panic if you see countless of error boxes, it happens when the training is at early stage.
# But if you still can't see a normal box after several epoches, not even one in all image,
# then it's possible that either the anchors config is inappropriate or the ground truth is corrupted.
Q1。为什么已经有几个有效的pytorch项目实施此操作。
A1:由于AFAIK都没有完全恢复官方效率的真正算法,这就是为什么他们的社区无法实现的原因,或者很难通过从Scratch培训来获得与官方有效性的得分相同的原因。
Q2:该存储库和其他库到底有什么区别?
A2:例如,这两个是最受欢迎的有效胶条 - pytorch,
https://github.com/toandaominh1997/felficitydet.pytorch
https://github.com/signatrix/felficitydet
这是问题,以及为什么这些问题很难获得与官方相同的分数:
第一个:
第二个:
pytorch的batchNoralization与tensorflow略有不同,动量_pytorch = 1 -momentum_tensorflow。好吧,如果我的注意力减少,我没有意识到这个陷阱。 Signatrix/EdgitionDet从TensorFlow中成功了该参数,因此BN会表现不佳,因为运行平均值和运行差异已由新输入主导。
对深度分离的conv2d的误解。深度分离的conv2d是深度 - conv2d和pointwise-conv2d和biasadd,在两个conv2d之后只有一个biasadd,而signatrix/extistiveDet在深度conv2d上具有额外的biasadd。
误解了maxpooling2d的第一个参数,第一个参数是kernel_size,而不是步幅。
在倾斜之后,缺少bn的电网输出功能。
使用效率网络的错误输出功能。这是很大的。它采用任何具有Conv.Stride 2的输出,但这是错误的。它应该是下一个Conv. -stride是2或EfficityNet的最终输出的人。
在Conv2D和合并上不应用相同的填充。
几次操作后缺少Swish激活。
在BIFPN,回归器和分类器中缺少Cons/BN操作。这是非常棘手的,如果您不深入探讨官方实施,则具有不同权重的相同操作。
illustration of a minimal bifpn unit
P7_0 -------------------------> P7_2 -------->
|-------------| ↑
↓ |
P6_0 ---------> P6_1 ---------> P6_2 -------->
|-------------|--------------↑ ↑
↓ |
P5_0 ---------> P5_1 ---------> P5_2 -------->
|-------------|--------------↑ ↑
↓ |
P4_0 ---------> P4_1 ---------> P4_2 -------->
|-------------|--------------↑ ↑
|--------------↓ |
P3_0 -------------------------> P3_2 -------->
例如,p4将下降到p4_0,然后将其变为p4_1,任何人都可能认为p4_0直接转到p4_2,对吗?
这就是为什么他们错的原因,P4应该再次下降频道,而p4_0_another的权重不同,然后转到p4_2。
最后,一些常见的问题,它们的锚定解码器和编码器与原始问题不同,但这并不是其表现不佳的主要原因。
同样,来自EfficityNet-Pytorch的Conv2DstataticSamePadding不像张力流一样执行,填充策略是不同的。因此,我自己实现了真正的TensorFlow风格Conv2DStaticSamePadding和MaxPool2DstaticsamePadding。
尽管存在上述问题,但它们是启发我的出色存储库,因此有这个存储库。
该存储库主要基于有效的DET,其更改可确保其性能与论文一样近。
顺便说一句,调试静态图形Tensorflow V1确实很痛苦。不要试图用TF-ONNX或MMDNN等自动化工具导出它,因为其自定义/复杂操作,它们只会引起更多问题。
即使您像我一样成功,您也必须处理同一类中疯狂的混乱机器生成的代码,而与从头开始翻译相比,它需要更多的时间来重构。
Q3:找到错误时该怎么办?
A3:如果已修复了更新日志,请查看更新日志,然后拉最新的代码以重试。如果没有帮助,请创建一个新问题并详细描述它。
结论:他们提供的精度几乎相同。提示:设置force_input_size=1920 。官方回购使用原始图像大小,而此存储库使用默认网络输入大小。如果您尝试比较这两个存储库,则必须确保输入大小是一致的。
欣赏以下存储库中的出色工作:
如果您喜欢此存储库,或者您想出于任何原因支持作者,则可以向作者捐款。请随时给我发送您的名字或介绍页面,我将确保您的名字在赞助商列表中。
衷心感谢您的慷慨。
Cndylan Claire-S11