No module named '__torch__'

In python3.7 and windows10, pytorch 1.5, I saved my model
and…
I loaded

import torch
model = torch.load(‘D:\CR_DOWN\CRAFT-pytorch-master\CRAFT-pytorch-master\model_OCR.pt’)

but… I got a error of
No module named ‘torch
why I got this error??


ModuleNotFoundError Traceback (most recent call last)
in
----> 1 model = torch.load(‘D:\CR_DOWN\CRAFT-pytorch-master\CRAFT-pytorch-master\model_OCR.pt’)

~\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
582 opened_file.seek(orig_position)
583 return torch.jit.load(opened_file)
–> 584 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
585 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
586

~\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\serialization.py in _load(zip_file, map_location, pickle_module, **pickle_load_args)
840 unpickler = pickle_module.Unpickler(data_file, **pickle_load_args)
841 unpickler.persistent_load = persistent_load
–> 842 result = unpickler.load()
843
844 return result

ModuleNotFoundError: No module named ‘torch

Hi,

Did you saved that file with a different version of pytorch by any chance? Especially a more recent version than the one you use for loading?

I’ve recognized that the model what i trying to convert to mobile is actually not pytorch model…
(it was python function name, not a pytorch model)
I changed the model correctly, and it worked!
Thank you.

1 Like