mr2.nn.nets.Restormer
- class mr2.nn.nets.Restormer[source]
Bases:
UNetBaseRestormer architecture.
Implements the Restormer [ZAM22] network, which is a U-shaped transformer with channel wise attention and depthwise convolutions in the feed forward network.
References
[ZAM22]Zamir, Syed Waqas, et al. “Restormer: Efficient transformer for high-resolution image restoration.” CVPR 2022, https://arxiv.org/pdf/2111.09881.pdf
- __init__(n_dim: int, n_channels_in: int, n_channels_out: int, n_blocks: Sequence[int] = (4, 6, 6, 8), n_refinement_blocks: int = 4, n_heads: Sequence[int] = (1, 2, 4, 8), n_channels_per_head: int = 48, mlp_ratio: float = 2.66, cond_dim: int = 0)[source]
Initialize Restormer.
- Parameters:
n_dim (
int) – The number of spatial dimensions of the input tensor.n_channels_in (
int) – The number of input channels.n_channels_out (
int) – The number of output channels.n_blocks (
Sequence[int], default:(4, 6, 6, 8)) – Number of blocks in each stagen_refinement_blocks (
int, default:4) – Number of refinement blocksn_heads (
Sequence[int], default:(1, 2, 4, 8)) – Number of attention heads in each stagen_channels_per_head (
int, default:48) – Number of channels per attention headmlp_ratio (
float, default:2.66) – Ratio for hidden dimension expansioncond_dim (
int, default:0) – Dimension of conditioning input. If 0, no conditioning is applied.
- encoder
The encoder.
- decoder
The decoder.
- skip_blocks
Modifications of the skip connections.