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.
My problem was that I had installed pytorch version 1.0.0 which then uses an earlier version of torchvision which holds the respective model. My issue was resolved after running:
Yes: The output for python -m fastai.ustils.show_install:
Traceback (most recent call last):
File “C:\Users\rjsod\Anaconda3\envs\fastai\lib\runpy.py”, line 183, in run_module_as_main
mod_name, mod_spec, code = get_module_details(mod_name, Error)
File “C:\Users\rjsod\Anaconda3\envs\fastai\lib\runpy.py”, line 109, in get_module_details import(pkg_name)
File "C:\Users\rjsod\fastai\fastai\utils_init.py", line 1, in
from .collect_env import *
File “C:\Users\rjsod\fastai\fastai\utils\collect_env.py”, line 4, in
from …imports.torch import *
File "C:\Users\rjsod\fastai\fastai\imports_init.py", line 2, in
from .torch import *
File “C:\Users\rjsod\fastai\fastai\imports\torch.py”, line 1, in
import torch, torch.nn.functional as F
File "C:\Users\rjsod\Anaconda3\envs\fastai\lib\site-packages\torch_init.py", line 81, in
ctypes.CDLL(dll)
File "C:\Users\rjsod\Anaconda3\envs\fastai\lib\ctypes_init.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
Im sorry. The typo is in the post. The error persists when I copy paste from your reply.Currently Reinstalling Anaconda and contents. Im going to install as shown in the article you posted. Will edit thread if error still persists.
If you are running your code in a Jupyter notebook/Lab. It may happen that the notebook is getting triggered from a different (base) environment. In your fastai environment try installing jupyter