fudan-zvg / SETR

[CVPR 2021] Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers
MIT License
1.05k stars 149 forks source link

AttributeError: 'DataContainer' object has no attribute 'shape' #43

Closed 202041600047 closed 2 years ago

202041600047 commented 3 years ago

hello, Thank you for your contribution, When my dataset is Cityscapes, I run tools / train.py. It has the following error:

Traceback (most recent call last): File "/home/caiweixin/Downloads/SETR-main/tools/train.py", line 161, in main() File "/home/caiweixin/Downloads/SETR-main/tools/train.py", line 150, in main train_segmentor( File "/home/caiweixin/Downloads/SETR-main/mmseg/apis/train.py", line 105, in train_segmentor runner.run(data_loaders, cfg.workflow, cfg.total_iters) File "/home/caiweixin/anaconda3/envs/SETR-main/lib/python3.9/site-packages/mmcv/runner/iter_based_runner.py", line 130, in run iter_runner(iter_loaders[i], kwargs) File "/home/caiweixin/anaconda3/envs/SETR-main/lib/python3.9/site-packages/mmcv/runner/iter_based_runner.py", line 60, in train outputs = self.model.train_step(data_batch, self.optimizer, kwargs) File "/home/caiweixin/Downloads/SETR-main/mmseg/models/segmentors/base.py", line 152, in train_step losses = self(data_batch) File "/home/caiweixin/anaconda3/envs/SETR-main/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/home/caiweixin/anaconda3/envs/SETR-main/lib/python3.9/site-packages/mmcv/runner/fp16_utils.py", line 84, in new_func return old_func(args, kwargs) File "/home/caiweixin/Downloads/SETR-main/mmseg/models/segmentors/base.py", line 122, in forward return self.forward_train(img, img_metas, *kwargs) File "/home/caiweixin/Downloads/SETR-main/mmseg/models/segmentors/encoder_decoder.py", line 153, in forward_train x = self.extract_feat(img) File "/home/caiweixin/Downloads/SETR-main/mmseg/models/segmentors/encoder_decoder.py", line 79, in extract_feat x = self.backbone(img) File "/home/caiweixin/anaconda3/envs/SETR-main/lib/python3.9/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/home/caiweixin/Downloads/SETR-main/mmseg/models/backbones/vit.py", line 393, in forward B = x.shape[0] AttributeError: 'DataContainer' object has no attribute 'shape'

I don't know how to solve it. I hope you can give me some suggestions. Thank you very much.

sixiaozheng commented 2 years ago

Maybe your environment is installed incorrectly, please refer to the A from-scratch setup script in the README.md to reinstall the environment. And run the command ./tools/dist_train.sh ${CONFIG_FILE} ${GPU_NUM} .