stark-t / PAI

Pollination_Artificial_Intelligence
5 stars 1 forks source link

Implement YOLOv7 tiny #55

Closed valentinitnelav closed 1 year ago

valentinitnelav commented 1 year ago

Make sure to use the tiny weights and the yolov7-tiny.yaml cfg file for a fair comparison with YOLOv5 n & s models.

Are there tiny COCO weights for the Pythorch implementation? The confusion started from there I think.

stark-t commented 1 year ago

@valentinitnelav I hope these weights work, best case is that weights can be used for pytorch and darknet as well.

weights yolov7tiny cfg

valentinitnelav commented 1 year ago

I had the same issue with YOLOv4 (see #44). I remember I had some darknet weights but were not compatible with the Pythorch framework. i will try nevertheless, but I do not have high hopes.

stark-t commented 1 year ago

@valentinitnelav ok.... do we have any idea what to do if this doenst work?

another link to some tiny weights (found in this issue)

valentinitnelav commented 1 year ago

That is indeed the correct link. I do not know why I didn't use the yolov7-tiny.pt from the start. Thanks for your patience. I think that somehow I presumed at that time that yolov7.pt are the smallest pretrained weights. I looked at this table in the README file which is actually about general performance metrics and not about all available weights.

Also, I double-checked and we do not need to use the --cfg argument in the train.py if we do not train from scratch. As long as we use the --weights argument, then the model architecture is presumed from that. --cfg must be mentioned when training from scratch - see Train Custom Data - 3. Train

Train a YOLOv5s model on COCO128 by specifying dataset, batch-size, image size and either pretrained --weights yolov5s.pt (recommended), or randomly initialized --weights '' --cfg yolov5s.yaml (not recommended)

and this comment of Glenn Jocher

--cfg will cause a new model to be constructed from scratch. Any matching layers in --weights will be transferred.

Also, to be extra sure, I checked in the .err cluster file and I can see that the printed model architecture matches the yolov7-tiny.yaml which uses LeakyReLU.

I'll have updated results for YOLOv7 in the coming days.

valentinitnelav commented 1 year ago

FYI

In the *.log file I get a download error for the weights even though I made sure that I downloaded them manually before running the script yolov7_train_tiny_640_rtx.sh

Downloading https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt to /home/sc.uni-leipzig.de/user/pai/detectors/yolov7/weights_v0_1/yolov7-tiny.pt...
Download error: [Errno 2] No such file or directory: '/home/sc.uni-leipzig.de/user/pai/detectors/yolov7/weights_v0_1/tmpjok410lv'
ERROR: Download failure: /home/sc.uni-leipzig.de/user/pai/detectors/yolov7/weights_v0_1/yolov7-tiny.pt missing, try downloading from https://github.com/WongKinYiu/yolov7/releases/

The problem is that the path is corrupted because somehow it uses pai instead of PAI. This is done internally/on the fly and not from yolov7_train_tiny_640_rtx.sh, so not sure where the bug happens.

However, this error didn't break the training process and we might neglect it. I just document it here for now.

valentinitnelav commented 1 year ago

Fresh results with YOLOv7-tiny (results from 191623_yolov7_img640_b8_e300_hyp_custom)

confusion_matrix

results

stark-t commented 1 year ago

@valentinitnelav really cool. Thank you so much for putting in the effort to run this.

valentinitnelav commented 1 year ago

Fixed with https://github.com/stark-t/PAI/commit/5f22789fdc776202f45a5685fc789e9b49ddfe0e