简体   繁体   中英

Loading resnet50 prettrianed model in PyTorch

I want to use resnet50 pretrained model using PyTorch and I am using the following code for loading it:

    import torch
    model = torch.hub.load("pytorch/vision", "resnet50", weights="IMAGENET1K_V2")

Although I upgrade the torchvision but I receive the following error:

Any idea?

As per the latest definition, we now load models using torchvision library, you can try that using:

from torchvision.models import resnet50, ResNet50_Weights

# Old weights with accuracy 76.130%
model1 = resnet50(weights=ResNet50_Weights.IMAGENET1K_V1)

# New weights with accuracy 80.858%
model2 = resnet50(weights=ResNet50_Weights.IMAGENET1K_V2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM