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

Yolov8 Bad detections #12631

Open
1 task done
IbrahimAlmasri01 opened this issue May 12, 2024 · 7 comments
Open
1 task done

Yolov8 Bad detections #12631

IbrahimAlmasri01 opened this issue May 12, 2024 · 7 comments
Labels
question Further information is requested

Comments

@IbrahimAlmasri01
Copy link

Search before asking

Question

Hello, I am training a model on objects that are small and with a varying lighting conditions.
I now have more than 1000 images, and the model is doing really bad in detection. I am not talking about misclassification.

Thus, is there any recommendations to solve this problem?
I have tried multiple hyperparameters and so on. But if there is anything else I am missing out please let me know !

Thanks

Additional

No response

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

@IbrahimAlmasri01 hi there! 😊 It sounds like you're working hard on training your model under challenging conditions! Here are a couple of suggestions that might help improve detection performance:

  1. Data augmentation: This can be particularly beneficial for small objects and varying lighting conditions. Consider using augmentations that simulate different lighting (brightness, contrast) and those that manipulate the size and position of objects (scaling, cropping, rotation).

  2. Modify Anchor Boxes: Adjust the anchor boxes in your configuration to better match the size distribution of your small objects. This can help the model better localize these objects.

  3. Increase Model Resolution: Training and inferring at a higher resolution can improve the detection of small objects.

Here's how you can increase the input size for training in your YAML configuration file:

# Example of increasing input resolution
image_size: 640  # Increase this size appropriate to your computational capabilities

And for data augmentation, you might modify your dataset's settings to include random brightness and contrast adjustments:

# Adding data augmentation in data.yaml
augmentations:
  brightness: 0.1  # Adjust brightness by a factor of ±0.1
  contrast: 0.2  # Adjust contrast by a factor of ±0.2

I hope these tips help! Let us know how it goes or if you need further assistance. Happy training! 🚀

@echo385
Copy link

echo385 commented May 13, 2024

@IbrahimAlmasri01 hi there! 😊 It sounds like you're working hard on training your model under challenging conditions! Here are a couple of suggestions that might help improve detection performance:

  1. Data augmentation: This can be particularly beneficial for small objects and varying lighting conditions. Consider using augmentations that simulate different lighting (brightness, contrast) and those that manipulate the size and position of objects (scaling, cropping, rotation).
  2. Modify Anchor Boxes: Adjust the anchor boxes in your configuration to better match the size distribution of your small objects. This can help the model better localize these objects.
  3. Increase Model Resolution: Training and inferring at a higher resolution can improve the detection of small objects.

Here's how you can increase the input size for training in your YAML configuration file:

# Example of increasing input resolution
image_size: 640  # Increase this size appropriate to your computational capabilities

And for data augmentation, you might modify your dataset's settings to include random brightness and contrast adjustments:

# Adding data augmentation in data.yaml
augmentations:
  brightness: 0.1  # Adjust brightness by a factor of ±0.1
  contrast: 0.2  # Adjust contrast by a factor of ±0.2

I hope these tips help! Let us know how it goes or if you need further assistance. Happy training! 🚀

Where can I find all the parameters that can be modified in augmentations?

@echo385
Copy link

echo385 commented May 13, 2024

@IbrahimAlmasri01 hi there! 😊 It sounds like you're working hard on training your model under challenging conditions! Here are a couple of suggestions that might help improve detection performance:

  1. Data augmentation: This can be particularly beneficial for small objects and varying lighting conditions. Consider using augmentations that simulate different lighting (brightness, contrast) and those that manipulate the size and position of objects (scaling, cropping, rotation).
  2. Modify Anchor Boxes: Adjust the anchor boxes in your configuration to better match the size distribution of your small objects. This can help the model better localize these objects.
  3. Increase Model Resolution: Training and inferring at a higher resolution can improve the detection of small objects.

Here's how you can increase the input size for training in your YAML configuration file:

# Example of increasing input resolution
image_size: 640  # Increase this size appropriate to your computational capabilities

And for data augmentation, you might modify your dataset's settings to include random brightness and contrast adjustments:

