错误描述
Downloading https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt to weights/yolov5s.pt...
ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)>
Re-attempting https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt to weights/yolov5s.pt...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (77) error setting certificate verify locations:
CAfile: /Users/gclm/anaconda3
CApath: none
ERROR: Downloaded file 'weights/yolov5s.pt' does not exist or size is < min_bytes=100000.0
weights/yolov5s.pt missing, try downloading from https://github.com/ultralytics/yolov5/releases/
Traceback (most recent call last):
File "detect.py", line 240, in <module>
main(opt)
File "detect.py", line 235, in main
run(**vars(opt))
File "/Users/gclm/anaconda3/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
return func(*args, **kwargs)
File "detect.py", line 73, in run
model = attempt_load(weights, map_location=device) # load FP32 model
File "/Users/gclm/Projects/07-inskylab/yolov5/models/experimental.py", line 119, in attempt_load
ckpt = torch.load(attempt_download(w), map_location=map_location) # load
File "/Users/gclm/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 594, in load
with _open_file_like(f, 'rb') as opened_file:
File "/Users/gclm/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/Users/gclm/anaconda3/lib/python3.8/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: 'weights/yolov5s.pt'
解决办法
根据错误提示,初步推断是anaconda3的问题,优先排查curl 路径是否有问题。
1. 查看curl 路径
~$ which curl
/Users/gclm/anaconda3/bin/curl
2.删除anaconda3 curl 映射
~$ rm -rf /Users/gclm/anaconda3/bin/curl
# 重新查看curl映射
~$ which curl
/usr/bin/curl