-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
I got an hubconf.py error while loading my best.pt saved model #11481
Comments
👋 Hello @amir-sbg, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it. If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results. RequirementsPython>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit. Introducing YOLOv8 🚀We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀! Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects. Check out our YOLOv8 Docs for details and get started with: pip install ultralytics |
@amir-sbg hello! It seems that there was an issue with loading the YOLOv5 model in your environment. The error trace suggests that there was a If the issue persists, please let us know and we'd be happy to assist you further. Thanks for using YOLOv5! |
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help. For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLO 🚀 and Vision AI ⭐ |
Search before asking
YOLOv5 Component
Detection, Other
Bug
YOLOv5 🚀 2023-5-2 Python-3.10.11 torch-2.0.0+cu118 CPU
KeyError Traceback (most recent call last)
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/hubconf.py in _create(name, pretrained, channels, classes, autoshape, verbose, device)
48 try:
---> 49 model = DetectMultiBackend(path, device=device, fuse=autoshape) # detection model
50 if autoshape:
8 frames
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/models/common.py in init(self, weights, device, dnn, data, fp16, fuse)
343 if pt: # PyTorch
--> 344 model = attempt_load(weights if isinstance(weights, list) else w, device=device, inplace=True, fuse=fuse)
345 stride = max(int(model.stride.max()), 32) # model stride
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/models/experimental.py in attempt_load(weights, device, inplace, fuse)
79 ckpt = torch.load(attempt_download(w), map_location='cpu') # load
---> 80 ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
81
KeyError: 'model'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/hubconf.py in _create(name, pretrained, channels, classes, autoshape, verbose, device)
59 except Exception:
---> 60 model = attempt_load(path, device=device, fuse=False) # arbitrary model
61 else:
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/models/experimental.py in attempt_load(weights, device, inplace, fuse)
79 ckpt = torch.load(attempt_download(w), map_location='cpu') # load
---> 80 ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
81
KeyError: 'model'
The above exception was the direct cause of the following exception:
Exception Traceback (most recent call last)
in <cell line: 2>()
1 import torch
----> 2 model = torch.hub.load('./yolov5', 'custom',force_reload=True, path='./best1.pt', source='local')
3 # model = torch.hub.load("ultralytics/yolov5", "custom", weights_path, force_reload=True)
4 # Image
5 img = './road.jpg'
/usr/local/lib/python3.10/dist-packages/torch/hub.py in load(repo_or_dir, model, source, trust_repo, force_reload, verbose, skip_validation, *args, **kwargs)
556 verbose=verbose, skip_validation=skip_validation)
557
--> 558 model = _load_local(repo_or_dir, model, *args, **kwargs)
559 return model
560
/usr/local/lib/python3.10/dist-packages/torch/hub.py in _load_local(hubconf_dir, model, *args, **kwargs)
585
586 entry = _load_entry_from_hubconf(hub_module, model)
--> 587 model = entry(*args, **kwargs)
588
589 return model
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/hubconf.py in custom(path, autoshape, _verbose, device)
81 def custom(path='path/to/model.pt', autoshape=True, _verbose=True, device=None):
82 # YOLOv5 custom or local model
---> 83 return _create(path, autoshape=autoshape, verbose=_verbose, device=device)
84
85
/content/drive/MyDrive/Colab Notebooks/YOLO/./yolov5/hubconf.py in _create(name, pretrained, channels, classes, autoshape, verbose, device)
76 help_url = 'https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading'
77 s = f'{e}. Cache may be out of date, try
force_reload=True
or see {help_url} for help.'---> 78 raise Exception(s) from e
79
80
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
-YOLOv5 🚀 2023-5-2 Python-3.10.11 torch-2.0.0+cu118 CPU
-Google Colab
-Python 3.10
Minimal Reproducible Example
import torch
model = torch.hub.load('./yolov5', 'custom',force_reload=True, path='./best.pt', source='local')
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: