我正在尝试使用以下代码在自定义数据集上加载经过训练的yolov5模型:
# Model
model = torch.hub.load('/home/yolov5/runs/train/yolo_sign_det2/weights', 'best') # or yolov5n - yolov5x6, custom
但是我遇到了这个错误:
ValueError Traceback (most recent call last)
<ipython-input-3-c832ab8c1eab> in <module>
2
3 # Model
----> 4 model = torch.hub.load('/home/yolov5/runs/train/yolo_sign_det2/weights', 'best') # or yolov5n - yolov5x6, custom
5
6 # Images
~/.conda/envs/yolo/lib/python3.6/site-packages/torch/hub.py in load(repo_or_dir, model, source, force_reload, verbose, skip_validation, *args,**kwargs)
395
396 if source == 'github':
--> 397 repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose, skip_validation)
398
399 model = _load_local(repo_or_dir, model, *args,**kwargs)
~/.conda/envs/yolo/lib/python3.6/site-packages/torch/hub.py in _get_cache_or_reload(github, force_reload, verbose, skip_validation)
163 os.makedirs(hub_dir)
164 # Parse github repo information
--> 165 repo_owner, repo_name, branch = _parse_repo_info(github)
166 # Github allows branch name with slash '/',
167 # this causes confusion with path on both Linux and Windows.
~/.conda/envs/yolo/lib/python3.6/site-packages/torch/hub.py in _parse_repo_info(github)
110 else:
111 repo_info, branch = github, None
--> 112 repo_owner, repo_name = repo_info.split('/')
113
114 if branch is None:
ValueError: too many values to unpack (expected 2)
谁能告诉我我哪里做错了吗?
1条答案
按热度按时间6rqinv9w1#
在Pytorch documentation website中,
source
选项似乎默认设置为github,因此您的代码行:实际上是指:
因此,您需要按照链接文档中的说明设置
source=local
,保持source='github'
意味着您的程序正在尝试查找一个GitHub仓库(如您的错误消息所示)。修复方法是将
source
设置为local,然后使用以下代码行: