Torchvision model different behavior after torch.hub

Viewed 130

I want to fix some odd import behavior I'm seeing

This does not work:

import torchvision
dilated_model = torchvision.models.resnet50(
    pretrained=True, 
    replace_stride_with_dilation=[False, False, True]
)

resnet50() got an unexpected keyword argument 'replace_stride_with_dilation'

But this does

import torch
model = torch.hub.load('pytorch/vision:v0.9.0', 'resnet18', pretrained=True)

import torchvision
dilated_model = torchvision.models.resnet50(
    pretrained=True, 
    replace_stride_with_dilation=[False, False, True]
)

What's going on? In the torchvision github code, replace_stride_with_dilation should be valid... and my torch/torchvision packages are up to date (torch=1.8.1, torchvision=0.9.1)


Update: no clue what caused the issue, but it went away after pip uninstall torchvision && pip install torchvision.

0 Answers
Related