Centernet: IndexError: index 2 is out of bounds for axis 0 with size 2

Created on 11 Sep 2019  ·  7Comments  ·  Source: xingyizhou/CenterNet

Most helpful comment

self._valid_ids
should not include 0 (background)

一开始被 https://img-blog.csdnimg.cn/20190828210637735.png
误导了
其实,仿照coco.py 自己建立的aic.py文件中相应部分应该是
self.class_name = [ '__background__', 'car'] self._valid_ids = [ 3]
coco中car对应类别3,aic中一致。
如果把对应背景的0放进_valid_ids,训练时报错。

All 7 comments

/home/asus/anaconda3/envs/CenterNet/bin/python3.6 /home/asus/CenterNet1/src/main.py ctdet --load_model ../models/ctdet_coco_dla_2x.pth
Fix size testing.
training chunk_sizes: [6]
The output will be saved to /home/asus/CenterNet1/exp/ctdet/coco_dla_2x
heads {'hm': 2, '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=6, cat_spec_wh=False, center_thresh=0.1, chunk_sizes=[6], data_dir='/home/asus/CenterNet1/data', dataset='hfut', debug=0, debug_dir='/home/asus/CenterNet1/exp/ctdet/coco_dla_2x/debug', debugger_theme='white', demo='17790319373_bd19b24cfc_k.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/asus/CenterNet1/exp/ctdet', exp_id='coco_dla_2x', fix_res=True, flip=0.5, flip_test=False, gpus=[0], gpus_str='0', head_conv=256, heads={'hm': 2, '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='../models/ctdet_coco_dla_2x.pth', lr=2.5e-05, lr_step=[180, 210], master_batch_size=6, mean=array([[[1.073299, 1.073299, 1.073299]]], 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=2, num_epochs=230, num_iters=-1, num_stacks=1, num_workers=2, 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/asus/CenterNet1/', rot_weight=1, rotate=0, save_all=False, save_dir='/home/asus/CenterNet1/exp/ctdet/coco_dla_2x', scale=0.4, scores_thresh=0.1, seed=317, shift=0.1, std=array([[[1.673852, 1.673852, 1.673852]]], 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 ../models/ctdet_coco_dla_2x.pth, epoch 230
Skip loading parameter hm.2.weight, required shapetorch.Size([2, 256, 1, 1]), loaded shapetorch.Size([80, 256, 1, 1]).
Skip loading parameter hm.2.bias, required shapetorch.Size([2]), loaded shapetorch.Size([80]).
Setting up data...
==> initializing coco 2017 val data.
loading annotations into memory...
Done (t=0.04s)
creating index...
index created!
Loaded val 4000 samples
==> initializing coco 2017 train data.
loading annotations into memory...
Done (t=0.10s)
creating index...
index created!
Loaded train 12000 samples
Starting training...
Traceback (most recent call last):
File "/home/asus/CenterNet1/src/main.py", line 102, in
main(opt)
File "/home/asus/CenterNet1/src/main.py", line 70, in main
log_dict_train, _ = trainer.train(epoch, train_loader)
File "/home/asus/CenterNet1/src/lib/trains/base_trainer.py", line 119, in train
return self.run_epoch('train', epoch, data_loader)
File "/home/asus/CenterNet1/src/lib/trains/base_trainer.py", line 61, in run_epoch
for iter_id, batch in enumerate(data_loader):
File "/home/asus/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/asus/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)
IndexError: Traceback (most recent call last):
File "/home/asus/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/asus/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/asus/CenterNet1/src/lib/datasets/sample/ctdet.py", line 117, in __getitem__
draw_gaussian(hm[cls_id], ct_int, radius)
IndexError: index 2 is out of bounds for axis 0 with size 2

Process finished with exit code 1

Exactly the same question.......

I changed the num_class by adding one,you can try it.

I met the same problem when I trained with a custom dataset. The problem is solved by changing the structure of the dataset. There should be 3 different folders contain your train/Val/test images. You could try to follow the coco format to store your data.

Best,
Neo

I met the same problem when I trained with a custom dataset. The problem is solved by changing the structure of the dataset. There should be 3 different folders contain your train/Val/test images. You could try to follow the coco format to store your data.

Best,
Neo

Actually,can you put an image about your dataset floder?Thanks.

self._valid_ids
should not include 0 (background)

一开始被 https://img-blog.csdnimg.cn/20190828210637735.png
误导了
其实,仿照coco.py 自己建立的aic.py文件中相应部分应该是
self.class_name = [ '__background__', 'car'] self._valid_ids = [ 3]
coco中car对应类别3,aic中一致。
如果把对应背景的0放进_valid_ids,训练时报错。

self._valid_ids
should not include 0 (background)

一开始被 https://img-blog.csdnimg.cn/20190828210637735.png
误导了
其实,仿照coco.py 自己建立的aic.py文件中相应部分应该是
self.class_name = [ '__background__', 'car'] self._valid_ids = [ 3]
coco中car对应类别3,aic中一致。
如果把对应背景的0放进_valid_ids,训练时报错。

Exactly the same question!!!
File "/home/asus/CenterNet1/src/lib/datasets/sample/ctdet.py", line 117, in getitem draw_gaussian(hm[cls_id], ct_int, radius) IndexError: index 4 is out of bounds for axis 0 with size 4
Because I has 4 class (add background is 5)
In your datasets/dataset/hfut.py ,
`
self.class_name = [
'__background__', 'car', 'person', 'others', 'bird'],

self._valid_ids = [  1, 2, 3, 4]

`
attention , self._valid_ids shouldnot has 0 in it
you can find coco.py and pascal.py in this fold . Though there has __background__ in class_name , there hasnot 0 in _valid_ids . so delate 0 in _valid_ids and it soloved.
And all images in same fold , there has three json file . It's OK

完全一样的问题!!!
就是你自己写的datasets/dataset/hfut.py里面self._valid_ids = [ 1, 2, 3, 4]不要加0 你看下旁边的coco.py 和 pascal.py ,虽然类别里有__background__ , 但是_valid_ids 都没加0
然后就正常训练了
json是三个文件,图片我都堆在一个文件夹了,这个没问题的

Was this page helpful?
0 / 5 - 0 ratings