RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory问题解决

环境:Windows10,yolov5-5.0,Anaconda3的python3.8虚拟环境

以下是具体报错

(yolov5_p3.8) C:\ProgramData\yolov5_distillation-5.0>python detect.py
Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='',
exist_ok=False, img_size=640, iou_thres=0.45, name='exp', nosave=False, project='runs/detect', 
save_conf=False, save_txt=False, source='data/images', update=False, view_img=False, 
weights='yolov5s.pt')
YOLOv5  2021-4-12 torch 1.11.0+cpu CPU

Traceback (most recent call last):
  File "detect.py", line 178, in <module>
    detect()
  File "detect.py", line 34, in detect
    model = attempt_load(weights, map_location=device)  # load FP32 model
  File "C:\ProgramData\yolov5_distillation-5.0\models\experimental.py", line 118, in attempt_load
    ckpt = torch.load(w, map_location=map_location)  # load
  File "C:\ProgramData\Anaconda3\envs\yolov5_p3.8\lib\site-packages\torch\serialization.py", line 705, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "C:\ProgramData\Anaconda3\envs\yolov5_p3.8\lib\site-packages\torch\serialization.py", line 243, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

也算是个纯小白,基本上啥也不懂,问了大佬说是Namespace后面括号里的weights默认值需要改一下。但是代码还没去研究,所以可以先自己设置参数。

python detect.py --weights weights/yolov5s.pt

成功!
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory问题解决_第1张图片

你可能感兴趣的:(pytorch,人工智能,python)