DnCNN#
- class deepinv.models.DnCNN(in_channels=3, out_channels=3, depth=20, bias=True, nf=64, pretrained='download', pretrained_2d_isotropic=False, device='cpu', dim=2)[source]#
Bases:
DenoiserDnCNN convolutional denoiser.
The architecture was introduced by Zhang et al.[1] and is composed of a series of convolutional layers with ReLU activation functions. The number of layers can be specified by the user. Unlike the original paper, this implementation does not include batch normalization layers.
The network can be initialized with pretrained weights, which can be downloaded from an online repository. The pretrained weights are trained with the default parameters of the network, i.e. 20 layers, 64 channels and biases.
- Parameters:
in_channels (int) β input image channels
out_channels (int) β output image channels
depth (int) β number of convolutional layers
bias (bool) β use bias in the convolutional layers
nf (int) β number of channels per convolutional layer
pretrained (str, None) β use a pretrained network. If
pretrained=None, the weights will be initialized at random using Pytorchβs default initialization. Ifpretrained='download', the weights will be downloaded from an online repository (only available for architecture with depth 20, 64 channels and biases). It is possible to download weights trained via the regularization method in Pesquet et al.[2], usingpretrained='download_lipschitz'. When building a 3D network, it is possible to initialize with 2D pretrained weights by usingpretrained='download_2d'orpretrained='download_lipschitz_2d', which provides a good starting point for fine-tuning. Finally,pretrainedcan also be set as a path to the userβs own pretrained weights. See pretrained-weights for more details.pretrained_2d_isotropic (bool) β when loading 2D pretrained weights into a 3D network, whether to initialize the 3D kernels isotropically. By default the weights are loaded axially, i.e., by initializing the central slice of the 3D kernels with the 2D weights.
device (torch.device, str) β Device to put the model on.
dim (str, int) β Whether to build 2D or 3D network (if str, can be β2β, β2dβ, β3Dβ, etc.)
- References:
- forward(x, sigma=None)[source]#
Run the denoiser on noisy image. The noise level is not used in this denoiser.
- Parameters:
x (torch.Tensor) β noisy image
sigma (float) β noise level (not used)
Note
The argument
sigmais included for compatibility with the base classDenoiserbut is not used in this model.
Examples using DnCNN:#
Pattern Ordering in a Compressive Single Pixel Camera
PnP with custom optimization algorithm (Primal-Dual Condat-Vu)
Plug-and-Play algorithm with Mirror Descent for Poisson noise inverse problems.
Deep Equilibrium (DEQ) algorithms for image deblurring
Reducing the memory and computational complexity of unfolded network training