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

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

Open
1 task done
youssef66677 opened this issue Dec 18, 2024 · 2 comments
Open
1 task done
Labels
detect Object Detection issues, PR's question Further information is requested

Comments

@youssef66677
Copy link

youssef66677 commented Dec 18, 2024

Search before asking

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 youssef66677 added the question Further information is requested label Dec 18, 2024
@UltralyticsAssistant UltralyticsAssistant added the detect Object Detection issues, PR's label Dec 18, 2024
@UltralyticsAssistant
Copy link
Member

👋 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! 😊

@pderrenger
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detect Object Detection issues, PR's question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants