Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I still have the error: AttributeError: 'NoneType' object has no attribute 'shape' #232

Closed
201814476285951 opened this issue Jul 25, 2019 · 9 comments

Comments

@201814476285951
Copy link

/home/ying/anaconda3/envs/CenterNet/bin/python /home/ying/CenterNet-master/src/main.py
Fix size testing.
training chunk_sizes: [32]
The output will be saved to /home/ying/CenterNet-master/src/lib/../../exp/ctdet/coco_dla
heads {'hm': 80, 'wh': 2, 'reg': 2}
Namespace(K=100, aggr_weight=0.0, agnostic_ex=False, arch='dla_34', aug_ddd=0.5, aug_rot=0, batch_size=32, cat_spec_wh=False, center_thresh=0.1, chunk_sizes=[32], data_dir='/home/ying/CenterNet-master/src/lib/../../data', dataset='coco', debug=0, debug_dir='/home/ying/CenterNet-master/src/lib/../../exp/ctdet/coco_dla/debug', debugger_theme='white', demo='/home/ying/CornerNet-master/data/tool/images/val/00000451.jpg', dense_hp=False, dense_wh=False, dep_weight=1, dim_weight=1, down_ratio=4, eval_oracle_dep=False, eval_oracle_hm=False, eval_oracle_hmhp=False, eval_oracle_hp_offset=False, eval_oracle_kps=False, eval_oracle_offset=False, eval_oracle_wh=False, exp_dir='/home/ying/CenterNet-master/src/lib/../../exp/ctdet', exp_id='coco_dla', fix_res=True, flip=0.5, flip_test=False, gpus=[0], gpus_str='0', head_conv=256, heads={'hm': 80, 'wh': 2, 'reg': 2}, hide_data_time=False, hm_hp=True, hm_hp_weight=1, hm_weight=1, hp_weight=1, input_h=512, input_res=512, input_w=512, keep_res=False, kitti_split='3dop', load_model='/home/ying/CenterNet-master/models/ctdet_coco_dla_2x.pth', lr=0.000125, lr_step=[90, 120], master_batch_size=32, mean=array([[[0.40789655, 0.44719303, 0.47026116]]], dtype=float32), metric='loss', mse_loss=False, nms=False, no_color_aug=False, norm_wh=False, not_cuda_benchmark=False, not_hm_hp=False, not_prefetch_test=False, not_rand_crop=False, not_reg_bbox=False, not_reg_hp_offset=False, not_reg_offset=False, num_classes=80, num_epochs=140, num_iters=-1, num_stacks=1, num_workers=4, off_weight=1, output_h=128, output_res=128, output_w=128, pad=31, peak_thresh=0.2, print_iter=0, rect_mask=False, reg_bbox=True, reg_hp_offset=True, reg_loss='l1', reg_offset=True, resume=False, root_dir='/home/ying/CenterNet-master/src/lib/../..', rot_weight=1, rotate=0, save_all=False, save_dir='/home/ying/CenterNet-master/src/lib/../../exp/ctdet/coco_dla', scale=0.4, scores_thresh=0.1, seed=317, shift=0.1, std=array([[[0.2886383 , 0.27408165, 0.27809834]]], dtype=float32), task='ctdet', test=False, test_scales=[1.0], trainval=False, val_intervals=5, vis_thresh=0.3, wh_weight=0.1)
Creating model...
loaded /home/ying/CenterNet-master/models/ctdet_coco_dla_2x.pth, epoch 230
Setting up data...
==> initializing coco 2017 val data.
loading annotations into memory...
Done (t=0.53s)
creating index...
index created!
Loaded val 5000 samples
==> initializing coco 2017 train data.
loading annotations into memory...
Done (t=13.66s)
creating index...
index created!
Loaded train 118287 samples
Starting training...
Traceback (most recent call last):
File "/home/ying/CenterNet-master/src/main.py", line 102, in
main(opt)
File "/home/ying/CenterNet-master/src/main.py", line 70, in main
log_dict_train, _ = trainer.train(epoch, train_loader)
File "/home/ying/CenterNet-master/src/lib/trains/base_trainer.py", line 119, in train
return self.run_epoch('train', epoch, data_loader)
File "/home/ying/CenterNet-master/src/lib/trains/base_trainer.py", line 61, in run_epoch
for iter_id, batch in enumerate(data_loader):
File "/home/ying/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "/home/ying/anaconda3/envs/CenterNet/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/ying/anaconda3/envs/CenterNet/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/ying/anaconda3/envs/CenterNet/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/ying/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'

Process finished with exit code 1
Please help me.Thanks a lot.

@201814476285951
Copy link
Author

Both for train and test.

@VRCMF
Copy link

VRCMF commented Jul 26, 2019

Check my question @201814476285951

@87ssfantasy
Copy link

I have also encountered this problem. The reason for this problem is that you cannot find the corresponding image under ‘images’ through your train.json and test.json, and make sure that all the images involved in the json file are placed in the images.

@1356789-rr
Copy link

I have also encountered this problem. The reason for this problem is that you cannot find the corresponding image under ‘images’ through your train.json and test.json, and make sure that all the images involved in the json file are placed in the images.

I also have this problem. How did you solve it?

@VRCMF
Copy link

VRCMF commented Jun 21, 2020

It means that images are not loaded. You need check paths of images. @1356789-rr

@1356789-rr
Copy link

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:23 |ETA: 0:00:02 |loss 5.3952 |hm_loss 4.0542 |wh_loss 10.6215 |off_loss 0.2789 |Data 0.225s(0.181s) |Net 2.013s
ctdet/coco_dla |################################| train: [2][100/101]|Tot: 0:03:16 |ETA: 0:00:02 |loss 3.6989 |hm_loss 2.7938 |wh_loss 6.4400 |off_loss 0.2610 |Data 0.151s(0.153s) |Net 1.944s
ctdet/coco_dla |################################| train: [3][100/101]|Tot: 0:03:16 |ETA: 0:00:02 |loss 3.4937 |hm_loss 2.6760 |wh_loss 5.5985 |off_loss 0.2578 |Data 0.153s(0.152s) |Net 1.946s
ctdet/coco_dla |################################| train: [4][100/101]|Tot: 0:03:16 |ETA: 0:00:02 |loss 3.4031 |hm_loss 2.6093 |wh_loss 5.3395 |off_loss 0.2599 |Data 0.150s(0.153s) |Net 1.947s
ctdet/coco_dla |################################| train: [5][100/101]|Tot: 0:03:16 |ETA: 0:00:02 |loss 3.2957 |hm_loss 2.5137 |wh_loss 5.2178 |off_loss 0.2602 |Data 0.152s(0.153s) |Net 1.945s
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'

@VRCMF Hello, it was normal at the beginning of the training. Why did this problem occur later?

@VRCMF
Copy link

VRCMF commented Jun 22, 2020

@1356789-rr hi, it might be the missing of training images or the incomplete path of training images in .json file. You should check it out.

@1356789-rr
Copy link

@1356789-rr hi, it might be the missing of training images or the incomplete path of training images in .json file. You should check it out.

Hello, take the liberty of asking, is there any path information in JSON file? My dataset is xml to json. The main information is as follows.
{"images": [],
"type": "instances",
"annotations": [],
"categories": []}
My query found that the normal Coco data set is like this.
{"info": [],
 "licenses": [], 
"images": [],
"annotations": [],
"categories":[]}
Is the error related to it?

@VRCMF
Copy link

VRCMF commented Jun 22, 2020

@1356789-rr hi, you could refer the coco format provided by official web. Also, there might be a situation that a image do not exist in the image path of json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants