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

ultralytics 8.1.43 40% faster ultralytics imports #9547

Merged
merged 25 commits into from Apr 5, 2024
Merged

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Apr 4, 2024

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

This PR introduces various updates across testing, data handling, and utility modules in the Ultralytics repository.

πŸ“Š Key Changes

  • Testing Enhancements: Simplified the tensor inference in tests by replacing complex OpenCV and torchvision transformations with direct PyTorch tensor creation.
  • Module Refactor: Moved the ClassificationDataset class definition for clarity and improved import efficiency.
  • Version Bump: Updated the package version to 8.1.43.
  • Dependency Management: Reduced direct imports from torchvision and other heavy libraries within function scopes to accelerate startup times.
  • Code Streamlining: Removed unused imports and updated code for better readability and performance. For example, in test and data augmentation functions, less verbose and more efficient data handling approaches are now used.

🎯 Purpose & Impact

  • Enhanced Test Reliability: The updates to testing scripts ensure more straightforward and reliable testing processes.
  • Improved Import Efficiency: By deferring heavy imports, the updates contribute to faster load times for the Ultralytics package, enhancing the user experience, especially in environments where startup time is critical.
  • Future-Proofing: Cleaning up and streamlining the codebase helps maintain the package more efficiently and lays a solid foundation for future enhancements.
  • User and Developer Experience: These changes benefit both users of the Ultralytics package by providing a smoother experience and developers by easing the process of understanding and contributing to the codebase.

In summary, this PR brings forth important updates that streamline operations, enhance performance, and improve the overall user and developer experience of the Ultralytics repository. πŸš€

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 31.81818% with 75 lines in your changes are missing coverage. Please review.

Project coverage is 37.96%. Comparing base (99c61d6) to head (9bf4422).

❗ Current head 9bf4422 differs from pull request most recent head 6b83a36. Consider uploading reports for the commit 6b83a36 to get more accurate results

Files Patch % Lines
ultralytics/data/dataset.py 10.60% 59 Missing ⚠️
ultralytics/data/augment.py 20.00% 4 Missing ⚠️
ultralytics/data/explorer/gui/dash.py 0.00% 2 Missing ⚠️
ultralytics/models/fastsam/prompt.py 0.00% 2 Missing ⚠️
ultralytics/utils/checks.py 50.00% 2 Missing ⚠️
ultralytics/data/explorer/explorer.py 50.00% 1 Missing ⚠️
ultralytics/data/explorer/utils.py 0.00% 1 Missing ⚠️
ultralytics/models/sam/predict.py 50.00% 1 Missing ⚠️
ultralytics/models/yolo/classify/train.py 0.00% 1 Missing ⚠️
ultralytics/utils/benchmarks.py 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9547      +/-   ##
==========================================
- Coverage   37.99%   37.96%   -0.03%     
==========================================
  Files         121      121              
  Lines       15277    15281       +4     
==========================================
- Hits         5804     5802       -2     
- Misses       9473     9479       +6     
Flag Coverage Ξ”
GPU 37.96% <31.81%> (-0.03%) ⬇️

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.

@ddeevvaa
Copy link

ddeevvaa commented Apr 4, 2024

how faster it can be?any test?

@glenn-jocher
Copy link
Member Author

@ddeevvaa I still haven't removed it completely, there's one file left, but seems to improve speed from about 1.4s -> 1.0s import

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher
Copy link
Member Author

glenn-jocher commented Apr 4, 2024

@ddeevvaa final results are here averaged over 30 imports. Speedup of 25.3% acheived, reduced import time from 1411ms by 357ms to 1054ms on my Macbook Air M2.

EDIT: 542 ms removed from import (1411 ms -> 869 ms 38% faster) after also scoping pandas that had accidentally be de-scoped. This is HUGE!!!!

this PR

  • 1.054 s for import ultralytics
  • EDIT: 0.869 s after also scoping pandas that had been inadvertently added as top-level Explorer imports

main branch

  • 1.411s for import ultralytics

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@ddeevvaa
Copy link

ddeevvaa commented Apr 5, 2024

very strong~
a remarkable improvement,it seems mergence will be soon

@glenn-jocher
Copy link
Member Author

@ddeevvaa thank you so much for the encouraging feedback! 🌟 We're thrilled by the performance improvements as well and can't wait for the merge to happen. It's all about making YOLOv8 better and faster for everyone. Keep an eye out for updates soon!

@glenn-jocher glenn-jocher changed the title Scope torchvision for faster ultralytics imports ultralytics 8.1.43 40% faster ultralytics imports Apr 5, 2024
@glenn-jocher glenn-jocher merged commit a262865 into main Apr 5, 2024
10 checks passed
@glenn-jocher glenn-jocher deleted the updates branch April 5, 2024 13:29
hmurari pushed a commit to hmurari/ultralytics that referenced this pull request Apr 17, 2024
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
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