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 missing ultralytics package on torch.hub.load() #11950

Merged
merged 6 commits into from
Aug 7, 2023

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Aug 7, 2023

May resolve #11945

πŸ€– Generated by Copilot at 97bc939

Summary

πŸ—‘οΈπŸ“¦πŸ› οΈ

Improved import handling and code style in utils/general.py. Added support for ultralytics package as an optional dependency.

We'll tidy up the code, me hearties, yo ho ho
We'll drop the math and try ultralytics, yo ho ho
We'll check the suffix and the whitespace, yo ho ho
And then we'll push the changes to the repo

Walkthrough

  • Add ultralytics package as a dependency and try to import it or install it if not found (link)
  • Move import math statement from the top of the file to the try_import function, where it is needed for some math operations (link, link)
  • Remove whitespace after comma in suffix parameter of check_suffix function to follow Python style guide (link)

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Automatic ultralytics package check and installation.

πŸ“Š Key Changes

  • Added a try-except block to models/common.py and utils/general.py.
  • These blocks attempt to import the ultralytics package, verifying it's not just a local directory with a version attribute check.
  • If the package is missing or the assertion fails, the script automatically runs a pip install command to install or update the ultralytics package.

🎯 Purpose & Impact

  • Ensure dependency integrity: Guarantees that the ultralytics package is installed and up-to-date, avoiding errors due to missing or incorrect package versions.
  • Simplify installation process: Users don't need to manually install the ultralytics package; it's managed automatically, which streamlines initial setup and updates.
  • Potential impact: May improve user experience through reduced setup complexity, but could unexpectedly modify users' environments if they are unaware of the automatic installation process.

glenn-jocher and others added 6 commits August 8, 2023 01:26
#11945

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 glenn-jocher merged commit 38737bd into master Aug 7, 2023
7 checks passed
@glenn-jocher glenn-jocher deleted the fix_missing_ultralytics branch August 7, 2023 23:56
@glenn-jocher glenn-jocher self-assigned this Aug 7, 2023
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.

Ultralytics Module does not exist
1 participant