当前位置:   article > 正文

Pytorch:离线下载预训练模型方法,如VGGNet,ResNet,DenseNet等_models.resnet18(pretrained=use_pretrained)

models.resnet18(pretrained=use_pretrained)

以Resnet18为例,在程序中输入

  1. from __future__ import print_function, division
  2. from torchvision import models
  3. model_ft = models.resnet18(pretrained=True)

然后运行,就会出现如下

再将这个网址复制到浏览器中,就可以直接下载Resnet18模型。下载结束后,将下载的文件放入你建立的python项目中,再运用如下代码就可以调用Resnet18模型。

  1. model_ft = models.resnet18(pretrained=False)
  2. pre = torch.load('resnet18-5c106cde.pth')
  3. model_ft.load_state_dict(pre)

 

其他的学习模型也可以用类似的方法下载,或者可以参看下面的下载网址

‘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’

‘densenet121’: ‘https://download.pytorch.org/models/densenet121-a639ec97.pth’
‘densenet169’: ‘https://download.pytorch.org/models/densenet169-b2777c0a.pth’
‘densenet201’: ‘https://download.pytorch.org/models/densenet201-c1103571.pth’
‘densenet161’: ‘https://download.pytorch.org/models/densenet161-8d451a50.pth’

‘vgg11’: ‘https://download.pytorch.org/models/vgg11-bbd30ac9.pth’
‘vgg13’: ‘https://download.pytorch.org/models/vgg13-c768596a.pth’
‘vgg16’: ‘https://download.pytorch.org/models/vgg16-397923af.pth’
‘vgg19’: ‘https://download.pytorch.org/models/vgg19-dcbb9e9d.pth’
‘vgg11_bn’: ‘https://download.pytorch.org/models/vgg11_bn-6002323d.pth’
‘vgg13_bn’: ‘https://download.pytorch.org/models/vgg13_bn-abd245e5.pth’
‘vgg16_bn’: ‘https://download.pytorch.org/models/vgg16_bn-6c64b313.pth’
‘vgg19_bn’: ‘https://download.pytorch.org/models/vgg19_bn-c79401a0.pth’

‘alexnet’: ‘https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth’

#Inception v3 ported from TensorFlow
‘inception_v3_google’: ‘https://download.pytorch.org/models/inception_v3_google-1a9a5a14.pth’

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/351063
推荐阅读
相关标签
  

闽ICP备14008679号