D-X-Y/landmark-detection

SAN: error when load the pretrained model

QcQcM opened this issue · 4 comments

QcQcM commented

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

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

QcQcM commented

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 commented

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.