-
Notifications
You must be signed in to change notification settings - Fork 384
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
RuntimeError: The shape of the mask [1, 1, 128, 128] at index 1 does not match the shape of the indexed tensor [1, 80, 128, 128] at index 1 #28
Comments
I replaced the content of my .data/coco/annotations/instances_{minival2014,trainval2014}.json to my coco style file and replaced the content of my .data/coco/images/{minival2014,trainval2014} to my own images.
} |
@li10141110 How many categories do you have? |
@li10141110 Add these codes above the
|
1 category |
Thank you Kaiwen, I make it |
Did it work with you? I had the same problem but the solution was to edit the categories number in the config file. I am also training with 1 class but I am having problems in the evaluation. I have only 1 class, and it's giving me a "key error 0"
in the db/coco.py file |
In models/CenterNet-104.py, model class definition, the out_dim is hard-coded to 80. For custom datasets with a different out_dim, these need to be changed along with the above-mentioned changes. Just making a note for other users. |
Hi, thank you for your great work. I build a coco style object detection dataset with only one category. According to your project, I rectified CenterNet-104.json file and finally, I was stuck by the following error. I know that the shape of the mask is [1, 1, 128, 128] (my batch_size==1), I don't know how to change it from [1, 80, 128, 128] to [1, 1, 128, 128] accordingly. Any help would be appreciated!
###############################################
/home/imdl/anaconda3/envs/centernet/bin/python /home/imdl/workspace/CenterNet-master_train_custom_dataset/train.py CenterNet-104
loading all datasets...
using 1 threads
loading from cache file: cache/coco_trainval2014.pkl
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading from cache file: cache/coco_minival2014.pkl
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
system config...
{'batch_size': 1,
'cache_dir': 'cache',
'chunk_sizes': [1],
'config_dir': 'config',
'data_dir': '../data',
'data_rng': <mtrand.RandomState object at 0x7f7bf9c02870>,
'dataset': 'MSCOCO',
'decay_rate': 10,
'display': 5,
'learning_rate': 0.00025,
'max_iter': 100000,
'nnet_rng': <mtrand.RandomState object at 0x7f7bf9c028b8>,
'opt_algo': 'adam',
'prefetch_size': 6,
'pretrain': None,
'result_dir': 'results',
'sampling_function': 'kp_detection',
'snapshot': 5000,
'snapshot_name': 'CenterNet-104',
'stepsize': 4500,
'test_split': 'testdev',
'train_split': 'trainval',
'val_iter': 200,
'val_split': 'minival',
'weight_decay': False,
'weight_decay_rate': 1e-05,
'weight_decay_type': 'l2'}
db config...
{'ae_threshold': 0.5,
'border': 128,
'categories': 1,
'data_aug': True,
'gaussian_bump': True,
'gaussian_iou': 0.7,
'gaussian_radius': -1,
'input_size': [511, 511],
'kp_categories': 1,
'lighting': True,
'max_per_image': 100,
'merge_bbox': False,
'nms_algorithm': 'exp_soft_nms',
'nms_kernel': 3,
'nms_threshold': 0.5,
'output_sizes': [[128, 128]],
'rand_color': True,
'rand_crop': True,
'rand_pushes': False,
'rand_samples': False,
'rand_scale_max': 1.4,
'rand_scale_min': 0.6,
'rand_scale_step': 0.1,
'rand_scales': array([0.6, 0.7, 0.8, 0.9, 1. , 1.1, 1.2, 1.3]),
'special_crop': False,
'test_scales': [1],
'top_k': 70,
'weight_exp': 8}
len of db: 1451
start prefetching data...
shuffling indices...
building model...
module_file: models.CenterNet-104
start prefetching data...
shuffling indices...
total parameters: 210062960
setting learning rate to: 0.00025
training start...
0%| | 0/100000 [00:00<?, ?it/s]THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp line=663 error=11 : invalid argument
/home/imdl/anaconda3/envs/centernet/lib/python3.6/site-packages/torch/nn/modules/upsampling.py:122: UserWarning: nn.Upsampling is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.Upsampling is deprecated. Use nn.functional.interpolate instead.")
Traceback (most recent call last):
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/train.py", line 204, in
train(training_dbs, validation_db, args.start_iter)
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/train.py", line 138, in train
training_loss, focal_loss, pull_loss, push_loss, regr_loss = nnet.train(**training)
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/nnet/py_factory.py", line 82, in train
loss_kp = self.network(xs, ys)
File "/home/imdl/anaconda3/envs/centernet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/models/py_utils/data_parallel.py", line 68, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/imdl/anaconda3/envs/centernet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/nnet/py_factory.py", line 21, in forward
loss_kp = self.loss(preds, ys, **kwargs)
File "/home/imdl/anaconda3/envs/centernet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/models/py_utils/kp.py", line 330, in forward
focal_loss += self.focal_loss(tl_heats, gt_tl_heat)
File "/home/imdl/workspace/CenterNet-master_train_custom_dataset/models/py_utils/kp_utils.py", line 180, in _neg_loss
pos_pred = pred[pos_inds]
RuntimeError: The shape of the mask [1, 1, 128, 128] at index 1 does not match the shape of the indexed tensor [1, 80, 128, 128] at index 1
Process finished with exit code 1
The text was updated successfully, but these errors were encountered: