torch.hub.load报错urllib.error.HTTPError: HTTP Error 403: rate limit exceeded

在运行DINOv2的示例代码时,需要载入预训练的模型,比如:

python 复制代码
backbone_model = torch.hub.load(repo_or_dir="facebookresearch/dinov2", model=backbone_name)

torch.hub.load报错"urllib.error.HTTPError: HTTP Error 403: rate limit exceeded",具体报错信息如下:

Traceback (most recent call last):

File "/data1/domainnet/dinov2/demo.py", line 15, in <module>

backbone_model = torch.hub.load(repo_or_dir="facebookresearch/dinov2", model=backbone_name)

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/site-packages/torch/hub.py", line 555, in load

repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, trust_repo, "load",

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/site-packages/torch/hub.py", line 222, in _get_cache_or_reload

_validate_not_a_forked_repo(repo_owner, repo_name, ref)

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/site-packages/torch/hub.py", line 181, in _validate_not_a_forked_repo

response = json.loads(_read_url(Request(url, headers=headers)))

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/site-packages/torch/hub.py", line 164, in _read_url

with urlopen(url) as r:

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/urllib/request.py", line 214, in urlopen

return opener.open(url, data, timeout)

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/urllib/request.py", line 523, in open

response = meth(req, response)

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/urllib/request.py", line 632, in http_response

response = self.parent.error(

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/urllib/request.py", line 561, in error

return self._call_chain(*args)

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/urllib/request.py", line 494, in _call_chain

result = func(*args)

File "/root/miniconda3/envs/dinov2-extras/lib/python3.9/urllib/request.py", line 641, in http_error_default

raise HTTPError(req.full_url, code, msg, hdrs, fp)

urllib.error.HTTPError: HTTP Error 403: rate limit exceeded

据说这个是PyTorch部分版本的Bug,可以在torch.hub相关代码前加一行,如下:

python 复制代码
torch.hub._validate_not_a_forked_repo = lambda a, b, c: True

backbone_model = torch.hub.load(repo_or_dir="facebookresearch/dinov2", model=backbone_name)

问题解决。

相关推荐
翔云API13 分钟前
PHP静默活体识别API接口应用场景与集成方案
人工智能
浊酒南街19 分钟前
吴恩达深度学习笔记:卷积神经网络(Foundations of Convolutional Neural Networks)4.9-4.10
人工智能·深度学习·神经网络·cnn
Tony聊跨境34 分钟前
独立站SEO类型及优化:来检查这些方面你有没有落下
网络·人工智能·tcp/ip·ip
懒惰才能让科技进步40 分钟前
从零学习大模型(十二)-----基于梯度的重要性剪枝(Gradient-based Pruning)
人工智能·深度学习·学习·算法·chatgpt·transformer·剪枝
yyfhq1 小时前
sdnet
python
Qspace丨轻空间1 小时前
气膜场馆:推动体育文化旅游创新发展的关键力量—轻空间
大数据·人工智能·安全·生活·娱乐
没有不重的名么1 小时前
门控循环单元GRU
人工智能·深度学习·gru
测试19981 小时前
2024软件测试面试热点问题
自动化测试·软件测试·python·测试工具·面试·职场和发展·压力测试
love_and_hope1 小时前
Pytorch学习--神经网络--搭建小实战(手撕CIFAR 10 model structure)和 Sequential 的使用
人工智能·pytorch·python·深度学习·学习
2403_875736871 小时前
道品科技智慧农业中的自动气象检测站
网络·人工智能·智慧城市