SpursLipu / YOLOv3v4-ModelCompression-MultidatasetTraining-Multibackbone

YOLO ModelCompression MultidatasetTraining
GNU General Public License v3.0
445 stars 136 forks source link

你好,请问次项目支持yolov2的剪枝吗?我在yolov2的骨干网络上加入参残差网络层,然后在后面接上yolov3的3个尺度的检测层,最后剪枝报错了。 #44

Closed chenjunson closed 4 years ago

chenjunson commented 4 years ago

报错如下:chenjunsong@chenjunsong-GJ5CN64:~/U-YOLOv3$ python3 normal_prune.py --data data/obj.data --cfg cfg/yolov2/yolo-obj.cfg --weights weights/best.pt --percent 0.1 Namespace(cfg='cfg/yolov2/yolo-obj.cfg', data='data/obj.data', img_size=608, percent=0.1, weights='weights/best.pt') Model Summary: 120 layers, 4.07562e+07 parameters, 4.07562e+07 gradients Caching labels (500 found, 0 missing, 0 empty, 0 duplicate, for 500 images): 100%|█████████████████████████████████████████████████████████████████████████████████████| 500/500 [00:00<00:00, 10877.12it/s] Class Images Targets P R mAP@0.5 F1: 100%|█████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:28<00:00, 1.12it/s] all 500 2.09e+03 0.57 0.00759 0.135 0.015 Threshold should be less than 0.9868. The corresponding prune ratio is 0.987. Channels with Gamma value less than 0.0965 are pruned! Number of channels has been reduced from 9888 to 8900 Prune ratio: 0.100 layer index: 0 total channel: 32 remaining channel: 30 layer index: 2 total channel: 64 remaining channel: 59 layer index: 5 total channel: 64 remaining channel: 57 layer index: 10 total channel: 128 remaining channel: 115 layer index: 15 total channel: 256 remaining channel: 224 layer index: 18 total channel: 256 remaining channel: 232 layer index: 23 total channel: 512 remaining channel: 470 layer index: 26 total channel: 512 remaining channel: 471 layer index: 29 total channel: 512 remaining channel: 461 layer index: 30 total channel: 1024 remaining channel: 910 layer index: 31 total channel: 512 remaining channel: 453 layer index: 32 total channel: 1024 remaining channel: 923 layer index: 33 total channel: 512 remaining channel: 461 layer index: 34 total channel: 1024 remaining channel: 933 layer index: 41 total channel: 256 remaining channel: 234 layer index: 42 total channel: 512 remaining channel: 457 layer index: 43 total channel: 256 remaining channel: 229 layer index: 44 total channel: 512 remaining channel: 462 layer index: 45 total channel: 256 remaining channel: 229 layer index: 46 total channel: 512 remaining channel: 459 layer index: 53 total channel: 128 remaining channel: 105 layer index: 54 total channel: 256 remaining channel: 238 layer index: 55 total channel: 128 remaining channel: 118 layer index: 56 total channel: 256 remaining channel: 232 layer index: 57 total channel: 128 remaining channel: 113 layer index: 58 total channel: 256 remaining channel: 225 Prune channels: 988 Prune ratio: 0.063 Caching labels (500 found, 0 missing, 0 empty, 0 duplicate, for 500 images): 100%|█████████████████████████████████████████████████████████████████████████████████████| 500/500 [00:00<00:00, 11243.52it/s] Class Images Targets P R mAP@0.5 F1: 100%|█████████████████████████████████████████████████████████████████████████████████████| 32/32 [00:27<00:00, 1.15it/s] all 500 2.09e+03 0.584 0.0067 0.134 0.0133 after prune_model_keep_size map is 0.13384984434263122 Model Summary: 120 layers, 3.55866e+07 parameters, 3.55866e+07 gradients Traceback (most recent call last): File "normal_prune.py", line 183, in init_weights_from_loose_model(compact_model, pruned_model, CBL_idx, Other_idx, CBLidx2mask) File "/home/chenjunsong/U-YOLOv3/utils/prune_utils.py", line 194, in init_weights_from_loose_model input_mask = get_input_mask(loose_model.module_defs, idx, CBLidx2mask) File "/home/chenjunsong/U-YOLOv3/utils/prune_utils.py", line 154, in get_input_mask return CBLidx2mask[idx - 2] KeyError: 7

SpursLipu commented 4 years ago

yolov2肯定是可以做的,但我没时间做了,你得自己调一下。