Creating a custom Image Similarity Loss Function

Hi,
I am relatively new to FastAI and was wondering whether the FastAI library has got a Loss Function that scores two images based on how structurally similar they are. I could not find anything like this in the documentation so I am thinking that such a loss function might not be implemented. Therefore my next question would be to try and ask for guidance on how to create a custom loss function. I am looking at implementing something like the Structural Similarity Index by Wang et al . Any pointers as to how to I can add to the code to include this custom loss function would be much appreciated. Thank you.

The closest task that I am aware of is identifying if two images are of the same class using Siamese Network. But this uses a traditional loss function such as Cross entropy loss flat.

Any pointers as to how to I can add to the code to include this custom loss function would be much appreciated.

The following has an example on how to incorporate your own loss function as part of creating a Learner instance.

The setup from “Perceptual Losses for Real-Time Style Transfer and Super-Resolution” could be also interesting for that.

Thank you for your pointer and comments Manikandan … will follow up.

Thank you Michael … will have a close look at this.

No problem. This topic is definitely interesting. Please share your progress when you feel comfortable.