yolov5 icon indicating copy to clipboard operation
yolov5 copied to clipboard

Error running in windows 11 with python 3.12 virtual env

Open balakreshnan opened this issue 1 year ago • 5 comments
trafficstars

Search before asking

  • [X] I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

File "c:\Code\gradioapps\mfgappsv1.venv\Lib\site-packages\torch\hub.py", line 599, in _load_local model = entry(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 215, in yolov5s return _create("yolov5s", pretrained, channels, classes, autoshape, _verbose, device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 103, in _create raise Exception(s) from e Exception: 'model'. Cache may be out of date, try force_reload=True or see https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading for help.

Environment

python 3.12 latest on all libraries

Minimal Reproducible Example

import torch

Model

model = torch.hub.load("ultralytics/yolov5", "yolov5s", channels=3, force_reload=True)

Image

im = "https://ultralytics.com/images/zidane.jpg"

Inference

results = model(im)

results.pandas().xyxy[0]

xmin ymin xmax ymax confidence class name

0 749.50 43.50 1148.0 704.5 0.874023 0 person

1 433.50 433.50 517.5 714.5 0.687988 27 tie

2 114.75 195.75 1095.0 708.0 0.624512 0 person

3 986.00 304.00 1028.0 420.0 0.286865 27 tie

Additional

PS C:\Code\gradioapps\mfgappsv1> python .\yolotest.py Downloading: "https://github.com/ultralytics/yolov5/zipball/master" to C:\Users\babal/.cache\torch\hub\master.zip YOLOv5 2024-9-27 Python-3.12.6 torch-2.4.1+cpu CPU

Traceback (most recent call last): File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 70, in _create model = DetectMultiBackend(path, device=device, fuse=autoshape) # detection model ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\models\common.py", line 489, in init model = attempt_load(weights if isinstance(weights, list) else w, device=device, inplace=True, fuse=fuse) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\models\experimental.py", line 99, in attempt_load ckpt = (ckpt.get("ema") or ckpt["model"]).to(device).float() # FP32 model ~~~~^^^^^^^^^ KeyError: 'model'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 85, in _create model = attempt_load(path, device=device, fuse=False) # arbitrary model ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\models\experimental.py", line 99, in attempt_load ckpt = (ckpt.get("ema") or ckpt["model"]).to(device).float() # FP32 model ~~~~^^^^^^^^^ KeyError: 'model'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Code\gradioapps\mfgappsv1\yolotest.py", line 4, in model = torch.hub.load("ultralytics/yolov5", "yolov5s", channels=3, force_reload=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Code\gradioapps\mfgappsv1.venv\Lib\site-packages\torch\hub.py", line 570, in load model = _load_local(repo_or_dir, model, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Code\gradioapps\mfgappsv1.venv\Lib\site-packages\torch\hub.py", line 599, in _load_local model = entry(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 215, in yolov5s return _create("yolov5s", pretrained, channels, classes, autoshape, _verbose, device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\babal/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 103, in _create raise Exception(s) from e Exception: 'model'. Cache may be out of date, try force_reload=True or see https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading for help.

Are you willing to submit a PR?

  • [ ] Yes I'd like to help by submitting a PR!

balakreshnan avatar Sep 27 '24 13:09 balakreshnan

👋 Hello @balakreshnan, thank you for reporting this issue with YOLOv5 on Windows 11 using Python 3.12 🐍!

This is an automated response to help guide you through potential solutions. An Ultralytics engineer will also review your issue soon.

It seems like you're encountering an error related to loading the model. Please ensure that the cache is cleared and try using force_reload=True in your code, as suggested in the error message. Also, verify that you're using compatible versions of Python and PyTorch, as specified below:

Requirements

Ensure you have Python>=3.8.0 and all requirements.txt are installed, including PyTorch>=1.8. To get started, run:

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

Environments

YOLOv5 can run in these environments with dependencies pre-installed:

Status

YOLOv5 CI

Our Continuous Integration (CI) tests verify the functionality of YOLOv5 training, validation, inference, export, and benchmarks.

If your issue persists, please provide any additional information or updates here. Feel free to explore our ⭐️ Tutorials for more guidance.

Introducing YOLOv8 🚀

Check out our latest model, YOLOv8, for enhanced performance in object detection, image segmentation, and classification tasks. Explore YOLOv8 Docs to get started:

pip install ultralytics

Thank you for your patience, and we look forward to helping you resolve this issue! 😊

UltralyticsAssistant avatar Sep 27 '24 13:09 UltralyticsAssistant

i do have it.


From: Ultralytics Assistant @.> Sent: Friday, September 27, 2024 8:49 AM To: ultralytics/yolov5 @.> Cc: Mention @.>; Author @.> Subject: Re: [ultralytics/yolov5] Error running in windows 11 with python 3.12 virtual env (Issue #13335)

👋 Hello @balakreshnanhttps://github.com/balakreshnan, thank you for reporting this issue with YOLOv5 on Windows 11 using Python 3.12 🐍!

This is an automated response to help guide you through potential solutions. An Ultralytics engineer will also review your issue soon.

It seems like you're encountering an error related to loading the model. Please ensure that the cache is cleared and try using force_reload=True in your code, as suggested in the error message. Also, verify that you're using compatible versions of Python and PyTorch, as specified below:

Requirements

Ensure you have Python>=3.8.0https://www.python.org/ and all requirements.txthttps://github.com/ultralytics/yolov5/blob/master/requirements.txt are installed, including PyTorch>=1.8https://pytorch.org/get-started/locally/. To get started, run:

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

Environments

YOLOv5 can run in these environments with dependencies pre-installed:

Status

[YOLOv5 CI]https://github.com/ultralytics/yolov5/actions/workflows/ci-testing.yml

Our Continuous Integration (CI) tests verify the functionality of YOLOv5 traininghttps://github.com/ultralytics/yolov5/blob/master/train.py, validationhttps://github.com/ultralytics/yolov5/blob/master/val.py, inferencehttps://github.com/ultralytics/yolov5/blob/master/detect.py, exporthttps://github.com/ultralytics/yolov5/blob/master/export.py, and benchmarkshttps://github.com/ultralytics/yolov5/blob/master/benchmarks.py.

If your issue persists, please provide any additional information or updates here. Feel free to explore our ⭐️ Tutorialshttps://docs.ultralytics.com/yolov5/ for more guidance.

Introducing YOLOv8 🚀

Check out our latest model, YOLOv8https://github.com/ultralytics/ultralytics, for enhanced performance in object detection, image segmentation, and classification tasks. Explore YOLOv8 Docshttps://docs.ultralytics.com/ to get started:

pip install ultralytics

Thank you for your patience, and we look forward to helping you resolve this issue! 😊

— Reply to this email directly, view it on GitHubhttps://github.com/ultralytics/yolov5/issues/13335#issuecomment-2379333015 or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF7FZBWGDNDPET5GC3XTFWTZYVPAPBFKMF2HI4TJMJ2XIZLTSWBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIZDANRYG42TQNRZGGSG4YLNMWUWQYLTL5WGCYTFNSBKK5TBNR2WLKRTGU2TEMBQGIZTGOFENZQW2ZNJNBQXGX3MMFRGK3FMON2WE2TFMN2F65DZOBS2YSLTON2WKQ3PNVWWK3TUUZ2G64DJMNZZJAVEOR4XAZNKOJSXA33TNF2G64TZUV3GC3DVMWUTENRUHAYTQNRYG2BKI5DZOBS2K2LTON2WLJLWMFWHKZNKGI2TKMRZHE4DSOJXQKSHI6LQMWSWYYLCMVWKK5TBNR2WLKRSGA3DQNZVHA3DSMMCUR2HS4DFUVWGCYTFNSSXMYLMOVS2UMZVGUZDAMBSGMZTRJ3UOJUWOZ3FOKTGG4TFMF2GK. You are receiving this email because you were mentioned.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

balakreshnan avatar Sep 27 '24 14:09 balakreshnan

@balakreshnan if you've already tried clearing the cache and using force_reload=True, please ensure all dependencies are up to date. If the issue persists, consider testing with a different Python version, as Python 3.12 might have compatibility issues. Let us know if you need further assistance!

glenn-jocher avatar Sep 27 '24 19:09 glenn-jocher

yolov8 worked so pls close v5 doesn't work.


From: Glenn Jocher @.> Sent: Friday, September 27, 2024 2:01 PM To: ultralytics/yolov5 @.> Cc: Mention @.>; Author @.>; Comment @.***> Subject: Re: [ultralytics/yolov5] Error running in windows 11 with python 3.12 virtual env (Issue #13335)

@balakreshnanhttps://github.com/balakreshnan if you've already tried clearing the cache and using force_reload=True, please ensure all dependencies are up to date. If the issue persists, consider testing with a different Python version, as Python 3.12 might have compatibility issues. Let us know if you need further assistance!

— Reply to this email directly, view it on GitHubhttps://github.com/ultralytics/yolov5/issues/13335#issuecomment-2379885737 or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF7FZBTKNGRCROTSKAHJ44DZYWTRBBFKMF2HI4TJMJ2XIZLTSWBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIZDANRYG42TQNRZGGSG4YLNMWUWQYLTL5WGCYTFNSBKK5TBNR2WLKRTGU2TEMBQGIZTGOFENZQW2ZNJNBQXGX3MMFRGK3FMON2WE2TFMN2F65DZOBS2YSLTON2WKQ3PNVWWK3TUUZ2G64DJMNZZJAVEOR4XAZNKOJSXA33TNF2G64TZUV3GC3DVMWUTENRUHAYTQNRYG2BKI5DZOBS2K2LTON2WLJLWMFWHKZNKGI2TKMRZHE4DSOJXQKSHI6LQMWSWYYLCMVWKK5TBNR2WLKRSGA3DQNZVHA3DSMMCUR2HS4DFUVWGCYTFNSSXMYLMOVS2UMZVGUZDAMBSGMZTRJ3UOJUWOZ3FOKTGG4TFMF2GK. You are receiving this email because you were mentioned.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

balakreshnan avatar Sep 27 '24 20:09 balakreshnan

Thank you for the update. If YOLOv8 works for you, feel free to continue using it. We'll close this issue. If you have further questions, let us know.

glenn-jocher avatar Sep 28 '24 01:09 glenn-jocher