Yolov5 with Pytorch Overfitting Problem

Hello there. I trained in yolov5 with my own data set and my map values ​​are like this. As a result of the model I made with 30 epochs, it did a normal quality job when testing with video, but when I tested the same video with the model formed as a result of 300 epochs, it did a worse job than 30 epochs. how can i solve this.



Hi,

As you have correctly identified in the title, the model suffers from overfitting.
Especially for object detection these are some specific ways you can solve them:

Use Data Augmentation using the Albumentations Library
Data Augmentations is a way to prevent your model from learning on noise by simply altering the data to express more variety. This can introduce helpful aspects of your model like translational or rotational invariance. You can apply these augmentations to the frames of your video and a great thing is that these albumentations work to transform both boxes and images so you don’t have to worry about that.
I suggest you check out this github and doc to get started:

Additionally you can try to obtain more data by looking for other well known dataset like openImages, Imagenet, COCO etc. and altering your dataclass to work on images that share the same classes you are already testing for.

Another thing to try is to increase the weight decay in your model. Note: You can also find more geeneral advice on overfitting on the internet but these are some specific ways you can tackle the issue you have right now.

Sarthak

1 Like

Thank you for your interest.
I will try to increase data. You said weight reduction in the model, what exactly is this? you mean my L2 norm

It depends on your optimizer.
Use this documentation to find out more on whether it L1, L2 or some smart combination.
https://pytorch.org/docs/stable/optim.html

Check this image as an example.

Also, in addtion to more data, I really suggest you check out the albumentations library as that can add a lot to your model.

Sarthak Jain

thank you my friend. i will do what you say