Bootstrap

depth anything复现时遇到的问题

问题一:depth_anything = DepthAnything.from_pretrained('LiheYoung/depth_anything_{}14'.format(args.encoder)).to(DEVICE).eval()

加载.pth文件时出问题了?

错误提示:huggingface_hub.utils._errors. LocalEntryNotFoundError: an error happened while trying to locate the file on the HU and we cannot find the requested files in the local cache.

解决方案:

下载权重,使用国内的镜像,首先在命令行执行下面的命令设置下环境变量:

export HF_ENDPOINT=https://hf-mirror.com

然后再运行run.sh

问题解决 √

问题二:depth = depth_anything(image)

加载图片时出问题了,与权重文件不匹配吗?

错误提示:RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

解决方案:将所有的内容都放到cpu上运行,即DEVICE = torch.device("cpu")

问题解决 √

问题三:depth = depth_anything(image)

是torch版本问题吗?

错误提示:TypeError: interpolate() got an unexpected keyword argument 'antialias'

解决方案:在run.sh文件中加入更新torch和torchvision的命令

问题解决 √

附加:run.sh 是我自己写的,可参考

pip install -r requirements.txt
pip install --upgrade torch
pip install --upgrade torchvision
python run.py --encoder vits --img-path assets/examples

;