pytroch下载pretrained model失败或者过慢问题

    科技2024-04-18  6

    报错

    做fine-turne的时候,使用resnet152的pretrained model, 直接运行的时候,一直报错。

    File "/usr/lib/python3.5/urllib/request.py", line 1256, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

    resnet的下载url:

    model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth', 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', 'resnet101': 'https://download.pytorch.org/models/resnet101-5d3b4d8f.pth', 'resnet152': 'https://download.pytorch.org/models/resnet152-b121ed2d.pth', 'resnext50_32x4d': 'https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth', 'resnext101_32x8d': 'https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth', 'wide_resnet50_2': 'https://download.pytorch.org/models/wide_resnet50_2-95faca4d.pth', 'wide_resnet101_2': 'https://download.pytorch.org/models/wide_resnet101_2-32ee1156.pth', }

    下载到本地的位置

    win10:

    C:\Users\xx_username\.cache\torch\hub\checkpoints

    ubuntu:

    /home/xx_username/.cache/torch/checkpoints/

    处理方法:

    如果可以上网从官网、直接下载url的pretrained model, 放到指定位置,即可运行。

    如果想下载http://amazonaws.com的预训练模型,可以直接浏览器输入:

    https://github.com/LikeLy-Journey/SegmenTron/releases/download/v0.1.0/resnet50-25c4b509.pth https://github.com/LikeLy-Journey/SegmenTron/releases/download/v0.1.0/resnet101-2a57e44d.pth https://github.com/LikeLy-Journey/SegmenTron/releases/download/v0.1.0/resnet152-0d43d698.pth
    Processed: 0.036, SQL: 12