I don’t get this error with the latest torchvision version.
Is torchvision.models imported as pretrainedmodels in your code?
Also, the state_dict name looks different from the torchvision one in this line of code 14.