报错信息:
RuntimeError: It looks like there is no internet connection and the repo could not be found in the cache
报错位置:
self.dinov2_vitg14 = torch.hub.load("facebookresearch/dinov2", "dinov2_vitg14", pretrained=False)
报错原因:
挂载服务器时,无法连接github,从而无法在线加载模型。
解决方案:
首先根据项目名称("facebookresearch/dinov2")将项目下载到本地,并传至服务器上。
然后将"facebookresearch/dinov2"修改为你的本地路径"path/to/your/dinov2_main"。
最后添加一个参数“source”
self.dinov2_vitg14 = torch.hub.load("path/to/your/dinov2_main", "dinov2_vitg14", source='local' pretrained=False)