pytorch / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://pytorch.org
Other
82.02k stars 21.99k forks source link

Add SSIM as Loss Function #97788

Open bluehyena opened 1 year ago

bluehyena commented 1 year ago

🚀 The feature, motivation and pitch

Hello, I am doing research in the field of Unsupervised Anomaly Detection. In Unsupervised Anomaly Detection, you can segment an anomaly area through Reconstruction Error, but in the case of areas with ambiguous boundaries, better performance is shown when using loss using SSIM than using existing losses. Therefore, I would like to be able to use SSIM as the loss function of pytorch. Thank you :)

Alternatives

No response

Additional context

No response

janeyx99 commented 1 year ago

Thanks for raising this up! PyTorch Core has some pretty strict rules when it comes to adding a new Optimizer or Module function or feature: https://github.com/pytorch/pytorch/wiki/Developer-FAQ#i-have-a-new-function-or-feature-id-like-to-add-to-pytorch-should-it-be-in-pytorch-core-or-a-library-like-torchvision.

Currently, SSIM seems best suited to be implemented in a separate library (or using an existing one), and for the future, we'll happily reconsider if this function increases in popularity. We can leave this issue open to gauge popularity among other researchers and users.