-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yolov5 pruning model does not detect images #286
Comments
The same issue here. |
|
I referred to yolov7's code and tested it on yolov5-v7.0 successfully. Hope this is helpful.
|
Thanks again, I've tried your method but find that the mAP after training is not up to the original level, any way to fine tune it? thanks |
Try this script:
--weights: path of fp32 model The mAP after pruning may be lower, but not a lot. In my case, [email protected] is as the same as before, but [email protected]:.95 is 1% lower. |
thanks, but I can't find the file named train_after_pruning.py, how can I get it ?please |
Actually, just copy above code I provided to a file and name this file as "train_after_pruning.py". |
@LorenzoSun-V thanks for the train_after_pruning script. I was having some issues in getting good accuracy in retraining after pruning in case of COCO dataset and yolov5s model architecture. Can you please tell me for what dataset and model configuration you got, [email protected] is as the same as before, but [email protected]:.95 is 1% lower as you had stated. Also, in my case I trained for 100 epochs with image size 320 and target prune rate of 0.5. But my mAP did drop significantly 0.34 from 0.48 in case of reference yolov5s model. |
@max190 , in my case, the dataset is labeled well and the task is relatively easy(just 2 classes for detection, and the features of each class are quite explicit). I suspect some important channels in your case had been pruned so your mAP was much lower even after training. Maybe you can try to use yolov5m and 0.3 pruning ratio. |
@LorenzoSun-V Thank you for providing the pruning code for v5. I ran it smoothly with it, but when I used it for inference in the video, the effect became unsatisfactory, and many targets were not detected. Is there still code that needs fine-tuning? Can you provide some code for fine-tuning? Thank you for your answer. Looking forward to hearing from you |
@maolinLiu666 I also got the same. Have you solved it? |
Before Pruning: MACs=1.009904 G, #Params=0.007226 G
After Pruning: MACs=0.379899 G, #Params=0.002635 G
image 1/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000009.jpg: 480x640 (no detections), 101.8ms
image 2/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000025.jpg: 448x640 (no detections), 82.9ms
image 3/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000030.jpg: 448x640 (no detections), 71.5ms
image 4/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000034.jpg: 448x640 (no detections), 69.0ms
image 5/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000036.jpg: 640x512 (no detections), 91.1ms
image 6/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000042.jpg: 480x640 (no detections), 77.8ms
image 7/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000049.jpg: 640x512 (no detections), 84.7ms
image 8/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000061.jpg: 512x640 (no detections), 89.4ms
image 9/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000064.jpg: 640x480 (no detections), 83.9ms
image 10/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000071.jpg: 448x640 (no detections), 75.2ms
image 11/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000072.jpg: 640x448 (no detections), 84.1ms
image 12/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000073.jpg: 640x576 (no detections), 106.5ms
image 13/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000074.jpg: 448x640 (no detections), 70.4ms
image 14/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000077.jpg: 480x640 (no detections), 79.0ms
image 15/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000078.jpg: 640x640 (no detections), 116.0ms
image 16/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000081.jpg: 448x640 (no detections), 75.0ms
image 17/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000086.jpg: 640x512 (no detections), 78.2ms
image 18/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000089.jpg: 480x640 (no detections), 77.8ms
image 19/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000092.jpg: 448x640 (no detections), 72.0ms
image 20/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000094.jpg: 448x640 (no detections), 73.5ms
image 21/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000109.jpg: 416x640 (no detections), 88.5ms
image 22/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000110.jpg: 480x640 (no detections), 76.1ms
image 23/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000113.jpg: 640x416 (no detections), 79.8ms
image 24/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000127.jpg: 512x640 (no detections), 89.1ms
image 25/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000133.jpg: 480x640 (no detections), 80.7ms
image 26/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000136.jpg: 480x640 (no detections), 78.8ms
image 27/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000138.jpg: 576x640 (no detections), 109.7ms
image 28/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000142.jpg: 640x480 (no detections), 80.5ms
image 29/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000143.jpg: 544x640 (no detections), 100.0ms
image 30/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000144.jpg: 480x640 (no detections), 76.2ms
image 31/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000149.jpg: 448x640 (no detections), 74.3ms
image 32/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000151.jpg: 640x480 (no detections), 84.7ms
image 33/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000154.jpg: 640x448 (no detections), 69.5ms
image 34/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000164.jpg: 480x640 (no detections), 77.3ms
image 35/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000165.jpg: 544x640 (no detections), 90.5ms
image 36/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000192.jpg: 480x640 (no detections), 78.4ms
image 37/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000194.jpg: 480x640 (no detections), 76.0ms
image 38/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000196.jpg: 480x640 (no detections), 80.3ms
image 39/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000201.jpg: 448x640 (no detections), 71.8ms
image 40/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000208.jpg: 480x640 (no detections), 78.2ms
image 41/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000241.jpg: 640x480 (no detections), 81.9ms
image 42/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000247.jpg: 448x640 (no detections), 76.5ms
image 43/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000250.jpg: 480x640 (no detections), 76.0ms
image 44/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000257.jpg: 480x640 (no detections), 83.0ms
image 45/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000260.jpg: 448x640 (no detections), 73.5ms
image 46/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000263.jpg: 640x608 (no detections), 107.1ms
image 47/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000283.jpg: 640x448 (no detections), 72.2ms
image 48/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000294.jpg: 448x640 (no detections), 75.4ms
image 49/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000307.jpg: 480x640 (no detections), 79.3ms
image 50/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000308.jpg: 448x640 (no detections), 73.6ms
image 51/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000309.jpg: 640x640 (no detections), 103.1ms
image 52/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000312.jpg: 448x640 (no detections), 72.3ms
image 53/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000315.jpg: 448x640 (no detections), 75.7ms
image 54/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000321.jpg: 480x640 (no detections), 81.6ms
image 55/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000322.jpg: 512x640 (no detections), 89.6ms
image 56/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000326.jpg: 448x640 (no detections), 78.0ms
image 57/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000328.jpg: 512x640 (no detections), 91.2ms
image 58/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000332.jpg: 480x640 (no detections), 79.2ms
image 59/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000338.jpg: 352x640 (no detections), 78.3ms
image 60/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000349.jpg: 480x640 (no detections), 85.9ms
image 61/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000357.jpg: 224x640 (no detections), 56.4ms
image 62/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000359.jpg: 448x640 (no detections), 75.8ms
image 63/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000360.jpg: 480x640 (no detections), 78.8ms
image 64/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000368.jpg: 640x480 (no detections), 85.2ms
image 65/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000370.jpg: 640x480 (no detections), 83.5ms
image 66/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000382.jpg: 480x640 (no detections), 83.1ms
image 67/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000384.jpg: 640x448 (no detections), 78.5ms
image 68/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000387.jpg: 480x640 (no detections), 88.8ms
image 69/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000389.jpg: 480x640 (no detections), 82.5ms
image 70/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000394.jpg: 640x640 (no detections), 103.8ms
image 71/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000395.jpg: 608x640 (no detections), 115.1ms
image 72/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000397.jpg: 480x640 (no detections), 94.8ms
image 73/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000400.jpg: 640x640 (no detections), 117.0ms
image 74/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000404.jpg: 640x448 (no detections), 86.2ms
image 75/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000415.jpg: 640x384 (no detections), 94.9ms
image 76/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000419.jpg: 480x640 (no detections), 104.4ms
image 77/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000428.jpg: 384x640 (no detections), 91.5ms
image 78/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000431.jpg: 416x640 (no detections), 80.0ms
image 79/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000436.jpg: 640x448 (no detections), 81.0ms
image 80/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000438.jpg: 480x640 (no detections), 91.9ms
image 81/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000443.jpg: 480x640 (no detections), 85.9ms
image 82/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000446.jpg: 640x480 (no detections), 83.9ms
image 83/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000450.jpg: 480x640 (no detections), 86.5ms
image 84/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000459.jpg: 640x544 (no detections), 109.8ms
image 85/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000471.jpg: 448x640 (no detections), 87.9ms
image 86/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000472.jpg: 256x640 (no detections), 68.4ms
image 87/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000474.jpg: 640x448 (no detections), 83.2ms
image 88/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000486.jpg: 448x640 (no detections), 81.2ms
image 89/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000488.jpg: 416x640 (no detections), 73.7ms
image 90/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000490.jpg: 640x640 (no detections), 114.1ms
image 91/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000491.jpg: 416x640 (no detections), 75.7ms
image 92/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000502.jpg: 448x640 (no detections), 81.0ms
image 93/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000508.jpg: 480x640 (no detections), 88.9ms
image 94/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000510.jpg: 480x640 (no detections), 118.2ms
image 95/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000514.jpg: 640x384 (no detections), 72.0ms
image 96/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000520.jpg: 480x640 (no detections), 83.2ms
image 97/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000529.jpg: 640x448 (no detections), 75.7ms
image 98/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000531.jpg: 480x640 (no detections), 84.8ms
image 99/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000532.jpg: 480x640 (no detections), 84.2ms
image 100/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000536.jpg: 480x640 (no detections), 89.3ms
image 101/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000540.jpg: 448x640 (no detections), 78.6ms
image 102/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000542.jpg: 512x640 (no detections), 90.9ms
image 103/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000544.jpg: 448x640 (no detections), 83.3ms
image 104/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000560.jpg: 448x640 (no detections), 78.5ms
image 105/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000562.jpg: 640x448 (no detections), 76.4ms
image 106/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000564.jpg: 640x544 (no detections), 106.5ms
image 107/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000569.jpg: 480x640 (no detections), 92.3ms
image 108/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000572.jpg: 640x448 (no detections), 76.2ms
image 109/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000575.jpg: 544x640 (no detections), 105.0ms
image 110/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000581.jpg: 640x608 (no detections), 116.4ms
image 111/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000584.jpg: 448x640 (no detections), 79.8ms
image 112/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000589.jpg: 480x640 (no detections), 90.9ms
image 113/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000590.jpg: 640x544 (no detections), 100.4ms
image 114/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000595.jpg: 480x640 (no detections), 82.8ms
image 115/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000597.jpg: 256x640 (no detections), 51.9ms
image 116/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000599.jpg: 416x640 (no detections), 70.6ms
image 117/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000605.jpg: 480x640 (no detections), 88.3ms
image 118/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000612.jpg: 480x640 (no detections), 87.9ms
image 119/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000620.jpg: 640x480 (no detections), 80.8ms
image 120/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000623.jpg: 640x480 (no detections), 79.6ms
image 121/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000625.jpg: 448x640 (no detections), 69.1ms
image 122/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000626.jpg: 480x640 (no detections), 92.7ms
image 123/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000629.jpg: 448x640 (no detections), 86.0ms
image 124/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000634.jpg: 640x448 (no detections), 71.2ms
image 125/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000636.jpg: 640x480 (no detections), 111.7ms
image 126/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000641.jpg: 448x640 (no detections), 253.3ms
image 127/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000643.jpg: 480x640 (no detections), 92.6ms
image 128/128 D:\Torch-Pruning-master\data\coco128\images\train2017\000000000650.jpg: 448x640 (no detections), 76.3ms
Speed: 0.6ms pre-process, 86.0ms inference, 7.5ms NMS per image at shape (1, 3, 640, 640)
Results saved to runs\detect\exp3
The text was updated successfully, but these errors were encountered: