Replace Mask R-CNN loss function

Hi,
I wanted to test other loss function for Mask R-CNN, so I followed this answer here.

This is what I did as a test:

  • I took maskrcnn_loss, changed the name, and added a print to make sure that everything was ok.
  • I tried to use roi_heads.mask_rcnn_loss = My_Loss
  • And I alsoI tried to use mymodel.roi_heads.mask_rcnn_loss = My_Loss

Unfortunately, in both case, MyLoss was never called (print never executed).

I use TorchVision 0.6.1.

What am I doing wrong?

Is the latest suggestion working for you?

For what I proposed, you would need to do instead
torchvision.models.detection.roi_heads.mask_rcnn_loss = My_Loss
i.e., directly modify what torchvision is using.
Is that what you tried doing?

Unfortunately no :frowning:
See my answer here.

As pointed here, it should not be:

but roi_heads.maskrcnn_loss = My_Loss