LION.models.CNNs.drunet¶
Classes
|
DRUNet (Zhang et al., 2021): the denoiser of Deep Plug-and-Play Image Restoration, a U-Net of residual blocks over four scales, without biases by default, optionally taking the noise level as an extra input channel. |
|
A residual block of DRUNet: two convolutions with |
Functions
|
A strided convolution that halves the image size (DRUNet's downsampling). |
|
A transposed convolution that doubles the image size (DRUNet's upsampling). |
- class LION.models.CNNs.drunet.DRUNet(model_parameters=None)[source]¶
Bases:
LIONmodelDRUNet (Zhang et al., 2021): the denoiser of Deep Plug-and-Play Image Restoration, a U-Net of residual blocks over four scales, without biases by default, optionally taking the noise level as an extra input channel. Takes images.
model_parameters(default_parameters()):in_channels,out_channels: 1, 1;int_channels: the first scale’s channels, doubled at each scale (64);kernel_size: 3x3;n_blocks: residual blocks per scale (4);use_noise_level: the noise level as an input channel, as in the paper (False);bias_free: no biases (True);act: atorch.nn.functionalactivation (“leaky_relu”);enforce_positivity: a ReLU on the output (False).
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- static default_parameters()[source]¶
The paper’s architecture (64 channels, 4 residual blocks per scale, no biases), without the noise level input by default (see the class).
- classmethod pretrained(verbose=1)[source]¶
The authors’ trained grayscale DRUNet (
drunet_gray.pth, from their KAIR repository): trained on natural images in [0, 1] with Gaussian noise levels up to 50/255, given as the noise level input. Their architecture is this one withact="relu"anduse_noise_level=True.The weights (130 MB) are downloaded once into torch’s hub cache (
torch.hub.get_dir()) and checked against their hash;verbose(1) shows the download’s progress. The model is on LION’s device. Give it images in [0, 1] (e.g.set_normalisation) and noise levels in those units.
- class LION.models.CNNs.drunet.ResBlock(n_channels=64, kernel_size=(3, 3), bias_free=True, act=<function leaky_relu>)[source]¶
Bases:
ModuleA residual block of DRUNet: two convolutions with
actbetween them, added to the input.Initialize internal Module state, shared by both nn.Module and ScriptModule.