WongKinYiu / yolov9

Implementation of paper - YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
GNU General Public License v3.0
8.63k stars 1.31k forks source link

Yolov9-s is slower than Yolov9-c. Why is this? #497

Open shigeomi-t opened 1 month ago

shigeomi-t commented 1 month ago

I trained models with my custom dataset. Yolov9-s model trained with my custom dataset is slower to detect than Yolov9-c trained with my custom dataset.

Execution command python detect_dual.py --source my_test_dataset_folder --img 448 --device 0 --weights path_to_my_model --name= my.yaml

Model Image Size Parameter Number of images for detection Detection Total Time GPU
Yolov9-s 448px 9,743,366 2,500 5m10sec RTX 3070ti
Yolov9-c 448px 50,999,590 2,500 4m12sec RTX 3070ti

Yolov9-s should be faster, but this is the result. Why is this? How can I speed up the detection of Yolov9-s?

guillermo-gabrielli-fer commented 1 month ago

Did you try benchmarking it after reparametrization (with detect.py)? Also if you ran the S version first, the images may have been cached in memory for the C run, depending on disk random access speed, it may be more substantial than the model difference.

I think some layers in T and S are relatively deeper compared to M and upwards, which may result in heavier auxiliary branches. Before reparametrization, it will still be using these parameters.

shigeomi-t commented 4 weeks ago

@guillermo-gabrielli-fer Thank you for your advice.

I cached model loaded and also put all the images in memory and then ran the detection, but Yolov9-s was slower.

This may be unrelated, but when I tried reparameterization, which is provided in this repository, I could not do it because of an error.

reparameterization code tools/reparameterization.ipynb Convert YOLOv9-S

Error raised

model.21.cv4.bn.num_batches_tracked perfectly matched!! Traceback (most recent call last): File "reparameterization.py", line 24, in model.state_dict()[k] += ckpt['model'].state_dict()[kr] KeyError: 'model.32.cv4.0.cv1.conv.weight'

I have no way to resolve this issue. Can someone please advise me?