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

Detection with Torch Hub Failing #13519

Closed
1 task done
llavkush opened this issue Feb 25, 2025 · 4 comments
Closed
1 task done

Detection with Torch Hub Failing #13519

llavkush opened this issue Feb 25, 2025 · 4 comments
Labels
dependencies Dependencies and packages detect Object Detection issues, PR's question Further information is requested

Comments

@llavkush
Copy link

Search before asking

Question

I have ML project on Python 3.7.8, it was working fine, but recently I am getting error when loading model with torch.hub.load

File "C:\Users\Strange/.cache\torch\hub\ultralytics_yolov5_master\models\common.py", line 39, in
from utils.dataloaders import exif_transpose, letterbox
File "C:\Users\Strange/.cache\torch\hub\ultralytics_yolov5_master\utils\dataloaders.py", line 776
if mosaic := self.mosaic and random.random() < hyp["mosaic"]:

I know yolov5 require python > 3.8, but all current dependencies in my project is of 3.7.8, please suggest workaround to work with it

Additional

No response

@llavkush llavkush added the question Further information is requested label Feb 25, 2025
@UltralyticsAssistant UltralyticsAssistant added dependencies Dependencies and packages detect Object Detection issues, PR's labels Feb 25, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @llavkush, thank you for your interest in YOLOv5 🚀! It looks like you're encountering an issue while using YOLOv5 with Torch Hub. As you noted, YOLOv5 indeed requires Python >= 3.8 to function properly, and supporting Python 3.7.8 is outside the recommended environment.

If this is a 🐛 Bug Report, please share a minimum reproducible example (MRE) of your code that demonstrates the issue. This will greatly help us to investigate further.

In the meantime, here are some helpful resources and recommendations:

Requirements

YOLOv5 requires Python>=3.8.0 with all requirements.txt dependencies installed:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

If you're unable to upgrade your Python version, consider running YOLOv5 in one of our verified environments where all dependencies are preinstalled:

Environments

YOLOv5 can be run in the following up-to-date verified environments:

Using one of these environments may allow you to bypass the need to modify your local setup.

Tutorials

For additional guidance:

Let us know if upgrading your environment or utilizing a verified environment resolves your issue. If not, please provide the requested MRE for further debugging. This is an automated response – an Ultralytics engineer will take a closer look and assist you further soon. 😊

@pderrenger
Copy link
Member

@llavkush to resolve the Python 3.7 compatibility issue with YOLOv5's walrus operator (:=), we recommend either:

  1. Upgrading to Python ≥3.8 (officially required for YOLOv5), or
  2. Using YOLOv5 v6.2 which maintained Python 3.7 compatibility:
model = torch.hub.load('ultralytics/yolov5:v6.2', 'yolov5s')

For details see the YOLOv5 v6.2 release notes. We strongly recommend updating to Python 3.8+ for continued support with modern versions.

@llavkush
Copy link
Author

@pderrenger thank you for the solution, this works.

@pderrenger
Copy link
Member

@llavkush you're welcome! Glad the solution worked for you. For future reference, our YOLOv5 documentation contains detailed version compatibility notes and migration guides if you decide to upgrade Python versions later. Happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Dependencies and packages detect Object Detection issues, PR's question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants