yolov5 icon indicating copy to clipboard operation
yolov5 copied to clipboard

Yolov5 model capturing other objects other than the intended or desired object

Open youssef66677 opened this issue 1 year ago • 2 comments

Search before asking

  • [X] I have searched the YOLOv5 issues and discussions and found no similar questions.

Question

I have a YOLO V5 m model for a dataset to detect a certain product but after training a dataset of a variety of pictures for the product in different cases and scenarios and various lighting conditions with no repetition for the cases, on 50 epochs and the Yolo v5 medium architecture and batch size of 16. What I have noticed is that the model is dependent on the color features, meaning that the objects have colors yellow and its shades and graidents. What should I do to fix this problem? Kindly help me, also kindly find the used dataset for training below

The product desired to be detected:

3 IMG_4712

The other products that are detected: 1 2

The dataset used in training (aprox 450 images) in google drive: https://drive.google.com/file/d/1oBH28fbyhEmabLLx2bPXpEMQ0s2zhg__/view?usp=sharing

Additional

No response

youssef66677 avatar Dec 18 '24 13:12 youssef66677

👋 Hello @youssef66677, thank you for your interest in YOLOv5 🚀! This is an automated response to help guide you while an Ultralytics engineer reviews your issue soon.

From your description, it seems like your model may be overfitting or potentially relying too heavily on color features for prediction. To provide better assistance, we need a bit more information.

If this is a 🐛 Bug Report:

Please ensure that you provide a minimum reproducible example (MRE). This includes a clear code snippet or setup that reproduces the issue, along with relevant logs or error messages.

If this is a custom training ❓ Question:

Providing as much detail as possible is key. In addition to the images and dataset link you've shared, consider elaborating on the following:

  • Validation and training metrics (mAP, precision, recall).
  • Training visualizations such as loss curves and accuracy trends over epochs.
  • If you are using augmentation techniques, specify the methods used.
  • Confirm you're following the best practices outlined in YOLOv5's guidelines (e.g., ensuring dataset balance, annotation quality, etc.).

Requirements

Ensure that your software environment meets YOLOv5's requirements, including Python>=3.8.0 and PyTorch>=1.8 installed correctly along with the other libraries in the requirements.txt file. Running a fresh setup can also help rule out dependency issues.

Environments

YOLOv5 can run in multiple verified environments, such as Colab notebooks, local machines, Docker, and cloud platforms, all of which support GPU acceleration. Please confirm your training environment and configuration.

Status

Our Continuous Integration (CI) tests verify YOLOv5 functionality daily across supported platforms. You can check these results before investigating further.

Providing more specific details and a concise reproducible setup will help us pinpoint the issue and guide you effectively. We're here to help! 😊

UltralyticsAssistant avatar Dec 18 '24 13:12 UltralyticsAssistant

@youssef66677 thank you for reaching out. Based on your observations, it seems the model might be overfitting to color features in your dataset. Here are a few suggestions to address this issue:

  1. Increase Dataset Size and Variety: With only ~450 images, your dataset may be insufficient for robust feature learning. Aim for at least 1500 images per class with diverse backgrounds, lighting, and object variations (reference).

  2. Data Augmentation: Apply augmentation techniques like color jitter, grayscale conversion, and random saturation/hue shifts during training to reduce reliance on color features. YOLOv5 supports these through the hyp.yaml file.

  3. Add Background Images: Include images without your target product to reduce false positives. Background images help the model distinguish between relevant and irrelevant features (reference).

  4. Fine-tune Hyperparameters: Adjust learning rate, confidence threshold, and class weights to encourage better generalization.

  5. Analyze Labels: Verify your labeling consistency to ensure accurate bounding boxes and eliminate any bias in annotations.

Please try these steps and retrain the model. If the issue persists, feel free to share additional information such as your loss curves, mAP scores, and confusion matrix for further analysis.

pderrenger avatar Dec 19 '24 10:12 pderrenger

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

  • Docs: https://docs.ultralytics.com
  • HUB: https://hub.ultralytics.com
  • Community: https://community.ultralytics.com

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

github-actions[bot] avatar Nov 23 '25 00:11 github-actions[bot]