I’ve two models (based on faster_rcnn from torchvision). I want to replace the weights of roi_head in model 2 with that of model 1’s.
My dict keys from model 1 has these keys:
'roi_heads.box_head.fc6.weight' 'roi_heads.box_head.fc6.bias' 'roi_heads.box_head.fc7.weight' 'roi_heads.box_head.fc7.bias' 'roi_heads.box_predictor.cls_score.weight' 'roi_heads.box_predictor.cls_score.bias' 'roi_heads.box_predictor.bbox_pred.weight' 'roi_heads.box_predictor.bbox_pred.bias'
Here’s my model 1
ckpt = torch.load('saved_models/model1.pth') model = get_model(15) model.load_state_dict(ckpt['model'])
Model 2 is identical but roi_heads is different.How can I load weights of roi_heads (from model 1) to my model 2’s roi_head ?