實時官方官方效率的官方效率重新實現,原始紙張鏈接: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