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

add support for custom augmentations #10312

Conversation

vaskers5
Copy link

@vaskers5 vaskers5 commented Nov 27, 2022

I add faced the same issue and support for custom torchvision.Transforms like augmentations

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhanced YOLOv5 image augmentation with torchvision transformations during inference.

📊 Key Changes

  • Introduced torchvision.transforms as T to allow advanced image transformations.
  • Modified the forward function signature to accept a transform composition (augment: T.Compose) instead of a boolean flag.
  • Updated _forward_augment to apply the augment transformations to images before running inference.

🎯 Purpose & Impact

  • Purpose: To enable more sophisticated and customizable image transformations during model inference, improving the versatility and accuracy of the model under various conditions.
  • Impact: Users can now pass custom torchvision transform pipelines to the model during inference, potentially improving results and allowing for experiments with different augmentations. This change could lead to better performance in real-world applications by simulating various scenarios that the model may encounter.

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 @vaskers5, 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

@vaskers5
Copy link
Author

vaskers5 commented Nov 27, 2022

now in can works like this:

`import torchvision.transforms as T

augment=T.Compose([
# T.ToTensor(),
# T.Normalize([0.5], [0.5]),
T.functional.rgb_to_grayscale,
lambda item: item.repeat(1, 3, 1, 1),
# T.ToPILImage()
])

model(img_path,
augment=augment
).show()`

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions YOLOv5 🚀 and Vision AI ⭐.

@github-actions github-actions bot added the Stale label Mar 22, 2023
@github-actions github-actions bot removed the Stale label Apr 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2023

👋 Hello there! We wanted to let you know that we've decided to close this pull request due to inactivity. We appreciate the effort you put into contributing to our project, but unfortunately, not all contributions are suitable or aligned with our product roadmap.

We hope you understand our decision, and please don't let it discourage you from contributing to open source projects in the future. We value all of our community members and their contributions, and we encourage you to keep exploring new projects and ways to get involved.

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

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

@github-actions github-actions bot added the Stale label Oct 3, 2023
@github-actions github-actions bot closed this Nov 3, 2023
@glenn-jocher
Copy link
Member

@vaskers5 glad to know it's been working for you! YOLOv5 now supports custom augmentations with torchvision.transforms like this. If you have any other questions or need further assistance, feel free to ask!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants