/pytorch-msssim

PyTorch differentiable Multi-Scale Structural Similarity (MS-SSIM) loss

Primary LanguagePythonOtherNOASSERTION

pytorch-msssim

Differentiable Multi-Scale Structural Similarity (SSIM) index

This small utiliy provides a differentiable MS-SSIM implementation for PyTorch based on Po Hsun Su's implementation of SSIM @ https://github.com/Po-Hsun-Su/pytorch-ssim. At the moment only a direct method is supported.

Installation

  1. Clone this repo.
  2. Copy "pytorch_msssim" folder in your project.

Example

basic usage

import pytorch_ssim
import torch
from torch.autograd import Variable

img1 = Variable(torch.rand(1, 1, 256, 256))
img2 = Variable(torch.rand(1, 1, 256, 256))

if torch.cuda.is_available():
    img1 = img1.cuda()
    img2 = img2.cuda()

print(pytorch_msssim.msssim(img1, img2))

Reference

https://ece.uwaterloo.ca/~z70wang/research/ssim/ https://github.com/Po-Hsun-Su/pytorch-ssim