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

Fix cutout bug #9452

Merged
merged 3 commits into from
Sep 18, 2022
Merged

Fix cutout bug #9452

merged 3 commits into from
Sep 18, 2022

Conversation

Oswells
Copy link
Contributor

@Oswells Oswells commented Sep 17, 2022

Signed-off-by: Junjie Zhang 46258221+Oswells@users.noreply.github.com

When I use cutout, I find that even if the object is completely covered, its gt_label is still retained on the image.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Refinement of cutout augmentation in data preprocessing to enhance object detection.

📊 Key Changes

  • Imported xywhn2xyxy function within augmentations.py.
  • Improved the cutout function by ensuring it considers the IOA (Intersection over Area) of bounding boxes in the image coordinate space.

🎯 Purpose & Impact

  • The purpose of these changes is to increase the accuracy of the cutout data augmentation technique used during training.
  • By converting labels to the correct coordinate format before calculating IOA, it ensures that the object detection model is trained on better quality data, potentially leading to improved model performance.
  • Users can expect their models to handle partial occlusions in a more robust way, which can be particularly beneficial for real-world applications where objects are often partially obscured.

Oswells and others added 2 commits September 17, 2022 17:23
Signed-off-by: Junjie Zhang <46258221+Oswells@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hello @Oswells, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

@glenn-jocher
Copy link
Member

@Oswells thanks for the PR! It looks like you are saying that the current box inputs are in the wrong format. Are you sure this is the case?

@glenn-jocher glenn-jocher changed the title fix cutout bug Fix cutout bug Sep 17, 2022
@Oswells
Copy link
Contributor Author

Oswells commented Sep 18, 2022

Yes, I think the current box inputs are in the wrong format.
I use this code to check and it works well on yolov5:v6.1, but it may not be compatible with yolov5: v6.2. When I test it on yolov5:v6.2, I use v6.1's plot_images. I find that the latest version still exist this problem.

from utils.datasets import create_dataloader
from utils.general import colorstr,init_seeds
from utils.plots import plot_images
import yaml 

init_seeds(429)
hyp='data/hyps/hyp.scratch-low.yaml'
with open(hyp, errors='ignore') as f:
            hyp = yaml.safe_load(f)
dataloader, dataset = create_dataloader(  "test.txt",
                                            480,
                                            22 // 2,
                                            32,
                                            False,
                                            hyp=hyp,
                                            augment=True,
                                            cache="ram",
                                            rect=False,
                                            rank=-1,
                                            workers=4,
                                            image_weights=False,
                                            quad=False,
                                            prefix=colorstr('train: '),
                                            shuffle=False)
for imgs, targets, paths, _ in dataloader:
    plot_images(imgs,targets)

before:
QQ图片20220918112735

fixed:
QQ图片20220918112735

@glenn-jocher
Copy link
Member

@Oswells I reviewed. You are absolutely right, the labels are in xywhn so the IoA computation is flawed.

Your fix looks good!

@glenn-jocher glenn-jocher merged commit 8ae81a6 into ultralytics:master Sep 18, 2022
@glenn-jocher
Copy link
Member

@Oswells PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

@Oswells Oswells deleted the Oswells-patch-1 branch September 19, 2022 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants