TransUNet: AttributeError: "'skip_channels'"
Hi, When I run the test.py , I get the following error:
` File “/home/wf/anaconda3/envs/trunet/lib/python3.7/site-packages/ml_collections/config_dict/config_dict.py”, line 883, in getitem field = self._fields[key] KeyError: ‘skip_channels’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/home/wf/anaconda3/envs/trunet/lib/python3.7/site-packages/ml_collections/config_dict/config_dict.py”, line 807, in getattr return self[attribute] File “/home/wf/anaconda3/envs/trunet/lib/python3.7/site-packages/ml_collections/config_dict/config_dict.py”, line 889, in getitem raise KeyError(self._generate_did_you_mean_message(key, str(e))) KeyError: “‘skip_channels’”
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/home/wf/anaconda3/envs/project_TransUNet_2/project_TransUNet/TransUNet/test.py”, line 118, in <module> net = ViT_seg(config_vit, img_size=args.img_size, num_classes=config_vit.n_classes).cuda() File “/home/wf/anaconda3/envs/project_TransUNet_2/project_TransUNet/TransUNet/networks/vit_seg_modeling.py”, line 378, in init self.decoder = DecoderCup(config) File “/home/wf/anaconda3/envs/project_TransUNet_2/project_TransUNet/TransUNet/networks/vit_seg_modeling.py”, line 343, in init skip_channels = self.config.skip_channels File “/home/wf/anaconda3/envs/trunet/lib/python3.7/site-packages/ml_collections/config_dict/config_dict.py”, line 809, in getattr raise AttributeError(e) AttributeError: “‘skip_channels’”`
Then I change skip_channels = self.config.skip_channels (in vit_seg_modeling.py 343 line) to skip_channels = [512,256,64,16] , I get the following new error:
RuntimeError: Error(s) in loading state_dict for VisionTransformer: Unexpected key(s) in state_dict: "transformer.embeddings.hybrid_model.root.conv.weight", size mismatch for transformer.embeddings.patch_embeddings.weight: copying a param with shape torch.Size([768, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([768, 3, 16, 16])
For me, the cause of this is unclear. Does anyone have an idea?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 21
If you use vit_name R50-ViT-B_16 to train, then you need to use vit_name R50-ViT-B_16 to test. Check whether the model name is same during training and testing.