# Adding data augmentation in data.yaml
augmentations:
  brightness: 0.1  # Adjust brightness by a factor of ±0.1
  contrast: 0.2  # Adjust contrast by a factor of ±0.2

I hope these tips help! Let us know how it goes or if you need further assistance. Happy training! 🚀

and I also want to know where I can modify the Anchor Boxes, thank you!

@IbrahimAlmasri01
Copy link
Author

@IbrahimAlmasri01 hi there! 😊 It sounds like you're working hard on training your model under challenging conditions! Here are a couple of suggestions that might help improve detection performance:

  1. Data augmentation: This can be particularly beneficial for small objects and varying lighting conditions. Consider using augmentations that simulate different lighting (brightness, contrast) and those that manipulate the size and position of objects (scaling, cropping, rotation).
  2. Modify Anchor Boxes: Adjust the anchor boxes in your configuration to better match the size distribution of your small objects. This can help the model better localize these objects.
  3. Increase Model Resolution: Training and inferring at a higher resolution can improve the detection of small objects.

Here's how you can increase the input size for training in your YAML configuration file:

# Example of increasing input resolution
image_size: 640  # Increase this size appropriate to your computational capabilities

And for data augmentation, you might modify your dataset's settings to include random brightness and contrast adjustments:

# Adding data augmentation in data.yaml
augmentations:
  brightness: 0.1  # Adjust brightness by a factor of ±0.1
  contrast: 0.2  # Adjust contrast by a factor of ±0.2

I hope these tips help! Let us know how it goes or if you need further assistance. Happy training! 🚀

Hello, thanks for your help!

I want to confirm a thing I have read on the documentation which is that Yolo is made for speed and small pictures. Thus, large images might have low performance.

My image is 2016 wide and 580 in height.
Is that considered large for yolov8 ?

Also, I have read that there is a parameter called reg_max, but its not available in YAML or the cfg ehich is related to anchor boxes.

@glenn-jocher
Copy link
Member

Hello @IbrahimAlmasri01,

Yes, YOLO is indeed optimized for speed and generally performs well with standard resolution inputs, such as 640x640 pixels. Your image size of 2016x580 is significantly larger and may affect the detection performance if not handled correctly. Consider resizing your images to a smaller fixed size or using techniques like sliding windows if resizing changes the aspect ratio critically.

Regarding the reg_max parameter, it’s not typically modified directly through the YAML or configuration files in standard YOLOv8 setups. Instead, adjusting anchor boxes can be done by recalculating them based on your specific dataset's object sizes and shapes, which can be executed through a custom training routine or by using tools provided in YOLOv8's utilities to analyze your dataset and suggest optimized anchor sizes.

Here is an example of how you might alter anchor sizes in your configuration YAML:

# Adjusting anchors for your data
anchors:
  - [10,13, 16,30, 33,23]  # smaller objects
  - [30,61, 62,45, 59,119] # medium objects
  - [116,90, 156,198, 373,326]  # larger objects

Adjust these based on your dataset specifics. Let me know if you need further assistance with this!

@zacario-li
Copy link

@glenn-jocher hi
Can I set 'random_crop_size' in yaml? How to verify if this take effect?

@glenn-jocher
Copy link
Member

Hello! 😊

Currently, random_crop_size isn't a directly configurable parameter in the YAML file for YOLOv8. For data augmentation involving cropping, you can adjust parameters like mosaic and mixup which indirectly influence how the model sees various crops of your data.

To verify the effects of any data augmentation, you can visually inspect your training batches. Here's a quick example of how you might do this using Python:

from ultralytics import YOLO, load_dataset

# Load your model and dataset
model = YOLO('yolov8n.pt')
dataset = load_dataset('path/to/your/data.yaml')

# Get a batch of images
imgs, labels, paths, shapes = dataset[0]  # Adjust index for different batches

# Visualize
for img in imgs:
    model.show(img)

This will display the augmented images, allowing you to see the effects of your current augmentation settings. If you have further questions or need more specific guidance, feel free to ask!

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

4 participants