报错 代码片
.
import timm
model = timm.create_model('res2net101_26w_4s', pretrained=True)
print(model)
Traceback (most recent call last):
File “C:\Users\chen.conda\envs\pytorch\lib\site-packages\urllib3\connectionpool.py”, line 711, in urlopen
self._prepare_proxy(conn)
File “C:\Users\chen.conda\envs\pytorch\lib\site-packages\urllib3\connectionpool.py”, line 1007, in _prepare_proxy
conn.connect()
…………
OSError: [Errno 0] Error
During handling of the above exception, another exception occurred:
…………
File “C:\Users\chen.conda\envs\pytorch\lib\site-packages\requests\sessions.py”, line 589, in request
resp = self.send(prep, **send_kwargs)
File “C:\Users\chen.conda\envs\pytorch\lib\site-packages\requests\sessions.py”, line 703, in send
r = adapter.send(request, **kwargs)
File “C:\Users\chen.conda\envs\pytorch\lib\site-packages\huggingface_hub\utils_http.py”, line 63, in send
return super().send(request, *args, **kwargs)
File “C:\Users\chen.conda\envs\pytorch\lib\site-packages\requests\adapters.py”, line 513, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: (MaxRetryError(“HTTPSConnectionPool(host=‘huggingface.co’, port=443): Max retries exceeded with url: /timm/res2net101_26w_4s.in1k/resolve/main/model.safetensors (Caused by ProxyError(‘Cannot connect to proxy.’, OSError(0, ‘Error’)))”), ‘(Request ID: ab50cad4-304e-4831-aa7e-1d5213e952c9)’)
进程已结束,退出代码1
大概就是因为网络请求错误问题啥的
timm他会默认先从huggingfaceHub下载,但是HF现在又被墙了,所以要手动下载
1、先获取cfg信息
import timm
model = timm.create_model('res2net101_26w_4s')
print(model.default_cfg)
2.【科学上网】去https://huggingface.co/上搜索然后再下载模型
3.下载保存到项目路径下
4、添加参数,再次运行成功打印模型
import timm
model = timm.create_model('res2net101_26w_4s', pretrained=True,
pretrained_cfg_overlay=dict(file='checkpoint/res2net101_26w_4s/pytorch_model.bin'))
print(model)