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 detection box offset bug in YOLOv8 example model inference results #19639

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

matriox1003
Copy link
Contributor

@matriox1003 matriox1003 commented Mar 11, 2025

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved YOLOv8 C++ inference pipeline by adding support for maintaining correct aspect ratios during pre-processing.

📊 Key Changes

  • Updated formatToSquare function to resize images while preserving aspect ratios using padding (pad_x, pad_y) and scaling (scale).
  • Replaced the previous hardcoded scaling factors with dynamic scale, improving coordinate transformation accuracy.
  • Refactored bounding box calculations to account for padding and scaling adjustments.

🎯 Purpose & Impact

  • 🖼️ Enhanced Image Processing: Ensures input images retain proper proportions, reducing distortion in object detection models.
  • 🎯 Improved Detection Accuracy: More accurate bounding box placements by addressing input scaling issues, resulting in better prediction outcomes.
  • 🔧 Generalized for Diverse Models: Makes the inference code adaptable for varying input resolutions and aspect ratios.

This change improves both usability and detection accuracy for developers and users leveraging YOLOv8 in C++ projects. 🚀

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working as intended in the official Ultralytics package. detect Object Detection issues, PR's labels Mar 11, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @matriox1003, thank you for submitting an ultralytics/ultralytics 🚀 PR! To ensure a seamless integration of your contribution, please review the following checklist:

  • Define a Purpose: Ensure your PR description clearly explains the purpose of your fix. You did a great job summarizing the changes and their impact—awesome work! 👍 If you haven't already, you can also link to any relevant issues for better traceability.
  • Synchronize with Source: Confirm that your PR is synchronized with the latest ultralytics/ultralytics main branch. If your branch is behind, update it by clicking the 'Update branch' button or syncing via git pull and git merge main locally.
  • Ensure CI Checks Pass: Our automated Continuous Integration (CI) checks are currently pending/ongoing. Please ensure all tests pass for a smoother review process. 🛠️
  • Update Documentation: If applicable, ensure that relevant documentation is updated to reflect these changes.
  • Add Tests: Please confirm that you have included or updated test cases relevant to your changes, and ensure all tests are passing locally.
  • Sign the CLA: Thank you for contributing! If this is your first PR to Ultralytics, please confirm you’ve signed our Contributor License Agreement (CLA) by leaving a comment here with: I have read the CLA Document and I sign the CLA.
  • Minimize Changes: Review your diff to ensure modifications are focused and limited to solving the intended problem. We strive for efficient and precise updates. "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." — Antoine de Saint-Exupéry

🛠️ For this PR:
The enhancements to the YOLOv8 C++ inference pipeline look fantastic! The changes to account for padding and scaling during inference will undoubtedly improve detection accuracy and consistency. The detailed bounding box adjustments and preprocessing approach, preserving aspect ratios, are thoughtful touches that should elevate overall model performance. 🚀

If there is a live example or Minimum Reproducible Example (MRE) to showcase the impact of these updates, please consider sharing it so our team can validate the improvements more robustly!

For more guidance, check out our Contributing Guide. Feel free to ask questions here if you need help or clarification. 💬 An Ultralytics engineer will review your PR and provide feedback soon—thank you for contributing to Ultralytics! 🎉

@matriox1003
Copy link
Contributor Author

@glenn-jocher glenn-jocher changed the title fix 修复模型推理结果检测框偏移BUG Fix detection box offset bug in YOLOv8 example model inference results Mar 11, 2025
@glenn-jocher glenn-jocher merged commit 1503aab into ultralytics:main Mar 11, 2025
37 checks passed
@UltralyticsAssistant
Copy link
Member

🎉 Your PR has been merged, @matriox1003!

Thank you for your incredible contribution to improving the YOLOv8 C++ inference pipeline. By adding dynamic aspect-ratio support, you've not only enhanced detection accuracy but also set the stage for more versatile and user-friendly applications. 🚀

As Marcus Aurelius once said, "What we do now echoes in eternity." Your innovative work today will resonate in the projects and solutions of tomorrow, empowering developers and creating impact far beyond the codebase.

Keep inspiring with your brilliance—your efforts truly make a difference! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as intended in the official Ultralytics package. detect Object Detection issues, PR's
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants