.. _pretrained-models: Pretrained Models ================= Pretrained reconstructors ~~~~~~~~~~~~~~~~~~~~~~~~~ Some methods do not require any training and can be quickly deployed to your problem. .. seealso:: See the example :ref:`sphx_glr_auto_examples_basics_demo_pretrained_model.py` for how to get started with these models on various problems. These models can be set-up in one line and perform inference in another line: .. doctest:: >>> import deepinv as dinv >>> x = dinv.utils.load_example("butterfly.png") >>> physics = dinv.physics.Downsampling() >>> y = physics(x) >>> model = dinv.models.RAM(pretrained=True) # or any of the models listed below >>> x_hat = model(y, physics) # Model inference >>> dinv.metric.PSNR()(x_hat, x) tensor([22.9831]) .. list-table:: Pretrained reconstructors :header-rows: 1 * - **Name** - **Family** - **Modality/Physics** - **Speed** * - :class:`RAM ` - Feedforward - General; physics must be linear - Fast * - :class:`DPIR ` - :ref:`Plug-and-play ` w/ pretrained denoiser - General - Medium * - :class:`DDRM ` - :ref:`Diffusion ` w/ pretrained denoiser - General; physics must be decomposable - Slow * - :class:`DiffPIR ` - :ref:`Diffusion ` w/ pretrained denoiser - General - Slow * - :class:`DPS ` - :ref:`Diffusion ` w/ pretrained denoiser - General - Slow * - :ref:`Pretrained denoisers ` - Feedforward - Denoising - Fast .. tip:: If you want to fine-tune these models on your own measurements (without or with ground truth) or physics, check out :ref:`sphx_glr_auto_examples_models_demo_foundation_model.py`. .. seealso:: See below for a full list of denoisers that can be plugged into iterative/sampling algorithms. .. _pretrained-weights: Description of weights ~~~~~~~~~~~~~~~~~~~~~~ For each model (:class:`Denoiser ` or :class:`Reconstructor `) that has pretrained weights, we briefly summarize the origin of the weights, associated reference and relevant details. All pretrained weights are hosted on `HuggingFace `_. Click on the model name to learn more about the type of model and use `pretrained=True` to use the pretrained weights. .. list-table:: Summary of pretrained weights :widths: 20 5 25 :header-rows: 1 * - Model - Type - Weight * - :class:`deepinv.models.DnCNN` - Denoiser - Default weights from `Learning Maximally Monotone Operators `_ trained on noise level 2.0/255: `DnCNN grayscale weights `_, `DnCNN color weights `_. * - - - Alternative weights trained on noise level 2.0/255 with Lipschitz constraint to ensure approximate firm nonexpansiveness: `Non-expansive DnCNN grayscale weights `_, `Non-expansive DnCNN color weights `_. * - :class:`deepinv.models.DRUNet` - Denoiser - Default weights trained with deepinv `(logs) `_, trained on noise levels in [0, 20]/255 and on the same dataset as DPIR: `DRUNet grayscale weights `_, `DRUNet color weights `_. * - - - Alternative weights from `DPIR `_, trained on noise levels in [0, 50]/255. `DRUNet original grayscale weights `_, `DRUNET original color weights `_. * - :class:`deepinv.models.GSDRUNet` - Denoiser - Weights from `Gradient-Step PnP `_, trained on noise levels in [0, 50]/255: `GSDRUNet color weights `_ and `GSDRUNet grayscale weights `_. * - :class:`deepinv.models.SCUNet` - Denoiser - Weights from `SCUNet `_, trained on images degraded with synthetic realistic noise and camera artefacts. `SCUNet color weights `_. * - :class:`deepinv.models.SwinIR` - Denoiser - Weights from `SwinIR `_, trained on various noise levels levels in {15, 25, 50}/255, in color and grayscale. The weights are automatically downloaded from the authors' `project page `_. * - :class:`deepinv.models.DiffUNet` - Denoiser - Default weights from `Ho et al. `_ trained on FFHQ (128 hidden channels per layer): `DiffUNet weights `_. * - - - Alternative weights from `Dhariwal and Nichol `_ trained on ImageNet128 (256 hidden channels per layer): `DiffUNet OpenAI weights `_. * - :class:`deepinv.models.EPLLDenoiser` - Denoiser - Weights estimated with deepinv on 50 mio patches from the training/validation images from BSDS500 for grayscale and color images. Code for generating the weights for the example :ref:`patch-prior-demo` is contained within the demo. * - :class:`deepinv.models.Restormer` - Denoiser - Weights from `Restormer: Efficient Transformer for High-Resolution Image Restoration `_: `Restormer weights `_, also available on the `deepinverse Restormer HuggingfaceHub `_. * - :class:`deepinv.models.RAM` - Reconstructor & Denoiser - Weights from `Terris et al. `_ :footcite:p:`terris2025reconstruct`. Pretrained weights from `RAM HuggingfaceHub `_.