Image Segmentation with Scribble Supervision
Weakly supervised computer vision
Dense segmentation labels are expensive: every object boundary has to be traced pixel by pixel. This project asks a cheaper question—if an annotator marks only a few confident foreground and background regions, can a model recover the complete object?
The resulting system fuses a sparse scribble with an RGB image, predicts a full-resolution probability map, and turns it into a binary mask. The strongest configuration combined an EfficientNet-B2 encoder, a U-Net decoder with scSE attention, region-aware loss, restrained augmentation, and a five-fold ensemble.

The Supervision Problem
Each sample contains an image, a tri-state scribble map, and a dense mask used only for training evaluation. The learning signal deliberately distinguishes “background,” “foreground,” and “not annotated” rather than treating every unmarked pixel as background.
Averaging both classes prevents the larger background region from hiding weak foreground recovery.
From Sparse Input to Dense Mask
The pipeline is deliberately linear. Every stage changes one representation, which makes failures easier to localize than a collection of loosely connected preprocessing and training panels.
- 01Encode[B, 4, 480, 352]
Fuse RGB pixels with the sparse scribble as a fourth channel.
- 02Extract32× downsample
Build a five-level EfficientNet-B2 feature hierarchy.
- 03Recoverdense logits
Decode with U-Net skip connections and scSE attention.
- 04OptimizeIoU + 0.2 BCE
Balance region overlap against pixel-wise classification.
- 05Validate5-fold ensemble
Average five fold-specific probability maps before thresholding.
Input Encoding
Images are resized from 500 × 375 to 480 × 352—the nearest lower size divisible by 32. Lanczos interpolation preserves RGB edges; nearest neighbor keeps mask labels discrete. The normalized image and encoded scribble are then concatenated before the first convolution.
Designing the Objective
Pixel accuracy is a poor guide when most pixels are background. The objective therefore combines an overlap loss, which reasons about the whole region, with a smaller weighted BCE term that keeps individual pixel decisions calibrated.
Smooth and stable when the target occupies only a small part of the image.
Augmentation Without Breaking Labels
An image transform is only valid when it is applied identically to the RGB image, the sparse scribble, and the dense target. The experiments compared three recipes, increasing spatial distortion while keeping that alignment invariant.
Small viewpoint and color changes improved generalization without destroying thin foreground hints.
Synthetic Scribble Generator
Dense masks can be converted into plausible sparse annotations, letting the model see a wider range of marking styles without requiring another annotation pass.
Architecture
Early fusion lets every encoder level interpret appearance together with annotation. The decoder restores spatial detail through U-Net skip connections, while scSE blocks recalibrate both channels and locations before the final one-channel prediction.
Choosing the Encoder
Too little capacity for fine boundaries
Competitive, but less stable across folds
Best accuracy-to-compute trade-off
Training and Evaluation
Seventy-two configurations crossed loss function, augmentation strength, batch size, and positive-class weighting. Validation was stratified into five folds; at inference, the five probability maps were averaged before applying the 0.5 threshold.
- Optimizer
- AdamW
- Learning rate
- 5 × 10⁻³ → 1 × 10⁻⁷ cosine
- Weight decay
- 1 × 10⁻⁴
- Precision
- bfloat16 on A100
- Training budget
- 8K–16K steps
- Early stopping
- 60 checks on validation mIoU
What the Experiments Changed
Mild augmentation won.
Low-intensity geometric and photometric changes preserved the sparse supervisory signal better than aggressive warps.
A moderate positive weight was enough.
A foreground weight of 3.0 produced the strongest IoU run; pushing to the raw 3.88× class ratio did not help.
Batch size was not the main lever.
Batches of 6, 8, and 12 stayed within seven ten-thousandths of mean IoU once the loss and augmentation recipe were fixed.
Sparse input still recovered coherent objects.
The five-model ensemble reached 0.8569 test mIoU while using only scribbled pixels as explicit annotation.
The main result is not that scribbles behave like dense labels—they do not—but that a carefully aligned pipeline can extract much more supervision from them than their size suggests. The next useful step would be testing richer scribble policies and uncertainty-guided annotation, so the model can ask for the small number of additional strokes that would improve a difficult mask most.