I was previously loading a ResNet model with the ResNet50_Weights parameter successfully, but then suddenly I started getting the following error:
Traceback (most recent call last):
File "splitting_models.py", line 3, in <module>
from torchvision.models.resnet import ResNet50_Weights
ImportError: cannot import name 'ResNet50_Weights' from 'torchvision.models.resnet' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torchvision/models/resnet.py)
Here is the import:
from torchvision.models import ResNet50_Weights
How could I go about fixing this?
PyTorch version: 1.2.0
TorchVision version: 0.4.0
EDIT
Upgrading using
pip install --upgrade torch torchvision
to the following versions fixed the issue:
PyTorch version: 1.12.0
TorchVision version: 0.13.0