1. Error information
UserWarning: Mapping deprecated model name vit_base_resnet50_384 to current vit_base_r50_s16_384.orig_in21k_ft_in1k.
**kwargs,
'(ReadTimeoutError("HTTPSConnectionPool(host='huggingface.co', port=443): Read timed out. (read timeout=10)"), '(Request ID: a2623e19-f380-47a6-9e64-5ed169b5b593)')' thrown while requesting HEAD https://huggingface.co/timm/vit_base_r50_s16_384.orig_in21k_ft_in1k/resolve/main/model.safetensors
2. Source code
model = DPTDepthModel(backbone='vitb_rn50_384', num_channels=3) # DPT Hybrid
checkpoint = torch.load(pretrained_weights_path, map_location=map_location)
if 'state_dict' in checkpoint:
state_dict = {}
for k, v in checkpoint['state_dict'].items():
state_dict[k[6:]] = v
else:
state_dict = checkpoint
model.load_state_dict(state_dict)
model.to(device)
3. 问题分析
访问huggingface出了问题,但是服务器已经挂了梯子,网络连接正常。
之后查看要访问的网址:https://huggingface.co/timm/vit_base_r50_s16_384.orig_in21k_ft_in1k/resolve/main/model.safetensors
主要到其中的timm
是之前我们pip 下来的一个包,它提供了预训练模型和各种网络组件,所以可能是我们单独pip install的过程中出了问题。
4. 解决方法
timm
降版本,目前为0.9.12
,降到0.4.5
pip install timm==0.4.5
问题解决后的正常终端输出:
Downloading: "https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-vitjx/jx_vit_base_resnet50_384-9fd3c705.pth" to /root/.cache/torch/hub/checkpoints/jx_vit_base_resnet50_384-9fd3c705.pth
5. 另外一种更为通用的方法
切换镜像到huggingface的国内版本:
在代码中加入
import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
注意这一步一定要放在import diffusers
之前,可以放在主python文件的第一句话,比如下面这么放,也可以多放几处试试
完结撒花✿✿ヽ(°▽°)ノ✿
Reference:
[1]. Unknown model (vit_base_resnet50_384) · Issue #14 · isl-org/DPT (github.com)
[2]. 使用Huggingface镜像站hf-mirror.com下载资源_hf.mirror-CSDN博客