01

Segma — U-Net from scratch

A U-Net rebuilt from scratch in PyTorch (≈ 7.8M parameters) to segment cats and dogs pixel by pixel on Oxford-IIIT Pet, with an ablation study measuring what skip connections really bring.

mIoU 0.719 · skip connections: +0.096 IoU on boundaries

Segma — U-Net from scratch

Stack

PythonPyTorchOpenCVJupyter

What happened?

  1. 01

    The question

    Everyone adds skip connections to a U-Net. But what do they actually bring, and where exactly?

  2. 02

    The problem

    Going deeper into a convolutional network, the image shrinks to a tiny grid (8×8 here): the network knows what is there, but forgets exactly where. Segmentation needs an answer for every single pixel.

  3. 03

    The hypothesis

    If skip connections hand the decoder back the details lost on the way down, removing them should hurt most on boundaries, the thinnest class.

  4. 04

    The build

    A three-notebook path: classical segmentation (thresholding, contours, K-means), layer-by-layer feature map visualisation, then a U-Net coded from scratch (DoubleConv, Down, Up) trained twice under identical settings, with and without skip connections, on Oxford-IIIT Pet (3 classes: animal, background, boundary).

  5. 05

    The failure

    Nothing dramatic, just the classic: shapes that did not match. Between poolings, transposed convolutions and skip concatenations, every level has to land on exactly the right size. A few dimension calculations later, the U was standing.

  6. 06

    The discovery

    Without skip connections, the network still roughly knows where the animal is (−0.031 IoU), but it can no longer draw its outline: boundary IoU drops from 0.471 to 0.375. Skip connections do not help the network see better, they help it remember where the details are.

  7. 07

    The result

    mIoU of 0.719 with skip connections versus 0.672 without, on 3,669 test images. Everything is documented as a course, in French and English.

  8. 08

    The next frontier

    Try other variants (attention gates, pretrained encoder), move to larger images, and apply segmentation to data that matters locally, such as agricultural or medical imaging.

Spider-Verse · homage