All models

uformer_b32

The Base Uformer: a UNet whose convolutions became window-attention Transformer blocks, for image restoration.

262 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (25 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
555.9K
Operations
262
Framework
PyTorch
Recurrent
No
Published
CVPR (arXiv 2021)
Cited by
2,244 (as of 9 October 2026)
Authors
Zhendong Wang, Xiaodong Cun, Jianmin Bao and others
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m12202
Graph hash
53d73e15941f78a2b92211413c1214dbd3a4b08a1618875a2fcc17deb1732879
Skeleton hash
f0d3cf0fedb99bb1c4affa236a2610ff41d2c424f422cf8b8b828fda91f04027
Architecture hash
fcd2eb6ab1c84f81d5406ef1d50c2db8c72d101a5e5f2919a86b3ad9e51703f0
Diagram SHA-256
ee01f51b907c19fb63c25aae17ffabed1b1bf77102041c39b72cb0825c351716
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

menagerie.classics.uformer:build_uformer_b: build({})

What it is

Uformer is a Transformer-based architecture for image restoration, the classic task of recovering a clean image from a degraded one. The degradations in question are the everyday ones: noise, blur, rain and so on. The shape is borrowed straight from UNet: the convolution layers are swapped for Transformer blocks while the hierarchical encoder-decoder and its skip connections stay put. The motivation is that the state-of-the-art ConvNet restorers of the time achieved impressive results but struggled with long-range dependencies.

The basic unit is the Locally-enhanced Window (LeWin) Transformer block, which runs self-attention inside non-overlapping windows instead of across the whole image. Because the window size stays fixed while the feature maps shrink down the hierarchy, attention at low resolution sees far more of the image. Local context, which restoration leans on heavily, comes from a depth-wise convolution slipped between the two fully-connected layers of the feed-forward network. Ablations found that locality belongs in the feed-forward path rather than in the attention: adding it to self-attention actually cost 0.02 dB on SIDD. The second design is a multi-scale restoration modulator: a learnable window-based tensor added to the features in each decoder LeWin block to help recover detail. It acts as a shared bias term added to all windows before self-attention, costing marginal parameters and compute. The network predicts a residual image that is added back to the input, trained with a Charbonnier loss.

The member captured here is the Base variant, Uformer-B, with C = 32 channels and encoder depths of {1, 2, 8, 8}. The decoder depths mirror the encoder's. Windows are 8 × 8 throughout and there are 4 encoder and decoder stages by default. On SIDD denoising Uformer-B reaches 39.89 dB PSNR, at least 0.14 dB above every other method. On DND it edges the previous state of the art, NBNet, by 0.09 dB. For motion deblurring, trained only on GoPro, it generalises to real blur, beating others by at least 0.23 dB on RealBlur-R and 0.36 dB on RealBlur-J. The biggest jump is deraining on SPAD: 47.84 dB, 3.74 dB over the previous best. Swapping the LeWin blocks for convolutional ResBlocks gives a plain UNet, and Uformer-B beats its UNet-B counterpart by 0.18 dB.

Key idea. Uformer swaps UNet's convolutions for locally-enhanced window Transformer blocks and adds a learnable multi-scale bias to the decoder, giving a restoration network that captures both local and global dependencies at modest cost.

  • Uformer
  • Uformer-B
  • uformer_b32
  • U-shaped Transformer
  • image restoration
  • LeWin Transformer block
  • locally-enhanced window attention
  • multi-scale restoration modulator
  • image denoising
  • deblurring
  • deraining
  • SIDD
  • GoPro

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{wang2021uformergeneralushapedtransformer,
      title={Uformer: A General U-Shaped Transformer for Image Restoration}, 
      author={Zhendong Wang and Xiaodong Cun and Jianmin Bao and Wengang Zhou and Jianzhuang Liu and Houqiang Li},
      year={2021},
      eprint={2106.03106},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2106.03106}, 
}