--- id: pytorch-msssim version: "1.0.0" license: unclear license_treatment: permissive maintenance: dormant --- # pytorch-msssim — Fast and differentiable MS-SSIM and SSIM for pytorch. License: permissive · Maintenance: dormant · Downloads: 300.9K/mo ## 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 above — 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 pip install pytorch-msssim uv add pytorch-msssim 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: unspecified - Install friction: low - Maintenance: dormant - Downloads: 300.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags image similarity metric pytorch, ssim ms-ssim differentiable, perceptual loss function, image quality assessment, structural similarity pytorch, neural network image loss, image-metrics, loss-functions, computer-vision [View on SkillFed](https://skillfed.io/packages/pytorch-msssim) · [View on PyPI](https://pypi.org/project/pytorch-msssim/)