You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to finetune the model when changing the NUM_CLASSES?
Maybe you need do like this to delete the last layer for the .pth model
_d=torch.load(path)
newdict=_d
def removekey(d, listofkeys):
r=d
for key in listofkeys:
del r[key]
return r
newdict['model'] = removekey(_d['model'], ['module.roi_heads.box.predictor.cls_score.bias','module.roi_heads.box.predictor.cls_score.weight','module.roi_heads.box.predictor.bbox_pred.bias','module.roi_heads.box.predictor.bbox_pred.weight','module.roi_heads.mask.predictor.mask_fcn_logits.weight','module.roi_heads.mask.predictor.mask_fcn_logits.bias'])
torch.save(newdict, 'mymodel.pth')
How to finetune the model when changing the NUM_CLASSES?
The text was updated successfully, but these errors were encountered: