AttributeError: 'NoneType' object has no attribute 'shape'
Opened this issue · 5 comments
Hello, I have encountered this problem, but I don’t know how to solve it. I hope you can give me some help. Thank you very much.
python3 train.py --model-name zhou_full --depth-training-loaders "kitti_zhou_train" --train-batches-per-epoch 7293 --masking-enable --masking-from-epoch 15 --masking-linear-increase
Starting initialization
Loading training dataset metadata:
- Can use 43760 images from the kitti (zhou_split) train split for depth training
- Can use 2975 images from the cityscapes train set for segmentation training
Loading validation dataset metadata: - Can use 1159 images from the kitti (kitti_split) validation set for depth validation
- Can use 500 images from the cityscapes validation set for segmentation validation
Summary: - Model name: zhou_full
- Logging directory: /media/disk1/xgl/SGDepth-master/Checkpoints/sgdepth_eccv_test/zhou_full
- Using device: cuda (GeForce GTX 1070)
Epoch 0:
Traceback (most recent call last):
File "train.py", line 372, in
trainer.train()
File "train.py", line 340, in train
self._run_epoch()
File "train.py", line 228, in _run_epoch
for batch_idx, batch in enumerate(self.train_loaders):
File "/media/disk1/xgl/SGDepth-master/loaders/init.py", line 25, in iter
for batch_idx, *group in zip(length_iter, *infinite_iters):
File "/media/disk1/xgl/SGDepth-master/loaders/init.py", line 30, in _make_infinite
for batch in loader:
File "/home/xgl/anaconda3/envs/xgl/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next
return self._process_next_batch(batch)
File "/home/xgl/anaconda3/envs/xgl/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
AttributeError: Traceback (most recent call last):
File "/home/xgl/anaconda3/envs/xgl/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/xgl/anaconda3/envs/xgl/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/xgl/anaconda3/envs/xgl/lib/python3.6/site-packages/torch/utils/data/dataset.py", line 85, in getitem
return self.datasets[dataset_idx][sample_idx]
File "/media/disk1/xgl/SGDepth-master/dataloader/pt_data_loader/basedataset.py", line 217, in getitem
sample = self.add_const_dataset_items(sample)
File "/media/disk1/xgl/SGDepth-master/dataloader/pt_data_loader/specialdatasets.py", line 47, in add_const_dataset_items
native_im_shape = sample[native_key].shape
AttributeError: 'NoneType' object has no attribute 'shape'
Hey there,
this is an error I usually get, if the datasets' folder structure is either not correct or if some of the images are missing/broken. In this case the opencv image loading function returns a None object, which has no attribute shape. Maybe you could double check, if the datasets are set up correctly?
Hey there,
this is an error I usually get, if the datasets' folder structure is either not correct or if some of the images are missing/broken. In this case the opencv image loading function returns a None object, which has no attribute shape. Maybe you could double check, if the datasets are set up correctly?
Thank you very much for your reply, I will check my data set according to your reply.
Hi @17853313621
I am facing the same issue like you. I am unable to find any broken images in the downloaded dataset so I am not sure what is causing the error. Were you able to solve the problem by downloading the data set again or did you do something else ?
This is because the json file is inconsistent with the folder file, and the image is missing.
Hello, I am creating an artificial intelligence algorithm and I encountered this error:
imageHeight, imageWidth = frame.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'
can you Help Me What Should I do?