D-X-Y / landmark-detection

Four landmark detection algorithms, implemented in PyTorch.
https://xuanyidong.com/assets/projects/TPAMI-2020-SRT.html
MIT License
925 stars 180 forks source link

SAN: error when load the pretrained model #68

Open QcQcM opened 4 years ago

QcQcM commented 4 years ago

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

XYudong commented 4 years ago

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

QcQcM commented 4 years ago

我重新训练了一下网络,解决了这个问题。谢谢,可能以后还有问题要麻烦您。

------------------ 原始邮件 ------------------ 发件人: "D-X-Y/landmark-detection" <notifications@github.com>; 发送时间: 2020年8月10日(星期一) 中午11:29 收件人: "D-X-Y/landmark-detection"<landmark-detection@noreply.github.com>; 抄送: "梦?缘にひパ"<708805642@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [D-X-Y/landmark-detection] SAN: error when load the pretrained model (#68)

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

tealeeseng commented 4 years ago

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 4 years ago

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.