Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAN: error when load the pretrained model #68

Open
QcQcM opened this issue Jul 16, 2020 · 4 comments
Open

SAN: error when load the pretrained model #68

QcQcM opened this issue Jul 16, 2020 · 4 comments
Assignees

Comments

@QcQcM
Copy link

QcQcM commented Jul 16, 2020

Which project are you using?

SAN

Issue description

When I use the pretrained model to test single picture on CPU, there was an error "No module names models".
This is probably because you save and load the entire model not only the model parameters with "torch.save(state, filename) torch.load(snapshot)",and my file path is inconsistent with your training.
but I just download the snapshot and put it in SAN/snapshots as you say, is there any thing wrong in my file path ? How can I load the model correctly?
I have used the model successfully on Win10, but failed in Ubuntu.
Your response will be very helpful. Thx!!!

Code example

qichang@qichang-TUF-Gaming-FA506IV-FA506IV:~/PycharmProjects/SAN$ python3 san_eval.py --image ./cache_data/cache/test_1.jpg --model ./snapshots/SAN_300W_GTB_itn_cpm_3_50_sigma4_128x128x8/checkpoint_49.pth.tar --face 819.27 432.15 971.70 575.87 --save_path temp_1.png --cpu The image is ./cache_data/cache/test_1.jpg The model is ./snapshots/SAN_300W_GTB_itn_cpm_3_50_sigma4_128x128x8/checkpoint_49.pth.tar The face bounding box is [819.27, 432.15, 971.7, 575.87] Traceback (most recent call last): File "san_eval.py", line 91, in <module> evaluate(args) File "san_eval.py", line 29, in evaluate if args.cpu: snapshot = torch.load(snapshot, map_location='cpu') File "/home/qichang/.local/lib/python3.6/site-packages/torch/serialization.py", line 386, in load return _load(f, map_location, pickle_module, **pickle_load_args) File "/home/qichang/.local/lib/python3.6/site-packages/torch/serialization.py", line 573, in _load result = unpickler.load() ModuleNotFoundError: No module named 'models'

System Info

Ubuntu 18.04

@D-X-Y D-X-Y self-assigned this Jul 21, 2020
@XYudong
Copy link

XYudong commented Aug 10, 2020

Hi, same here. Have you solved the issue? Thanks

@QcQcM
Copy link
Author

QcQcM commented Aug 10, 2020 via email

@tealeeseng
Copy link

CUDA_VISIBLE_DEVICES="" python3 san_eval.py --image ./cache_data/cache/test_1.jpg --model ./snapshots/SAN_300W_GTB_itn_cpm_3_50_sigma4_128x128x8/checkpoint_49.pth.tar --face 819.27 432.15 971.70 575.87 --save_path temp_1.png --cpu

works fine under torch 1.6 with cuda, Python 3.7.9, ubuntu 20.04

@QcQcM
Copy link
Author

QcQcM commented Dec 3, 2020

Hi, same here. Have you solved the issue? Thanks

You can try make directory SAN as source root ,then the model file path will be same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants