WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

FileNotFoundError: [Errno 2] No such file or directory: 'y' #67

Open Zomcxj opened 2 years ago

Zomcxj commented 2 years ago

作者你好,我在运行一开始检测时 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)')出现了错误 请问是什么原因?

WongKinYiu commented 2 years ago

https://github.com/WongKinYiu/yolor/blob/main/detect.py#L44

把 [0] 去掉

Zomcxj commented 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 detect() File "detect.py", line 44, in detect model.load_state_dict(torch.load(weights, 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 235, in _open_file_like return _open_buffer_reader(name_or_buffer) File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 220, in init _check_seekable(buffer) File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 311, in _check_seekable raise_err_msg(["seek", "tell"], e) File "D:\JetBrains\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 304, in raise_err_msg raise type(e)(msg) AttributeError: 'list' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO a nd try to load from it instead.

Varat7v2 commented 2 years ago

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'])