skillfed

pytorch-msssim

Fast and differentiable MS-SSIM and SSIM for pytorch.

pytorch-msssim v1.0.0 300.9K downloads/30d#7,840 on PyPI1,252
Permissive license DORMANT released

What it is and what it does

pytorch-msssim provides PyTorch implementations of SSIM (Structural Similarity Index) and MS-SSIM (Multi-Scale SSIM), two perceptual image quality metrics commonly used to measure similarity between images. Unlike naive implementations, it uses separable Gaussian kernels—decomposing 2D convolutions into two 1D operations—which reduces computational complexity and improves cache locality, making it significantly faster than alternatives like TensorFlow or scikit-image while remaining fully differentiable for use as a loss function in neural networks.

The package is typically used in image generation, reconstruction, and compression tasks where pixel-level losses (like L2) are inadequate. You can call ssim() and ms_ssim() as functions for one-off computations, or instantiate SSIM and MS_SSIM modules to reuse Gaussian kernels across multiple forward passes. It handles both single images and batches, supports grayscale and RGB, and includes 3D image support; inputs must be denormalized to a known range (e.g., [0, 255] or [0, 1]) for correct results.

Use it for:

  • Use as a loss function in autoencoders or image-to-image translation networks (e.g., super-resolution, denoising).
  • Evaluate image generation quality in GANs or diffusion models by computing MS-SSIM between generated and reference images.
  • Benchmark image compression algorithms by measuring perceptual similarity before and after compression.
  • Monitor image reconstruction fidelity in medical imaging or scientific applications where structural detail matters more than pixel values.
  • Compare image quality across different preprocessing or augmentation pipelines in computer vision workflows.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes fast, differentiable SSIM and MS-SSIM metrics for PyTorch tensors using separable Gaussian kernels, enabling efficient image quality assessment and loss functions for neural networks.

Yes, if you need a fast, differentiable SSIM/MS-SSIM implementation for PyTorch. The low install friction, permissive license, and proven performance (benchmarked against TensorFlow and scikit-image) make it a solid choice for image quality assessment and loss functions. Dormant maintenance is a minor concern—the core algorithm is stable and unlikely to need updates, but expect no active support for new PyTorch or Python versions.

Install

pytorch-msssim on PyPI

pip

pip install pytorch-msssim

uv

uv add pytorch-msssim

poetry

poetry add pytorch-msssim

Installing pytorch-msssim

Before you install

Low friction: pure Python wheel with only torch as a runtime dependency. Maintenance is dormant (last release 2023-05-25, last commit 2024-03-12), so expect no active bug fixes or feature updates, though the core algorithm is stable.

License in practice

MIT license (permissive) allows commercial and private use with minimal restrictions—suitable for most projects.

Quickstart

pip install pytorch-msssim

from pytorch_msssim import ssim, ms_ssim
# X, Y: (N,3,H,W) batches of images in range [0, 255]
ssim_val = ssim(X, Y, data_range=255, size_average=False)
ms_ssim_val = ms_ssim(X, Y, data_range=255, size_average=False)

Requires torch to be installed; input images must be in a known numeric range (e.g., [0, 255] or [0, 1]) and denormalized if needed.

Verify before relying

  • Whether the package supports modern PyTorch versions and recent Python releases (requires_python is unspecified).
  • Performance characteristics on GPU vs. CPU and with different image sizes or batch dimensions.
  • Compatibility with 3D images beyond the 2020.08.21 update note.

Package facts

License not declared (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — torch
Maintenance dormant — 1,177 days since the last release
Last repo commit
First released
Downloads 300,858/month — #7,840 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytorch_msssim-1.0.0-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

image similarity metric pytorchssim ms-ssim differentiableperceptual loss functionimage quality assessmentstructural similarity pytorchneural network image loss
image-metricsloss-functionscomputer-vision

More Artificial Intelligence packages

Further reading