ImportError: cannot import name 'mobilenet_v2' from 'torchvision.models'

Viewed 6732

I want to run a fastai deep learning model on my pc. Not train, just run the pre-trained model on my PC. I have the .pth file. I tried to import the fastai module that I installed and I recieved the error :

ImportError: cannot import name 'mobilenet_v2' from 'torchvision.models' (C:\file_path\__init__.py)

The Code I tried to execute:

#From the fastai library
from fastai import *
from torchvision.models import * 
from fastai.vision import *

I can't find any solutions as to why I am getting this error.

Im running this code in anaconda, to be specific, the spyder IDE connected to my anaconda environment. I will re-edit this if anyone needs more specifications. Thank you.

1 Answers

I just finished fixing this problem with my system. Uninstall any pytorch, torchvision by conda and pip. Uninstall fastai as well.

Go to https://pytorch.org/get-started/locally/ and run the conda command there base on your cuda version and etc. Then

conda install -c fastai fastai
Related