This repository contains an implementation of EPLL and the implementation for the work Posterior Sampling for Image Restoration using Explicit Patch Priors in PyTorch.
Expected Patch Log-Likelihood (EPLL) is a well established image decorruption algorithm. EPLL uses a patch-denoiser in order to restore full images, using the Half-Quadratic Splitting algorithm. The original paper uses a Gaussian mixture model (GMM) in order to denoise patches, but in principal any patch-denoiser can be used. This implementation allows for any patch denoiser to be used in order to restore images.
denoise_demo.py
shows how to denoise an image using the EPLL algorithm. Running it should produce the
following images:
The first image is the noisy version and the second one is the denoised version, specifically under noise with
This implementation follows the terminology of Posterior Sampling for Image Restoration using Explicit Patch Priors, which interprets the EPLL-loss as a loss of grids of the image. This allows for easily running faster versions of the same EPLL algorithm (using less grids), albeit at a slight cost of accuracy. For instance, the above images were produced using 16 grids, which takes ~5.2 seconds (with a GPU), while running on the same task with 4 grids takes ~1.3 seconds.
EPLL is widely known not for denoising, but for general image restorations. This implementation allows for that as well!
deblur_demo.py
shows how to deblur an image using this implementations and should produce the following images:
Crucially, this implementation uses automatic differentiation in order to decorrupt images. Any corruption process EPLL.decorrupt
.
While a GMM is commonly used for EPLL, essentially any other patch-prior can be used. Specifically, all that is needed is a class with a function
denoise
which receives batches of patches as well as the noise variance and returns the denoised patches.