.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/patch-priors/demo_epll.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_patch-priors_demo_epll.py: Expected Patch Log Likelihood (EPLL) for Denoising and Inpainting ==================================================================================================== In this example we use the expected patch log likelihood (EPLL) prior EPLL proposed in `"From learning models of natural image patches to whole image restoration" `_. for denoising and inpainting of natural images. To this end, we consider the inverse problem :math:`y = Ax+\epsilon`, where :math:`A` is either the identity (for denoising) or a masking operator (for inpainting) and :math:`\epsilon\sim\mathcal{N}(0,\sigma^2 I)` is white Gaussian noise with standard deviation :math:`\sigma`. .. GENERATED FROM PYTHON SOURCE LINES 10-20 .. code-block:: Python import torch from deepinv.optim import EPLL from deepinv.physics import GaussianNoise, Denoising, Inpainting from deepinv.loss.metric import PSNR from deepinv.utils import plot from deepinv.utils.demo import load_url_image, get_image_url device = "cuda" if torch.cuda.is_available() else "cpu" .. GENERATED FROM PYTHON SOURCE LINES 21-26 Load test image and model ---------------------------------------- As default EPLL loads pretrained weights for the Gaussian mixture model which where estimted based on 50 mio patches extracted from the BSDS500 dataset. An example how to estimate the parameters of GMM is included in the demo for limited-angle CT with patch priors. .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: Python url = get_image_url("CBSD_0010.png") test_img = load_url_image(url, grayscale=False).to(device) patch_size = 6 model = EPLL(channels=test_img.shape[1], patch_size=patch_size, device=device) .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading: "https://huggingface.co/deepinv/EPLL/resolve/main/GMM_BSDS_color2.pt?download=true" to /home/runner/.cache/torch/hub/checkpoints/GMM_BSDS_color2.pt 0%| | 0.00/35.7M [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_epll.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demo_epll.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_