WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.25k stars 4.18k forks source link

Help for transfer learning on a custom dataset #1832

Open alient12 opened 1 year ago

alient12 commented 1 year ago

Thanks for this great repo. I was working with YOLOv7 and I have some questions. I really appreciate for any help and recommendation from anyone.

This is what I did and my questions are at the end.

Dataset

I have 2 datasets for fresh and rotten apple, banana, orange, let's say dataset A and B.

Dataset A:

Dataset B:

Training

I used transfer learning on Dataset A with YOLOv7 tiny. Changed number of classes to 83 and mapped fresh apple, fresh orange and fresh banana with their index in COCO and added 3 new indexes for rotten apple, rotten banana and rotten orange. This is the result after 300 epochs:

validation: P R mAP@0.5 mAP@.5:.95
0.9706 0.9438 0.9826 0.9005
test P R mAP@0.5 mAP@.5:.95
0.96 0.956 0.981 0.887

results

The results say it's ok but when I tested it on Dataset B it wasn't ok. some tested images from Dataset B:

rotated_by_15_Screen Shot 2018-06-08 at 5 14 20 PM rotated_by_15_Screen Shot 2018-06-07 at 2 25 26 PM rotated_by_75_Screen Shot 2018-06-08 at 2 34 47 PM

Questions

  1. Did my model overfit because of 300 epochs are too high and 1200 images are too low?
  2. Is it fair to test model trained on 640x640 images on a lower size images?
  3. How can I combine Dataset B with Dataset A since B is low quality (augmented, lower resolution)?
  4. My last question is about labeling. In some images there are lots of apples (around 20, a few of them are on surface and the others are behind), I tagged all of them. Does it increase False Positive? Should I tag them as one? I tagged them separately because I wanted to use it on a robot arm application.
FreshApple (27) image
SamuelHafner commented 1 year ago

I can say to 1. that I mostly train my yolov7 models with 10 epochs and a batchsize of 40. This works pretty well for me and I got on a based yolov7x trained model a mAP(0.5...0.95) of 0.7. But I trained from scratch with the yolov7x coco model as pretrain and the ycbv and ycbm Dataset combined (so 126000 train images and 52000 validation images).