Open Zomcxj opened 2 years ago
https://github.com/WongKinYiu/yolor/blob/main/detect.py#L44
把 [0] 去掉
额 好像还是不行 Traceback (most recent call last): File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 308, in _check_seekable f.seek(f.tell()) AttributeError: 'list' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "detect.py", line 186, in
Remove [0] from line 44: model.load_state_dict(torch.load(weights[0], map_location=device)['model'])
or just replace the line 44 with:
model.load_state_dict(torch.load(weights, map_location=device)['model'])
作者你好,我在运行一开始检测时 python detect.py --source inference/images/horses.jpg --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --conf 0.25 --img-size 1280 --device 0时出现了这种错误 Traceback (most recent call last): File "E:/DeepLearning/Py-YOLOR/YOLOR-cat/detect.py", line 186, in
detect()
File "E:/DeepLearning/Py-YOLOR/YOLOR-cat/detect.py", line 44, in detect
model.load_state_dict(torch.load(weights[0], map_location=device)['model'])
File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 579, in load
with _open_file_like(f, 'rb') as opened_file:
File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'y'
我把各种路径补全就变成了这个错误 代码在E盘
FileNotFoundError: [Errno 2] No such file or directory: 'E'
个人觉得是权重输入路径parser.add_argument('--weights', nargs='+', type=str, default='yolor_p6.pt', help='model.pt path(s)')出现了错误
请问是什么原因?