Paper · 2024-02-23 · cs.CV
MambaIR: A Simple Baseline for Image Restoration with State-Space Model
Image restoration backbone that replaces window attention with a four-direction Mamba scan (VSSM), adding a conv bottleneck with channel attention and learnable skip scales in each block. Author-reported: beats SwinIR on classic SR (e.g. +0.41 dB Manga109 x2), lightweight SR and Gaussian color denoising (+0.48 dB Urban100, sigma 50); close to Restormer on real denoising.
State-space model (SSM)Image super-resolutionImage denoisingChannel attentionimage-restorationsuper-resolutiondenoisingmambastate-space-modellow-level-vision
arXivPDFCodeMarkdown15 min read
AI-compiled by claude-opus-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Image restoration means taking a damaged picture (too small, noisy, blurry) and producing a clean one. A good restorer looks at many pixels when it rebuilds each output pixel. Convolutional networks only look at a small neighbourhood. Transformers could look at the whole image, but comparing every pixel with every other pixel gets too expensive, so restoration transformers such as SwinIR only attend inside small windows.
MambaIR swaps the attention for Mamba, a "state-space model". Think of it as a reader that walks along a sequence once and keeps a running memory, so the cost grows linearly with the number of pixels while information can still travel across the whole image. Because an image is 2D, the feature map is unrolled into four 1D sequences (row by row, column by column, and both backwards), each one is scanned, and the results are added.
Unrolling an image puts some neighbouring pixels far apart in the sequence, and Mamba's large memory leaves many channels unused. The authors patch both problems with plain tools: a small convolution after the scan to bring back local detail, and a channel-attention gate that reweights channels. On super-resolution and denoising benchmarks the result matches or beats SwinIR at similar compute, by the authors' own numbers.
TL;DR
MambaIR is a SwinIR-shaped restoration network (shallow 3×3 conv → stacked
residual groups → reconstruction head) whose core block, the RSSB, is
LN → VSSM (4-direction selective scan) + scaled skip followed by
LN → conv bottleneck → channel attention + scaled skip. It targets classic,
lightweight and real-world SR, Gaussian color denoising, real denoising and
JPEG artifact removal. Author-reported gains over SwinIR are up to 0.45 dB on SR
at similar cost. The paper leaves most architecture sizes unstated; they are
only in the official code (Apache-2.0), which also differs from the paper in
a few training details (see Paper vs code).
Problem
Restoration quality tends to improve with receptive field, but CNN backbones have a small effective receptive field, and Transformers either pay quadratic cost in the number of pixels or restrict attention to shifted windows, which loses the global receptive field §1 fig. 1. Mamba offers linear-cost long-range modelling, but it was built for causal 1D sequences: flattening an image separates spatially adjacent pixels ("local pixel forgetting"), and the large hidden state leads to many inactive channels ("channel redundancy") §1 §3.3 fig. 3.
Method
Three stages §3.2 fig. 2:
- Shallow features: a 3×3 conv maps
I_LQ ∈ R^{H×W×3}toF_S ∈ R^{H×W×C}§3.2. - Deep features: several Residual State-Space Groups (RSSGs), each a stack
of RSSBs followed by a conv; then
F_R = F_D^L + F_S§3.2. In code each RSSG also has its own residual connection, and a LayerNorm plus a 3×3 conv follow the last group mambair_arch.py mambair_arch.py. - Reconstruction: produces
I_HQfromF_R§3.2. In code: conv + LeakyReLU + pixel-shuffle upsampler + conv for classic SR; a single conv + pixel shuffle for lightweight SR; and for denoising a conv whose output is added to the input image mambair_arch.py mambair_arch.py.
SSM background §3.1. Continuous system eq. 1:
h'(t) = \mathbf{A}h(t) + \mathbf{B}x(t), \quad y(t) = \mathbf{C}h(t) + \mathbf{D}x(t)
with state size N, A ∈ R^{N×N}, B ∈ R^{N×1}, C ∈ R^{1×N}, D ∈ R.
Zero-order-hold discretization as printed in the paper eq. 2:
\overline{\mathbf{A}} = \exp(\Delta\mathbf{A}), \quad \overline{\mathbf{B}} = (\Delta\mathbf{A})^{-1}(\exp(\mathbf{A}) - \mathbf{I})\cdot\Delta\mathbf{B}
Recurrent form eq. 3:
h_k = \overline{\mathbf{A}}h_{k-1} + \overline{\mathbf{B}}x_k, \quad y_k = \mathbf{C}h_k + \mathbf{D}x_k
Equivalent convolutional form over a length-L sequence eq. 4:
\overline{\mathbf{K}} \triangleq (\mathbf{C}\overline{\mathbf{B}}, \mathbf{C}\overline{\mathbf{A}}\overline{\mathbf{B}}, \dots, \mathbf{C}\overline{\mathbf{A}}^{L-1}\overline{\mathbf{B}}), \quad \mathbf{y} = \mathbf{x} \circledast \overline{\mathbf{K}}
Mamba makes B̄, C and Δ input-dependent §3.1.
Residual State-Space Block (RSSB) §3.3 fig. 2a, with learnable
per-channel scales s, s' ∈ R^C:
Z^l = \mathrm{VSSM}(\mathrm{LN}(F_D^l)) + s \cdot F_D^l eq. 5
F_D^{l+1} = \mathrm{CA}(\mathrm{Conv}(\mathrm{LN}(Z^l))) + s' \cdot Z^l eq. 6
Conv is a bottleneck that compresses channels by a factor γ to C/γ and
expands back §3.3. CA is squeeze-and-excitation channel attention §3.3.
Vision State-Space Module (VSSM) §3.4 fig. 2b, following VMamba, with channel expansion factor λ eq. 7:
X_1 = \mathrm{LN}(\text{2D-SSM}(\mathrm{SiLU}(\mathrm{DWConv}(\mathrm{Linear}(X))))) X_2 = \mathrm{SiLU}(\mathrm{Linear}(X)), \quad X_{out} = \mathrm{Linear}(X_1 \odot X_2)
2D Selective Scan (2D-SSM) §3.5 fig. 2c: flatten the feature map into four sequences, run the selective scan on each, sum the four outputs and reshape back to 2D.
# MambaIR forward pass (classic SR head), shapes for one image
# Input: low_quality (B, 3, H, W); output: (B, 3, s*H, s*W)
def mambair(low_quality):
# subtract the fixed DIV2K RGB mean
# [code: basicsr/archs/mambair_arch.py#L541-L545]
x = low_quality - rgb_mean
# shallow 3x3 conv to C channels [§3.2]
shallow = conv3x3(x, out=C) # (B, C, H, W)
# tokens = pixels, LayerNorm after embedding
# [code: basicsr/archs/mambair_arch.py#L560-L565]
tokens = layer_norm(flatten_hw(shallow)) # (B, H*W, C)
for group in groups:
group_input = tokens
for block in group.blocks:
tokens = rssb(block, tokens, H, W)
# per-group conv and residual
# [§3.2] [code: basicsr/archs/mambair_arch.py#L765-L766]
grid = unflatten(tokens)
tokens = flatten_hw(group.conv3x3(grid)) + group_input
# final norm and conv, then the long skip F_R = F_D + F_S [§3.2]
deep = conv3x3(unflatten(layer_norm(tokens)))
features = deep + shallow
# conv + LeakyReLU, pixel-shuffle upsampling, conv to RGB
# [code: basicsr/archs/mambair_arch.py#L615-L620]
out = conv_last(upsample(leaky_relu(conv3x3(features, out=64))))
return out + rgb_mean
def rssb(block, tokens, H, W):
x = reshape(tokens, (B, H, W, C))
# global branch with scaled skip [eq. 5]
z = vssm(block, layer_norm(x)) + block.s * x
# local branch: conv bottleneck then channel attention [eq. 6]
local = channel_attention(conv_bottleneck(layer_norm(z)))
return flatten(local + block.s_prime * z)
def vssm(block, x): # x (B, H, W, C)
# one linear gives both branches, each lambda*C wide
# [eq. 7] [code: basicsr/archs/mambair_arch.py#L374-L375]
branch_ssm, gate = split(linear(x, out=2 * lam * C))
# depthwise 3x3 conv + SiLU
# [eq. 7] [code: basicsr/archs/mambair_arch.py#L377-L378]
branch_ssm = silu(depthwise_conv3x3(branch_ssm))
# four-direction selective scan, outputs summed [§3.5]
y = sum(selective_scan_2d(branch_ssm))
# LayerNorm, gate with SiLU, project back to C [eq. 7]
return linear(layer_norm(y) * silu(gate), out=C)
def selective_scan_2d(feature): # (B, D, H, W)
# row-major, column-major, and both reversed
# [code: basicsr/archs/mambair_arch.py#L343-L344]
rows = flatten_row_major(feature)
cols = flatten_column_major(feature)
sequences = [rows, cols, reverse(rows), reverse(cols)]
# separate dt/B/C projections, A and D per direction
# [code: basicsr/archs/mambair_arch.py#L346-L362]
outputs = []
for direction, sequence in enumerate(sequences):
outputs.append(mamba_scan(sequence, params[direction]))
# undo reversal and transpose so all four align row-major
# [code: basicsr/archs/mambair_arch.py#L365-L369]
return realign(outputs)The bottleneck and channel attention in the classic and denoising models are
conv3x3(C→C/3) → GELU → conv3x3(C/3→C) → CA, with CA =
avgpool → 1×1 conv (C→C/30) → ReLU → 1×1 conv → sigmoid → multiply
mambair_arch.py mambair_arch.py.
Loss §3.6: L1 for SR eq. 8; Charbonnier with ε = 1e-3 for denoising eq. 9:
\mathcal{L} = \|I_{HQ} - I_{LQ}\|_1 \qquad \mathcal{L} = \sqrt{\|I_{HQ} - I_{LQ}\|^2 + \epsilon^2}
(As printed; the target should be the ground truth, see Pitfalls.)
Hyperparameters
Paper-stated values:
| Name | Value | Where | Notes |
|---|---|---|---|
| optimizer | Adam, β1 = 0.9, β2 = 0.999 | §4.1 | code uses β2 = 0.99 |
| initial learning rate | 2e-4, halved at milestones | §4.1 | milestones not stated in paper |
| batch size | 32 (SR), 16 (denoising) | §4.1 | |
| training patch | 64×64 (SR), 128×128 (denoising) | §4.1 | for SR, LR size per code (see Paper vs code) |
| augmentation | horizontal flip, rotations 90/180/270° | §4.1 | |
| ×3, ×4 SR init | from ×2 weights; LR and iterations halved | §4.1 | |
| Charbonnier ε | 1e-3 | §3.6 | code applies it unsquared |
| hardware | 8× NVIDIA V100 | §4.1 | |
| C, number of RSSGs/RSSBs, N, λ, γ | not stated | only in code | |
| total iterations, schedule | not stated | only in code | |
| real denoising | progressive training following Restormer | §4.4 | details not stated |
| real-world SR | training protocol of HAT | §4.3 | details not stated; no config in repo |
| test-time | MambaIR+ = self-ensemble | §4.1 |
From the official code (not stated in the paper):
| Name | Classic SR | Lightweight SR | Color denoising | Where |
|---|---|---|---|---|
| embed dim C | 180 | 60 | 180 | train_MambaIR_SR_x2.yml train_MambaIR_lightSR_x2.yml train_MambaIR_ColorDN_level15.yml |
| RSSGs × RSSBs | 6 × 6 | 4 × 6 | 6 × 6 | same |
state size N (d_state) | 16 | 10 | 16 | same |
expansion λ (mlp_ratio) | 2 | 1.2 | 1.2 | same |
| bottleneck γ | 3 | 2 | 3 | mambair_arch.py |
| CA squeeze factor | 30 | 30 | 30 | mambair_arch.py |
| depthwise conv kernel | 3 | 3 | 3 | mambair_arch.py |
| Δ rank | ceil(C/16) | ceil(C/16) | ceil(C/16) | mambair_arch.py |
| Δ init range | [0.001, 0.1], floor 1e-4 | same | same | mambair_arch.py |
| A init | S4D-real: A = −[1..N] per channel (stored as log) | same | same | mambair_arch.py |
| D init, skip scales s, s' init | ones | same | same | mambair_arch.py mambair_arch.py |
| stochastic depth | linear 0 → 0.1 | same | same | mambair_arch.py mambair_arch.py |
| upsampler | pixelshuffle | pixelshuffledirect | none | configs above |
| GPUs × batch/GPU | 8 × 4 | 2 × 16 | 8 × 2 | configs above |
HR crop (gt_size) | 128 (×2), 192 (×3, ×4) | 128 (×2), 192 (×3, ×4) | 128 | train_MambaIR_SR_x4.yml |
| LR, iterations (×2 / σ15) | 2e-4, 500k, halve at 250k/400k/450k/475k | 2e-4, 500k, same | 2e-4, 1.6M, halve at 800k/1.2M/1.4M/1.5M | train_MambaIR_SR_x2.yml train_MambaIR_ColorDN_level15.yml |
| LR, iterations (×3, ×4 / σ25, σ50) | 1e-4, 250k, halve at 125k/200k/225k/237.5k | 2e-4, 500k (not halved) | 1e-4, 800k, halve at 400k/600k/700k/750k | train_MambaIR_SR_x4.yml train_MambaIR_lightSR_x4.yml train_MambaIR_ColorDN_level50.yml |
| init for ×3/×4 or σ25/σ50 | ×2 model | ×2 model | σ15 model | train_MambaIR_SR_x4.yml train_MambaIR_ColorDN_level50.yml |
| weight decay, warmup | 0, none | 0, none | 0, none | configs above |
Results
Author-reported. PSNR/SSIM on the Y channel of YCbCr §4.1. Classic SR trained on DIV2K + Flickr2K; lightweight SR on DIV2K only; Gaussian color denoising on DIV2K + Flickr2K + BSD500 + WED; real denoising on 320 SIDD images §4.1.
Ablations (setting not stated; the "baseline" row equals the ×2 classic SR model in tab. 3) tab. 1 tab. 2:
| RSSB variant tab. 1 | Set5 | Set14 | Urban100 |
|---|---|---|---|
| (1) remove Conv | 38.48 | 34.54 | 34.04 |
| (2) remove Conv + CA | 38.55 | 34.64 | 34.06 |
| (3) replace with MLP | 38.55 | 34.68 | 34.22 |
| Scan mode tab. 2 | Set5 | Set14 | Urban100 |
|---|---|---|---|
| one-direction (TL→BR) | 38.53 | 34.63 | 34.06 |
| two-direction (TL→BR, BR→TL) | 38.56 | 34.60 | 33.96 |
| baseline (four directions) | 38.57 | 34.67 | 34.15 |
Classic SR (PSNR / SSIM) tab. 3:
| Method | Scale | Set5 | Set14 | BSDS100 | Urban100 | Manga109 |
|---|---|---|---|---|---|---|
| EDSR | ×2 | 38.11 / 0.9602 | 33.92 / 0.9195 | 32.32 / 0.9013 | 32.93 / 0.9351 | 39.10 / 0.9773 |
| RCAN | ×2 | 38.27 / 0.9614 | 34.12 / 0.9216 | 32.41 / 0.9027 | 33.34 / 0.9384 | 39.44 / 0.9786 |
| SAN | ×2 | 38.31 / 0.9620 | 34.07 / 0.9213 | 32.42 / 0.9028 | 33.10 / 0.9370 | 39.32 / 0.9792 |
| HAN | ×2 | 38.27 / 0.9614 | 34.16 / 0.9217 | 32.41 / 0.9027 | 33.35 / 0.9385 | 39.46 / 0.9785 |
| IGNN | ×2 | 38.24 / 0.9613 | 34.07 / 0.9217 | 32.41 / 0.9025 | 33.23 / 0.9383 | 39.35 / 0.9786 |
| CSNLN | ×2 | 38.28 / 0.9616 | 34.12 / 0.9223 | 32.40 / 0.9024 | 33.25 / 0.9386 | 39.37 / 0.9785 |
| NLSA | ×2 | 38.34 / 0.9618 | 34.08 / 0.9231 | 32.43 / 0.9027 | 33.42 / 0.9394 | 39.59 / 0.9789 |
| ELAN | ×2 | 38.36 / 0.9620 | 34.20 / 0.9228 | 32.45 / 0.9030 | 33.44 / 0.9391 | 39.62 / 0.9793 |
| IPT | ×2 | 38.37 / - | 34.43 / - | 32.48 / - | 33.76 / - | - |
| SwinIR | ×2 | 38.42 / 0.9623 | 34.46 / 0.9250 | 32.53 / 0.9041 | 33.81 / 0.9427 | 39.92 / 0.9797 |
| SRFormer | ×2 | 38.51 / 0.9627 | 34.44 / 0.9253 | 32.57 / 0.9046 | 34.09 / 0.9449 | 40.07 / 0.9802 |
| MambaIR | ×2 | 38.57 / 0.9627 | 34.67 / 0.9261 | 32.58 / 0.9048 | 34.15 / 0.9446 | 40.28 / 0.9806 |
| MambaIR+ | ×2 | 38.60 / 0.9628 | 34.69 / 0.9260 | 32.60 / 0.9048 | 34.17 / 0.9443 | 40.33 / 0.9806 |
| EDSR | ×3 | 34.65 / 0.9280 | 30.52 / 0.8462 | 29.25 / 0.8093 | 28.80 / 0.8653 | 34.17 / 0.9476 |
| RCAN | ×3 | 34.74 / 0.9299 | 30.65 / 0.8482 | 29.32 / 0.8111 | 29.09 / 0.8702 | 34.44 / 0.9499 |
| SAN | ×3 | 34.75 / 0.9300 | 30.59 / 0.8476 | 29.33 / 0.8112 | 28.93 / 0.8671 | 34.30 / 0.9494 |
| HAN | ×3 | 34.75 / 0.9299 | 30.67 / 0.8483 | 29.32 / 0.8110 | 29.10 / 0.8705 | 34.48 / 0.9500 |
| IGNN | ×3 | 34.72 / 0.9298 | 30.66 / 0.8484 | 29.31 / 0.8105 | 29.03 / 0.8696 | 34.39 / 0.9496 |
| CSNLN | ×3 | 34.74 / 0.9300 | 30.66 / 0.8482 | 29.33 / 0.8105 | 29.13 / 0.8712 | 34.45 / 0.9502 |
| NLSA | ×3 | 34.85 / 0.9306 | 30.70 / 0.8485 | 29.34 / 0.8117 | 29.25 / 0.8726 | 34.57 / 0.9508 |
| ELAN | ×3 | 34.90 / 0.9313 | 30.80 / 0.8504 | 29.38 / 0.8124 | 29.32 / 0.8745 | 34.73 / 0.9517 |
| IPT | ×3 | 34.81 / - | 30.85 / - | 29.38 / - | 29.49 / - | - |
| SwinIR | ×3 | 34.97 / 0.9318 | 30.93 / 0.8534 | 29.46 / 0.8145 | 29.75 / 0.8826 | 35.12 / 0.9537 |
| SRFormer | ×3 | 35.02 / 0.9323 | 30.94 / 0.8540 | 29.48 / 0.8156 | 30.04 / 0.8865 | 35.26 / 0.9543 |
| MambaIR | ×3 | 35.08 / 0.9323 | 30.99 / 0.8536 | 29.51 / 0.8157 | 29.93 / 0.8841 | 35.43 / 0.9546 |
| MambaIR+ | ×3 | 35.13 / 0.9326 | 31.06 / 0.8541 | 29.53 / 0.8162 | 29.98 / 0.8838 | 35.55 / 0.9549 |
| EDSR | ×4 | 32.46 / 0.8968 | 28.80 / 0.7876 | 27.71 / 0.7420 | 26.64 / 0.8033 | 31.02 / 0.9148 |
| RCAN | ×4 | 32.63 / 0.9002 | 28.87 / 0.7889 | 27.77 / 0.7436 | 26.82 / 0.8087 | 31.22 / 0.9173 |
| SAN | ×4 | 32.64 / 0.9003 | 28.92 / 0.7888 | 27.78 / 0.7436 | 26.79 / 0.8068 | 31.18 / 0.9169 |
| HAN | ×4 | 32.64 / 0.9002 | 28.90 / 0.7890 | 27.80 / 0.7442 | 26.85 / 0.8094 | 31.42 / 0.9177 |
| IGNN | ×4 | 32.57 / 0.8998 | 28.85 / 0.7891 | 27.77 / 0.7434 | 26.84 / 0.8090 | 31.28 / 0.9182 |
| CSNLN | ×4 | 32.68 / 0.9004 | 28.95 / 0.7888 | 27.80 / 0.7439 | 27.22 / 0.8168 | 31.43 / 0.9201 |
| NLSA | ×4 | 32.59 / 0.9000 | 28.87 / 0.7891 | 27.78 / 0.7444 | 26.96 / 0.8109 | 31.27 / 0.9184 |
| ELAN | ×4 | 32.75 / 0.9022 | 28.96 / 0.7914 | 27.83 / 0.7459 | 27.13 / 0.8167 | 31.68 / 0.9226 |
| IPT | ×4 | 32.64 / - | 29.01 / - | 27.82 / - | 27.26 / - | - |
| SwinIR | ×4 | 32.92 / 0.9044 | 29.09 / 0.7950 | 27.92 / 0.7489 | 27.45 / 0.8254 | 32.03 / 0.9260 |
| SRFormer | ×4 | 32.93 / 0.9041 | 29.08 / 0.7953 | 27.94 / 0.7502 | 27.68 / 0.8311 | 32.21 / 0.9271 |
| MambaIR | ×4 | 33.03 / 0.9046 | 29.20 / 0.7961 | 27.98 / 0.7503 | 27.68 / 0.8287 | 32.32 / 0.9272 |
| MambaIR+ | ×4 | 33.13 / 0.9054 | 29.25 / 0.7971 | 28.01 / 0.7510 | 27.80 / 0.8303 | 32.48 / 0.9281 |
Lightweight SR (MACs for a 1280×720 output) tab. 4:
| Method | Scale | #param | MACs | Set5 | Set14 | BSDS100 | Urban100 | Manga109 |
|---|---|---|---|---|---|---|---|---|
| CARN | ×2 | 1,592K | 222.8G | 37.76 / 0.9590 | 33.52 / 0.9166 | 32.09 / 0.8978 | 31.92 / 0.9256 | 38.36 / 0.9765 |
| IMDN | ×2 | 694K | 158.8G | 38.00 / 0.9605 | 33.63 / 0.9177 | 32.19 / 0.8996 | 32.17 / 0.9283 | 38.88 / 0.9774 |
| LAPAR-A | ×2 | 548K | 171.0G | 38.01 / 0.9605 | 33.62 / 0.9183 | 32.19 / 0.8999 | 32.10 / 0.9283 | 38.67 / 0.9772 |
| LatticeNet | ×2 | 756K | 169.5G | 38.13 / 0.9610 | 33.78 / 0.9193 | 32.25 / 0.9005 | 32.43 / 0.9302 | - |
| SwinIR-light | ×2 | 910K | 122.2G | 38.14 / 0.9611 | 33.86 / 0.9206 | 32.31 / 0.9012 | 32.76 / 0.9340 | 39.12 / 0.9783 |
| MambaIR-light | ×2 | 905K | 167.1G | 38.13 / 0.9610 | 33.95 / 0.9208 | 32.31 / 0.9013 | 32.85 / 0.9349 | 39.20 / 0.9782 |
| CARN | ×3 | 1,592K | 118.8G | 34.29 / 0.9255 | 30.29 / 0.8407 | 29.06 / 0.8034 | 28.06 / 0.8493 | 33.50 / 0.9440 |
| IMDN | ×3 | 703K | 71.5G | 34.36 / 0.9270 | 30.32 / 0.8417 | 29.09 / 0.8046 | 28.17 / 0.8519 | 33.61 / 0.9445 |
| LAPAR-A | ×3 | 544K | 114.0G | 34.36 / 0.9267 | 30.34 / 0.8421 | 29.11 / 0.8054 | 28.15 / 0.8523 | 33.51 / 0.9441 |
| LatticeNet | ×3 | 765K | 76.3G | 34.53 / 0.9281 | 30.39 / 0.8424 | 29.15 / 0.8059 | 28.33 / 0.8538 | - |
| SwinIR-light | ×3 | 918K | 55.4G | 34.62 / 0.9289 | 30.54 / 0.8463 | 29.20 / 0.8082 | 28.66 / 0.8624 | 33.98 / 0.9478 |
| MambaIR-light | ×3 | 913K | 74.5G | 34.63 / 0.9288 | 30.54 / 0.8459 | 29.23 / 0.8084 | 28.70 / 0.8631 | 34.12 / 0.9479 |
| CARN | ×4 | 1,592K | 90.9G | 32.13 / 0.8937 | 28.60 / 0.7806 | 27.58 / 0.7349 | 26.07 / 0.7837 | 30.47 / 0.9084 |
| IMDN | ×4 | 715K | 40.9G | 32.21 / 0.8948 | 28.58 / 0.7811 | 27.56 / 0.7353 | 26.04 / 0.7838 | 30.45 / 0.9075 |
| LAPAR-A | ×4 | 659K | 94.0G | 32.15 / 0.8944 | 28.61 / 0.7818 | 27.61 / 0.7366 | 26.14 / 0.7871 | 30.42 / 0.9074 |
| LatticeNet | ×4 | 777K | 43.6G | 32.30 / 0.8962 | 28.68 / 0.7830 | 27.62 / 0.7367 | 26.25 / 0.7873 | - |
| SwinIR-light | ×4 | 930K | 31.8G | 32.44 / 0.8976 | 28.77 / 0.7858 | 27.69 / 0.7406 | 26.47 / 0.7980 | 30.92 / 0.9151 |
| MambaIR-light | ×4 | 924K | 42.3G | 32.42 / 0.8977 | 28.74 / 0.7847 | 27.68 / 0.7400 | 26.52 / 0.7983 | 30.94 / 0.9135 |
Gaussian color denoising (PSNR) tab. 5:
| Method | BSD68 σ15/25/50 | Kodak24 σ15/25/50 | McMaster σ15/25/50 | Urban100 σ15/25/50 |
|---|---|---|---|---|
| IRCNN | 33.86 / 31.16 / 27.86 | 34.69 / 32.18 / 28.93 | 34.58 / 32.18 / 28.91 | 33.78 / 31.20 / 27.70 |
| FFDNet | 33.87 / 31.21 / 27.96 | 34.63 / 32.13 / 28.98 | 34.66 / 32.35 / 29.18 | 33.83 / 31.40 / 28.05 |
| DnCNN | 33.90 / 31.24 / 27.95 | 34.60 / 32.14 / 28.95 | 33.45 / 31.52 / 28.62 | 32.98 / 30.81 / 27.59 |
| DRUNet | 34.30 / 31.69 / 28.51 | 35.31 / 32.89 / 29.86 | 35.40 / 33.14 / 30.08 | 34.81 / 32.60 / 29.61 |
| SwinIR | 34.42 / 31.78 / 28.56 | 35.34 / 32.89 / 29.79 | 35.61 / 33.20 / 30.22 | 35.13 / 32.90 / 29.82 |
| Restormer | 34.40 / 31.79 / 28.60 | 35.47 / 33.04 / 30.01 | 35.61 / 33.34 / 30.30 | 35.13 / 32.96 / 30.02 |
| MambaIR | 34.48 / 32.24 / 28.66 | 35.42 / 32.99 / 29.92 | 35.70 / 33.43 / 30.35 | 35.37 / 33.21 / 30.30 |
Real denoising (PSNR / SSIM) tab. 6:
| Dataset | DeamNet | MPRNet | DAGL | Uformer | Restormer | MambaIR |
|---|---|---|---|---|---|---|
| SIDD | 39.47 / 0.957 | 39.71 / 0.958 | 38.94 / 0.953 | 39.77 / 0.959 | 40.02 / 0.960 | 39.89 / 0.960 |
| DND | 39.63 / 0.953 | 39.80 / 0.954 | 39.77 / 0.956 | 39.96 / 0.956 | 40.03 / 0.956 | 40.04 / 0.956 |
Other results: real-world ×4 SR is shown only as visual comparisons, since there is no ground truth §4.3 fig. 6. GPU memory as the input grows from 48×48 to 84×84 scales roughly like SwinIR and far below full attention §4.3 fig. 5; no numbers are given in the text. JPEG artifact-reduction results and further ablations (e.g. the number of RSSBs) are in the supplementary material, which is not part of the arXiv source §4.1 §4.2.
Paper vs code
- Adam β2: paper 0.999 §4.1; code 0.99 train_MambaIR_SR_x2.yml.
- Charbonnier ε: paper
sqrt(d² + ε²)with ε = 1e-3 eq. 9; code computessqrt(d² + eps)per element with eps = 1e-3, i.e. an effective ε of about 0.032 losses.py train_MambaIR_ColorDN_level15.yml. - SR patch size: paper says 64×64 SR patches §4.1. Code crops HR at 128 for ×2 and 192 for ×3/×4, so LR patches are 64 (×2, ×3) but 48 for ×4 train_MambaIR_SR_x2.yml train_MambaIR_SR_x4.yml.
- Scan order: the paper lists four corner-to-corner directions (TL→BR, BR→TL, TR→BL, BL→TR) §3.5. The code scans row-major, column-major, and the reverse of each mambair_arch.py.
- ×3/×4 halving: paper says to halve LR and iterations when initialising from ×2 §4.1. The classic configs do this train_MambaIR_SR_x4.yml; the lightweight ×3/×4 configs load ×2 weights but keep 2e-4 and 500k iterations train_MambaIR_lightSR_x4.yml.
- Lightweight block: not described in the paper. Code swaps the bottleneck to
1×1 (C→C/2) → depthwise 3×3 → GELU → 1×1 → depthwise 3×3 with dilation 2 → CAand uses a one-step pixel-shuffle head mambair_arch.py mambair_arch.py. - Real denoising: paper describes one architecture and Charbonnier loss
for denoising §3.6. The real-denoising config uses a different U-Net model
(
MambaIRUNet, dim 48, blocks [4, 6, 6, 8], 4 refinement blocks, λ = 1.5), L1 loss, AdamW (3e-4, weight decay 1e-4, β2 0.999), gradient clipping, mixup, and progressive patches 128→384 over 300k iterations train_MambaIR_RealDN.yml train_MambaIR_RealDN.yml. - Color denoising metric: paper reports Y-channel PSNR for everything
§4.1; the color-denoising test configs compute RGB PSNR with
test_y_channel: falsetest_MambaIR_ColorDN_level15.yml. - σ25/σ50 denoising: initialised from the σ15 model with LR 1e-4 and 800k iterations; not in the paper train_MambaIR_ColorDN_level50.yml.
- Extra pieces not in the paper: subtraction of the RGB mean, a LayerNorm after patch embedding, a residual around each RSSG, a final LayerNorm, and a global input skip for denoising mambair_arch.py mambair_arch.py.
Pitfalls
- Most architecture sizes are only in code. The paper gives no values for C, the group/block counts, state size N, λ or γ; use the code tables above.
- Eq. 2 as printed is inconsistent:
B̄usesexp(A)whileĀusesexp(ΔA). The code never implements eq. 2 itself; it callsmamba_ssm'sselective_scan_fnwith softplus on Δ plus a bias mambair_arch.py. Reuse that kernel rather than coding eq. 2 from the paper. - Loss equations compare output with input. Eqs. 8 and 9 are written as
I_HQ − I_LQ; the code compares the prediction with the ground truth losses.py. - Four scans means four sets of SSM parameters. Each direction has its own Δ/B/C projection, Δ projection, A and D mambair_arch.py. The scan itself runs in float32 even under mixed precision mambair_arch.py.
- Hard CUDA dependency. The model imports
mamba_ssm's fused selective scan mambair_arch.py. A pure-PyTorch port must reproduce its Δ softplus, bias and D-skip behaviour. - Narrow channel attention. Squeeze factor 30 leaves 6 hidden channels at C = 180 and 2 at C = 60 mambair_arch.py.
- Noise synthesis. Gaussian noise of σ/255 is added on the fly to float images in [0, 1] with no clipping; validation fixes seed 0 paired_image_dataset.py.
- Ablation setup unstated. tab. 1 and tab. 2 give no training setting, and they leave out the parameter and MAC counts that the variants change.
- Long training. Classic ×2 SR runs 500k iterations on 8 GPUs, and σ15 denoising 1.6M iterations train_MambaIR_SR_x2.yml train_MambaIR_ColorDN_level15.yml.
- Repository also holds MambaIRv2.
mambairv2_arch.pyand themambairv2configs belong to a later model; the files for this paper aremambair_arch.pyandoptions/*/mambair/.
Lineage
- Builds on: Mamba (arXiv:2312.00752) for the selective scan; VMamba (arXiv:2401.10166) for the VSSM and the 2D four-direction scan; SwinIR's three-stage pipeline and experimental setup; squeeze-and-excitation channel attention §3.3 §3.4 §3.5 §4.1.
- Compared against: SwinIR, SRFormer, IPT, ELAN, RCAN, EDSR, HAT (receptive-field plots), Restormer, DRUNet, Uformer and lightweight SR models tab. 3-6.
Source and license
Adapted from “MambaIR: A Simple Baseline for Image Restoration with State-Space Model” by Hang Guo, Jinmin Li, Tao Dai, Zhihao Ouyang, Xudong Ren, Shu-Tao Xia (arXiv:2402.15648), used under CC BY-SA 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. This page is licensed under CC BY-SA 4.0. Code citations refer to https://github.com/csguoh/MambaIR at commit 33d7b3460c46 (Apache-2.0). Any quoted code is shown under that license.