Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is yolov5 sensitive to the size of defects and what structural improvements are needed to increase its sensitivity to defects? #13027

Open
1 task done
AFallDay opened this issue May 20, 2024 · 5 comments
Labels
question Further information is requested

Comments

@AFallDay
Copy link

Search before asking

Question

Is yolov5 sensitive to the size of defects and what structural improvements are needed to increase its sensitivity to defects size?

Additional

No response

@AFallDay AFallDay added the question Further information is requested label May 20, 2024
@glenn-jocher
Copy link
Member

@AFallDay hello! 😊 YOLOv5 can indeed be sensitive to the size of defects, especially very small or very large ones compared to the overall image size. To enhance sensitivity to defect sizes, consider the following:

  1. Adjust Anchor Boxes: Customize anchor boxes to better match the typical sizes of defects in your dataset. This can be done by analyzing the distribution of defect sizes and adjusting the anchor box dimensions accordingly in the model's configuration.

  2. Image Resolution: Training and inference with higher image resolutions can help in detecting smaller defects. You can adjust the --img-size parameter during training and detection to a higher value suitable for your needs.

  3. Data Augmentation: Use augmentation techniques that emphasize size variations, like scaling and cropping, to make the model more robust to different defect sizes.

  4. Model Layers: Experiment with adding more layers or adjusting the depth of the network, as deeper networks might capture more detailed features, though at the cost of increased computational resources.

For more detailed guidance on customizing your model, you might find the documentation on model configuration and training tips helpful: https://docs.ultralytics.com/yolov5/.

Hope this helps! Let us know if you have any more questions.

@SwHaraday
Copy link

SwHaraday commented May 27, 2024

Hi,
If your deffects are small like 25x25 pixels in 640x640 image and have just slight defference from normal part, model tends to over-detect.
One possible reason is that Ground Truth Boxes are cut during Mosaic Augmentation and used as unintended training data.
In our case of surface deffect detection, I observed about 30% Ground Truth Boxes in trainig batch were cut and not as I anotated.
Model trained in default way works nice, but you may struggle with over detection.

You may need to add some function to keep Ground Truth Boxes as you intended during Mosaic Augmentation.

@glenn-jocher
Copy link
Member

Hi @SwHaraday,

Thank you for sharing your observations! 😊

You bring up a valid point about the potential impact of Mosaic Augmentation on small defects. Indeed, when ground truth boxes are cut during augmentation, it can lead to unintended training data and over-detection issues.

To address this, you can modify the Mosaic Augmentation process to ensure that ground truth boxes remain intact. This can be done by adding a function to check and adjust the placement of boxes during augmentation.

Additionally, you might consider experimenting with other augmentation techniques or adjusting the augmentation parameters to better suit your specific use case.

Your insights are valuable to the community, and we appreciate your contribution!

@SwHaraday
Copy link

SwHaraday commented May 27, 2024

Hi Glenn,
Thank you for reply. I never expected to have comment from you.
I hope this helps someone who has the same problem.
The implimentation is poor and childish, but at least it works.

https://github.com/SwHaraday/YOLOv5-dataloaders-for-industrial-purpose

@glenn-jocher
Copy link
Member

Hi @SwHaraday,

Thank you for sharing your implementation! 😊 Your contribution is valuable, and it's great to see the community working together to solve common issues. Every improvement, no matter how small, helps us all move forward.

For anyone facing similar challenges, your solution could be a helpful resource. Keep up the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants