Closed michael-gc closed 2 years ago
When I test the code to generate edge maps for my own images following the readme guide, an error occurs. Running the test code by:
python main.py --model pidinet_converted --config carv4 --sa --dil -j 4 --datadir ./data/test --dataset Custom --evaluate ./trained_models/table5_pidinet.pth --evaluate-converted
Error:
Namespace(ablation=False, checkinfo=False, config='carv4', datadir='./data/test', datase epochs=20, eta=0.3, evaluate='./trained_models/table5_pidinet.pth', evaluate_converted= =24, lmbda=1.1, lr=0.005, lr_steps=None, lr_type='multistep', model='pidinet', only_bsds nt_freq=10, resume=False, sa=True, save_freq=1, savedir='results/savedir', seed=16383577 0.0001, workers=4) {'layer0': 'cd', 'layer1': 'ad', 'layer2': 'rd', 'layer3': 'cv', 'layer4': 'cd', 'layer5 , 'layer7': 'cv', 'layer8': 'cd', 'layer9': 'ad', 'layer10': 'rd', 'layer11': 'cv', 'lay 'ad', 'layer14': 'rd', 'layer15': 'cv'} initialization done conv weights: lr 0.005000, wd 0.000100 bn weights: lr 0.005000, wd 0.000010 relu wei .000000 cuda is not used, the running might be slow => loading checkpoint from './trained_models/table5_pidinet.pth' => loaded checkpoint './trained_models/table5_pidinet.pth' successfully {'layer0': 'cd', 'layer1': 'ad', 'layer2': 'rd', 'layer3': 'cv', 'layer4': 'cd', 'layer5 , 'layer7': 'cv', 'layer8': 'cd', 'layer9': 'ad', 'layer10': 'rd', 'layer11': 'cv', 'lay 'ad', 'layer14': 'rd', 'layer15': 'cv'} Traceback (most recent call last): File "main.py", line 418, in <module> main(f) File "main.py", line 201, in main model.load_state_dict(convert_pidinet(checkpoint['state_dict'], args.config)) File "D:\Miniconda3\envs\paintly\lib\site-packages\torch\nn\modules\module.py", line 1 self.__class__.__name__, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for PiDiNet: Missing key(s) in state_dict: "init_block.weight", "block1_1.conv1.weight", "blo lock1_2.conv1.weight", .... Unexpected key(s) in state_dict: "module.init_block.weight", "module.block1_1.co ock1_1.conv2.weight", "module.block1_2.conv1.weight"...
Seems like the loaded model does not match the defined model. @zhuoinoulu Did I miss something? Very much appreciated for your help!
Hi, probably it is caused by the unmatched key names in the checkpoint, as the model checkpoint was trained with cuda, therefore there is a prefix "module." in the key names. Please try to remove this prefix if only CPU is used, by adding the following code after line 36: https://github.com/zhuoinoulu/pidinet/blob/781924fe30469cdc64f63ce6666a3e1f5b4e576f/models/convert_pidinet.py#L36 pname = pname.replace('module.', '')
It works! Thanks a lot~~
@michael-gc Hi. I got the same error but fixed it as @zhuoinoulu suggested. But I'm not getting getting the edge maps on the resultant folder. It says "Begin to eval...." and the "Img generated in .\results\eval_results\imgs_epoch_019" but there is no image in that folder.
Note: I have my images directly in a folder called test images.
Where am I doing the mistake?
When I test the code to generate edge maps for my own images following the readme guide, an error occurs. Running the test code by:
python main.py --model pidinet_converted --config carv4 --sa --dil -j 4 --datadir ./data/test --dataset Custom --evaluate ./trained_models/table5_pidinet.pth --evaluate-converted
Error:
Seems like the loaded model does not match the defined model. @zhuoinoulu Did I miss something? Very much appreciated for your help!