代码 snapshot = os.path.join(snapshot_path, 'best_model.pth')
if not os.path.exists(snapshot): snapshot = snapshot.replace('bestmodel', 'epoch'+str(args.max_epochs-1))
报错:C:\ProgramData\anaconda3\python.exe C:\Users\86133\Desktop\project_TransUNet\TransUNet\test.py
../model/TU_Synapse224/TU_pretrain_R50-ViT-B_16_skip3_epo150_bs24_224\epoch_149.pth
Traceback (most recent call last):
File "C:\Users\86133\Desktop\project_TransUNet\TransUNet\test.py", line 139, in
net.load_state_dict(torch.load(snapshot))
File "C:\Users\86133\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for VisionTransformer:
Missing key(s) in state_dict: "transformer.embeddings.hybrid_model.body.block1/.unit1/.gn1.weight", "
Unexpected key(s) in state_dict: "transformer.embeddings.DAblock1.conv5a.0.weight",
代码 snapshot = os.path.join(snapshot_path, 'best_model.pth') if not os.path.exists(snapshot): snapshot = snapshot.replace('bestmodel', 'epoch'+str(args.max_epochs-1)) 报错:C:\ProgramData\anaconda3\python.exe C:\Users\86133\Desktop\project_TransUNet\TransUNet\test.py ../model/TU_Synapse224/TU_pretrain_R50-ViT-B_16_skip3_epo150_bs24_224\epoch_149.pth Traceback (most recent call last): File "C:\Users\86133\Desktop\project_TransUNet\TransUNet\test.py", line 139, in
net.load_state_dict(torch.load(snapshot))
File "C:\Users\86133\AppData\Roaming\Python\Python311\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for VisionTransformer:
Missing key(s) in state_dict: "transformer.embeddings.hybrid_model.body.block1/.unit1/.gn1.weight", "
Unexpected key(s) in state_dict: "transformer.embeddings.DAblock1.conv5a.0.weight",
进程已结束,退出代码为 1