fast and differentiable MS-SSIM and SSIM for pytorch.
Project description
Pytorch MS-SSIM
fast and differentiable MS-SSIM and SSIM for pytorch 1.0+
For faster calculation speed, the 2D convolution (Gaussian Blur) is replaced by two 1D convolutions.
see Gaussian_blur wiki.
All calculations will be on the same device as inputs.
Install
python setup.py install
or
pip install pytorch-msssim
Example
from pytorch_msssim import ssim, ms_ssim, SSIM, MS_SSIM
# X: (N,3,H,W) a batch of RGB images with values ranging from 0 to 255.
# Y: (N,3,H,W)
ssim_val = ssim( X, Y, data_range=255, size_average=False) # return (N,)
ms_ssim_val = ms_ssim( X, Y, data_range=255, size_average=False ) #(N,)
# or set 'size_average=True' to get a scalar value as loss.
ssim_loss = ssim( X, Y, data_range=255, size_average=True) # return scalar value
ms_ssim_loss = ms_ssim( X, Y, data_range=255, size_average=True )
# you can also use MS_SSIM & SSIM classes to reuse windows.
ssim_module = SSIM(win_size=11, win_sigma=1.5, data_range=255, size_average=True, channel=3)
ms_ssim_module = MS_SSIM(win_size=11, win_sigma=1.5, data_range=255, size_average=True, channel=3)
ssim_loss = ssim_module(X, Y)
ms_ssim_loss = ms_ssim_module(X, Y)
Tests
Compared with skimage.measure.compare_ssim on CPU.
The outputs:
Downloading the test image...
====> Single Image
sigma=0.000000 compare_ssim=1.000000 (291.220903 ms) ssim_torch=1.000000 (389.045000 ms)
sigma=1.000000 compare_ssim=0.991319 (302.870035 ms) ssim_torch=0.991312 (463.139057 ms)
sigma=2.000000 compare_ssim=0.966552 (416.693926 ms) ssim_torch=0.966527 (445.262909 ms)
sigma=3.000000 compare_ssim=0.928726 (305.456877 ms) ssim_torch=0.928674 (459.895134 ms)
sigma=4.000000 compare_ssim=0.882462 (303.186893 ms) ssim_torch=0.882380 (354.626179 ms)
sigma=5.000000 compare_ssim=0.831174 (279.859304 ms) ssim_torch=0.831065 (354.197025 ms)
sigma=6.000000 compare_ssim=0.778095 (295.956135 ms) ssim_torch=0.777961 (353.795052 ms)
sigma=7.000000 compare_ssim=0.726729 (304.435015 ms) ssim_torch=0.726576 (354.927063 ms)
sigma=8.000000 compare_ssim=0.677140 (287.097931 ms) ssim_torch=0.676973 (359.275103 ms)
sigma=9.000000 compare_ssim=0.630489 (282.092094 ms) ssim_torch=0.630312 (376.378059 ms)
Pass
====> Batch
Pass
An autoencoder trained with MS_SSIM
left: original image, right: reconstructed image
Reference
https://github.com/jorge-pessoa/pytorch-msssim
https://ece.uwaterloo.ca/~z70wang/research/ssim/
https://ece.uwaterloo.ca/~z70wang/publications/msssim.pdf
Matlab Code
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytorch_msssim-0.1.1.tar.gz.
File metadata
- Download URL: pytorch_msssim-0.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62685d12357c329659a32fdfe98bfcd5227708ac082612bd3c26699cb02eb001
|
|
| MD5 |
dc6ba571164ecbf7c3ceb2a9a919f084
|
|
| BLAKE2b-256 |
f2456cd57ead7a92e729427b639ddafc4226cec0cdcdc4a7da6fd315c645e067
|
File details
Details for the file pytorch_msssim-0.1.1-py3.7.egg.
File metadata
- Download URL: pytorch_msssim-0.1.1-py3.7.egg
- Upload date:
- Size: 8.4 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88034a4c697baf54d52242054999d74f04ab8982890acd9688af640298f2d9d2
|
|
| MD5 |
f6903e5c19122e3042f2479348a14395
|
|
| BLAKE2b-256 |
75324bc715592a725e8ad1efc8b391d77543ebfe0f31ec38aaf9a11042af0cfd
|
File details
Details for the file pytorch_msssim-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pytorch_msssim-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998ff42fceb8906ecff2bbbecc2435e645ace8aa54259efe4311d0ae87256c5d
|
|
| MD5 |
c83f156f4f1ce6f7a7e22dc88d726a7f
|
|
| BLAKE2b-256 |
ea8e7f80fe4c40befa292e80bf0c7e72edbdce0626e6d161d228df0ec16d40c0
|