CenterNet icon indicating copy to clipboard operation
CenterNet copied to clipboard

During the training, the following errors occurred:AttributeError: 'NoneType' object has no attribute 'shape'

Open 1356789-rr opened this issue 4 years ago • 8 comments

Setting up data... ==> initializing coco 2017 val data. loading annotations into memory... Done (t=0.00s) creating index... index created! Loaded val 812 samples ==> initializing coco 2017 train data. loading annotations into memory... Done (t=0.01s) creating index... index created! Loaded train 812 samples Starting training... ctdet/coco_dla/home/rc/anaconda3/envs/centerNet1/lib/python3.6/site-packages/torch/nn/functional.py:52: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) ctdet/coco_dla |################################| train: [1][100/101]|Tot: 0:03:18 |ETA: 0:00:02 |loss 5.1209 |hm_loss 3.8793 |wh_loss 9.5661 |off_loss 0.2850 |Data 0.141s(0.133s) |Net 1.964s ctdet/coco_dla |################################| train: [2][100/101]|Tot: 0:03:15 |ETA: 0:00:02 |loss 3.5339 |hm_loss 2.6739 |wh_loss 5.9882 |off_loss 0.2611 |Data 0.141s(0.143s) |Net 1.931s ctdet/coco_dla |################################| train: [3][100/101]|Tot: 0:03:15 |ETA: 0:00:02 |loss 3.3472 |hm_loss 2.5956 |wh_loss 4.9320 |off_loss 0.2584 |Data 0.143s(0.143s) |Net 1.934s ctdet/coco_dla |################################| train: [4][100/101]|Tot: 0:03:15 |ETA: 0:00:02 |loss 3.2140 |hm_loss 2.4639 |wh_loss 4.9046 |off_loss 0.2596 |Data 0.146s(0.142s) |Net 1.938s ctdet/coco_dla |################################| train: [5][100/101]|Tot: 0:03:15 |ETA: 0:00:02 |loss 3.1397 |hm_loss 2.4231 |wh_loss 4.6018 |off_loss 0.2565 |Data 0.143s(0.142s) |Net 1.939s ctdet/coco_dlaTraceback (most recent call last): File "main.py", line 102, in main(opt) File "main.py", line 79, in main log_dict_val, preds = trainer.val(epoch, val_loader) File "/home/rc/CenterNet-master/src/lib/trains/base_trainer.py", line 116, in val return self.run_epoch('val', epoch, data_loader) File "/home/rc/CenterNet-master/src/lib/trains/base_trainer.py", line 61, in run_epoch for iter_id, batch in enumerate(data_loader): File "/home/rc/anaconda3/envs/centerNet1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 336, in next return self._process_next_batch(batch) File "/home/rc/anaconda3/envs/centerNet1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch raise batch.exc_type(batch.exc_msg) AttributeError: Traceback (most recent call last): File "/home/rc/anaconda3/envs/centerNet1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/rc/anaconda3/envs/centerNet1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 106, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/rc/CenterNet-master/src/lib/datasets/sample/ctdet.py", line 39, in getitem height, width = img.shape[0], img.shape[1] AttributeError: 'NoneType' object has no attribute 'shape'

I print(img), it's ok. So I don't know what's wrong,please help me!Thank you very much!

1356789-rr avatar Jun 22 '20 00:06 1356789-rr

I have the same mistake,have you solved it?

wangminj avatar Jun 22 '20 03:06 wangminj

make sure you got the correct image path. dataloader can't find the image with the path you give.

RENCHEN90 avatar Jun 22 '20 06:06 RENCHEN90

make sure you got the correct image path. dataloader can't find the image with the path you give.

The image path is correct. I have print (img), it has data. What I am puzzled about is that it didn't report a mistake at the beginning. It was after training several times that it made a mistake.

1356789-rr avatar Jun 22 '20 07:06 1356789-rr

make sure you got the correct image path. dataloader can't find the image with the path you give.

The image path is correct. I have print (img), it has data. What I am puzzled about is that it didn't report a mistake at the beginning. It was after training several times that it made a mistake.

because the first paths are correct. and the path after several iters is wrong. or your image file is broken for that specific image

RENCHEN90 avatar Jun 22 '20 07:06 RENCHEN90

make sure you got the correct image path. dataloader can't find the image with the path you give.

The image path is correct. I have print (img), it has data. What I am puzzled about is that it didn't report a mistake at the beginning. It was after training several times that it made a mistake.

because the first paths are correct. and the path after several iters is wrong. or your image file is broken for that specific image

Sorry, I don't quite understand. The annotations tag of my dataset is to convert xml to coco's json format. So I think if the data path is wrong, it will go wrong together. Why is there a time when the path is correct? I don't know how to find this mistake, can you elaborate on it. Thank you very much!

1356789-rr avatar Jun 22 '20 07:06 1356789-rr

I have the same problem with you ,have you solved it?thank you very much!

Veronica1997 avatar Jul 16 '20 14:07 Veronica1997

I have the same problem with you ,have you solved it?thank you very much!

I met same problem, do you solve it?

chordxu avatar Jul 22 '20 02:07 chordxu

test.py in 33: img_path = os.path.join(self.img_dir, 'val/',img_info['file_name']), add 'val', it works

bloom1123 avatar Nov 23 '21 01:11 bloom1123