ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.6k stars 16.1k forks source link

Overlapping Bounding Boxes of Different Classes #13203

Open toigni opened 1 month ago

toigni commented 1 month ago

Search before asking

Question

I annotate the small bounding box in Class B to be covered by the bounding box in Class A

Screenshot_20240720-111135~2

Despite increasing the amount of training data, the result of the detect after training is the appearance of a Class B bounding box of the same size as the Class A bounding box.

Screenshot_20240720-111142~2

Here are my questions: Is this issue the same as the one discussed in Issue #2172? Do you know if this has been improved in YOLOv8?

Additional

No response

github-actions[bot] commented 1 month ago

👋 Hello @toigni, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 1 month ago

@toigni hi there!

Thank you for reaching out and providing detailed information about your issue. Overlapping bounding boxes of different classes can indeed be a challenging problem. Here are a few steps and suggestions to help address this:

  1. Verify with Latest Version: First, ensure that you are using the latest version of YOLOv5. Sometimes, updates include bug fixes and improvements that might resolve your issue. You can update YOLOv5 by pulling the latest changes from the repository:

    git pull
  2. Adjusting Non-Maximum Suppression (NMS): The issue might be related to the Non-Maximum Suppression (NMS) settings. You can try adjusting the NMS threshold to see if it helps in differentiating the bounding boxes of different classes. You can modify the NMS threshold in the detect.py script:

    parser.add_argument('--conf-thres', type=float, default=0.25, help='object confidence threshold')
    parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
  3. Class-Specific NMS: Another approach is to use class-specific NMS, which can help in handling overlapping boxes of different classes more effectively. This feature is available in YOLOv5 and can be enabled by setting the agnostic parameter to False:

    results = non_max_suppression(prediction, conf_thres, iou_thres, classes=None, agnostic=False)
  4. Data Augmentation: Increasing the amount of training data is a good step. Additionally, you can try different data augmentation techniques to improve the robustness of your model. Techniques such as mosaic augmentation, mixup, and random cropping can help.

  5. Issue #2172: The issue you mentioned (#2172) might be related, but it's always good to verify with the latest version and try the above suggestions.

  6. YOLOv8: YOLOv8 is still under development, and while it aims to bring improvements, it's essential to check the latest documentation and release notes for specific enhancements related to overlapping bounding boxes.

If the problem persists, please provide more details about your training configuration and any custom modifications you have made. This will help in diagnosing the issue more accurately.

Feel free to reach out if you have any more questions or need further assistance. The YOLO community and the Ultralytics team are always here to help! 😊