youngwanLEE / CenterMask

[CVPR 2020] CenterMask : Real-Time Anchor-Free Instance Segmentation
https://arxiv.org/abs/1911.06667
Other
770 stars 124 forks source link

Output with shape doesn't match the broadcasting shape #29

Open Eswar1991 opened 4 years ago

Eswar1991 commented 4 years ago

I am performing transfer learning with centermask for my custom dataset. Using the trim_model script, I have reinitialized the following layers: cls_score = nn.Linear(num_inputs, num_classes) bbox_pred = nn.Linear(num_inputs, num_bbox_reg_classes * 4) mask_fcn_logits = nn.Conv2d(dim_reduced, num_classes, 1, 1, 0) cls_logits = nn.Conv2d(dim_reduced, num_classes-1, 3, 3, 0) conv5_mask = nn.ConvTranspose2d(dim_reduced, dim_reduced, 2, 2, 0)

newdict['model']['module.roi_heads.box.predictor.cls_score.weight'] = cls_score.weight newdict['model']['module.roi_heads.box.predictor.cls_score.bias'] = cls_score.bias

newdict['model']['module.roi_heads.maskiou.predictor.maskiou.weight'] = cls_score.weight newdict['model']['module.roi_heads.maskiou.predictor.maskiou.bias'] = cls_score.bias

newdict['model']['module.roi_heads.box.predictor.bbox_pred.weight'] = bbox_pred.weight newdict['model']['module.roi_heads.box.predictor.bbox_pred.bias'] = bbox_pred.bias

newdict['model']['module.roi_heads.mask.predictor.mask_fcn_logits.weight'] = mask_fcn_logits.weight newdict['model']['module.roi_heads.mask.predictor.mask_fcn_logits.bias'] = mask_fcn_logits.bias

newdict['model']['module.rpn.head.cls_logits.weight'] = cls_logits.weight newdict['model']['module.rpn.head.cls_logits.bias'] = cls_logits.bias

newdict['model']['module.roi_heads.mask.predictor.conv5_mask.weight'] = conv5_mask.weight newdict['model']['module.roi_heads.mask.predictor.conv5_mask.bias'] = conv5_mask.bias

After doing these, and on training, I am getting the following error:

Traceback (most recent call last): File "train_net.py", line 189, in main() File "train_net.py", line 182, in main model = train(cfg, args.local_rank, args.distributed) File "train_net.py", line 88, in train arguments, File "F:\Codes\Centermask\CenterMask\maskrcnn_benchmark\engine\trainer.py", line 94, in do_train optimizer.step() File "E:\Anaconda3\envs\centermasktrial2\lib\site-packages\torch\optim\sgd.py", line 107, in step p.data.add(-group['lr'], d_p) RuntimeError: output with shape [1, 256, 3, 3] doesn't match the broadcast shape [80, 256, 3, 3]

I am training for single class detection, but don't know how 80 suddenly popped up. Any help would be appreciated. Thank you