LSH9832 / edgeyolo

an edge-real-time anchor-free object detector with decent performance
Apache License 2.0
441 stars 58 forks source link

Custom Training gives no detections #15

Closed icklerly1 closed 1 year ago

icklerly1 commented 1 year ago

Hi, I am training edgeyolo on a custom dataset. Unfortunately the model does not detect any objects. Also the training loss does not decrease as expected.

number of images: train images: 15000 val images: 4370

and the auto calculated anchors in yolov4 would be: [5, 10], [13, 30], [25, 64], [38,123], [51,230], [87,158], [82,340], [136,420], [256,492]

My questions now:

Do I need to edit the anchors in params/model/edgeyolo.yaml ? And do I need to change the learning rate maybe?

LSH9832 commented 1 year ago

please do not change anchors in yaml file because this is an anchor-free detector(which is equivalent to that the size of the anchor box is the reciprocal of the scaling factor of the feature map) and changing to anchor-based models is not supported. you can change your learning rate if necessary.

icklerly1 commented 1 year ago

Alright. So I want to adapt the learning rate:

The calculation for the learning rate is lr_per_img: 0.00015625 # total_lr = lr_per_img batch_size_per_gpu len(devices)

What is the desired total_lr ? Otherwise I cannot calculate it for my custom training.

LSH9832 commented 1 year ago

Generally 0.01 or less

LSH9832 commented 1 year ago

there is no fixed way to adjust learning rate, it depends on yourself

icklerly1 commented 1 year ago

Hi,

thank you. I now tried to adjusted the learning rate to a lower value.

I additionally checked our annotations as well. Below you can see a picture:

testAnno

We only have 2 classes: "head" and "person".

In addition I changed the number of classes in params/model/edgeyolo.yaml:

from nc: 80 to nc: 2

I can start my training, the loss is decreasing a bit but right now I only get weird looking results, like this:

Do you have any idea what might be going wrong? I am really out of ideas..

blub

LSH9832 commented 1 year ago
  1. you can modify and run demo/load_dataset.py to ensure that images and annotations in your training is correct.
  2. it is not necessary to change nc from 80 to 2, it finally depends on length of names in your dataset config.
  3. it is recomended to use my model trained on coco dataset as your pretrained model
icklerly1 commented 1 year ago

Thanks a lot for your help! I found an error in my dataset preparation.

It now works great! Thanks again.