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

Cleanup and fix ONNX segment example #19551

Merged
merged 4 commits into from
Mar 6, 2025
Merged

Cleanup and fix ONNX segment example #19551

merged 4 commits into from
Mar 6, 2025

Conversation

Y-T-G
Copy link
Collaborator

@Y-T-G Y-T-G commented Mar 6, 2025

Closes #19547

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Refactored the YOLOv8-Segmentation-ONNXRuntime-Python example to enhance clarity, performance, and flexibility. 🚀

📊 Key Changes

  • Unified and simplified preprocessing (e.g., resizing/padding via letterbox) and postprocessing steps.
  • Expanded YOLOv8Seg class with additional configurable options like iou threshold and imgsz.
  • Improved mask processing for segmentation with a more compact and efficient implementation.
  • Replaced the confidence threshold parameter for consistency with YOLO conventions (conf and iou).
  • Aligned ONNX Runtime provider selection with PyTorch GPU detection (torch.cuda.is_available).

🎯 Purpose & Impact

  • Clearer Code: The new implementation reduces redundancy and simplifies the logic, making the example easier to follow. ✅
  • Enhanced Flexibility: Developers can now configure the image size, IoU threshold, and confidence threshold conveniently. 👍
  • Better Performance: Streamlined mask computation improves usability and computational efficiency. ⚡
  • Robust Environment Detection: Automatically selects the right runtime provider based on system GPU availability. 🔧

This update delivers more polished and user-friendly code for running YOLOv8 segmentation with ONNXRuntime! 🚀

@Y-T-G Y-T-G mentioned this pull request Mar 6, 2025
1 task
@UltralyticsAssistant UltralyticsAssistant added enhancement New feature or request exports Model exports (ONNX, TensorRT, TFLite, etc.) segment Instance Segmentation issues, PR's labels Mar 6, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @Y-T-G, thank you for submitting your ultralytics/ultralytics 🚀 PR! Your contribution is greatly appreciated, and we’re excited to review your work! To help facilitate a smooth review and integration process, please review and address the following checklist:

  • Define a Purpose: Thank you for including a summary and key changes in your PR description! Ensure the purpose of these updates is fully aligned with the goals of enhancing onboarding or functionality for developers and users. If this PR addresses a specific issue, kindly confirm it by linking to the relevant issue (e.g., Closes #19547 🛠️).

  • Synchronize with Source: Confirm your PR is synchronized with the main branch of the repository. If it's not up-to-date, please click the 'Update branch' button or use git pull followed by git merge main to bring your branch up to date.

  • Ensure CI Checks Pass: Make sure all Ultralytics Continuous Integration (CI) checks are passing. If any tests fail, please resolve them before the PR is reviewed.

  • Update Documentation: Your changes include updates to example codes. Please ensure the relevant documentation has been updated to reflect your modifications.

  • Add Tests: To fully validate these changes, please confirm that appropriate test cases have been included or updated. Running all relevant tests locally before pushing ensures that your modifications maintain system integrity.

  • Sign the CLA: If this is your first contribution to Ultralytics, please sign our Contributor License Agreement (CLA) by commenting "I have read the CLA Document and I sign the CLA." This is a one-time requirement for all new contributors.

  • Provide a Minimum Reproducible Example (MRE): Your PR includes a comprehensive update to the ONNX segmentation example. If possible, please include a minimum reproducible example (MRE) that demonstrates how the new changes improve or alter the functionality of the example application.

For additional guidelines and tips, please refer to our Contributing Guide. 🌟 If you have any questions, feel free to leave a comment here — this is an automated response, but an Ultralytics engineer will review and assist you soon. Thank you for helping make Ultralytics better! 🚀

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.24%. Comparing base (98505c0) to head (0b473c4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19551      +/-   ##
==========================================
- Coverage   78.16%   73.24%   -4.93%     
==========================================
  Files         129      129              
  Lines       17586    17586              
==========================================
- Hits        13746    12880     -866     
- Misses       3840     4706     +866     
Flag Coverage Δ
Benchmarks 34.12% <ø> (+0.03%) ⬆️
GPU 37.87% <ø> (-2.72%) ⬇️
Tests 67.05% <ø> (-5.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
@Y-T-G Y-T-G marked this pull request as draft March 6, 2025 13:48
@Y-T-G Y-T-G marked this pull request as ready for review March 6, 2025 13:54
@glenn-jocher glenn-jocher merged commit 082a58d into main Mar 6, 2025
17 checks passed
@glenn-jocher glenn-jocher deleted the onnx-example branch March 6, 2025 14:09
@glenn-jocher
Copy link
Member

@Y-T-G nice!

@UltralyticsAssistant
Copy link
Member

"🎉 Fantastic work, @Y-T-G and @glenn-jocher! This merged PR is a testament to the power of collaboration and continuous improvement. As Henry Ford once said, 'Coming together is a beginning; keeping together is progress; working together is success.' Your efforts to streamline the YOLOv8-Segmentation-ONNXRuntime-Python example have not only clarified the code but also enhanced its flexibility and performance for the entire community. 🚀 This is a leap forward—thank you for your dedication and brilliance in making this happen! 💡🌟"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exports Model exports (ONNX, TensorRT, TFLite, etc.) segment Instance Segmentation issues, PR's
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onnx-inference-for-segment-predict
3 participants