U-Net

Encoder–decoder · pattern · Image → Pixel mask, Image

Shrinks an image to coarse features and grows it back, copying each encoder level across to the matching decoder level.

Also called Encoder–decoder with skips, U²-Net, Hourglass network

Figure 1. The U-Net as a schematic: the parts it is built from and how data flows between them. Select a part to read about it.

What it does

A U-Net has a contracting path that convolves and downsamples, and an expanding path that upsamples back to the input size. At each resolution the encoder’s feature map is concatenated onto the decoder’s, so fine details lost in downsampling (edges, hair, thin structures) are available when the decoder draws the output. The final 1 × 1 convolution gives one value per pixel, typically passed through a sigmoid to make a mask. U²-Net nests a small U-Net inside each stage.

Formula

eℓ = Conv(Pool(eℓ−1))dℓ = Conv(Concat(Up(dℓ+1), eℓ))mask = σ(Conv1×1(d1))

Shapes and parameters

Shapes
Image [N, 3, H, W] → bottleneck [N, 128, H/4, W/4] → mask [N, 1, H, W], same size as the input.
Parameters
Dominated by the deepest convolutions. The small example totals 231,617; full U-Nets reach tens of millions.
Used for
U²-Net-p saliency, MODNet portrait matting, PP-HumanSeg, medical and document segmentation.

Figure 2. A real u-net in WeightSpace: Separate a person from the background, drawn from the file the app runs. Open a module to see the parts inside.

In WeightSpace

Catalog encoder–decoder models are edited at the bias of the final output convolution: the fused saliency logit, the foreground alpha logit, or the person/background logits. A positive delta grows the mask everywhere, a negative one shrinks it.