Does a Tiny Segmenter Need Attention? A Parameter-Matched Test on Dozens of Images

When a medical segmentation model must be trained from scratch on fifty images and run on cheap hardware, practitioners face a choice that the literature has never posed cleanly. One option is a very small convolutional network, which looks only at local neighborhoods but generalizes surprisingly well from little data. The other is to add self-attention, an operation that lets every location consult every other location, so the model sees the whole image at once. Attention is known to help larger models ignore misleading background. It is also known to need far more data. This proposal builds a family of segmentation networks under 500,000 parameters that differ in exactly one component: the operator that supplies image-wide context at the coarsest resolution. We train them from scratch on 10 to 85 images and ask whether attention buys anything that a cheaper convolutional trick does not, and if so, what kind of error it removes.

The core idea is simple to state. In a network that progressively shrinks the image, which we call a hierarchical network, an attention layer placed at the smallest resolution costs the same number of parameters as one placed anywhere else, but very little compute. So at a fixed parameter budget, the choice between attention and dilated convolution is purely a choice of inductive bias, meaning the built-in assumption about what structure to look for. We predict that attention's benefit in this regime appears almost entirely as fewer false-positive blobs far from the true structure, and not as sharper boundaries. To test this we split segmentation error into boundary and distant components. If the prediction fails, compact CNNs are sufficient, and that result is worth establishing.

What exists and what is missing

The direction most directly relevant is low-parameter optimization for scarce data. Tens of images can suffice to train neural networks for malignant leukocyte detection trains a six-layer CNN of about 7,210 parameters. It exceeds 0.90 ROC-AUC with 30 images, but plateaus at 0.81 ± 0.09 F1 on a 6-class task. Retinal Image Segmentation with Small Datasets builds CoNet, a U-Net cut down to three stages. It uses 9×3 rectangular kernels and dilated pyramid pooling (ASPP, parallel convolutions with spaced-out filter taps) at the input. With 55 unaugmented OCT B-scans on Duke DME, it reaches 88% mean Dice and 77% fluid Dice, against 70% for U-Net. These papers motivate the work: they show tiny CNNs are strong. CoNet in particular constrains it, because it already obtains wide context without any attention. It is therefore the competitor any attention module must beat.

On the hierarchical and hybrid side, several models combine convolution and attention but at much larger sizes.

  • SegFormer supplies two design pieces we reuse. Its four-stage encoder shrinks the image step by step. Its Mix-FFN places a 3×3 depthwise convolution inside the feed-forward layer so that zero-padding leaks position, removing the need for positional embeddings. But its smallest variant is still described as too heavy for low-power devices, and it relies on ImageNet pre-training.
  • Lite-Mono is a 3.1M-parameter hybrid for depth estimation. It uses cross-covariance attention, which mixes channels rather than spatial positions, together with stacked dilated convolutions. Its authors report that heavy dilation causes grid artifacts. It was also trained on large video data rather than dozens of images.
  • HMCFormer and CFFormer run full parallel CNN and Swin branches and fuse them. HMCFormer has about 12M parameters. CFFormer pairs ResNet34 with Swin-V2 and reaches 86.23% Dice on BUSI. Both double the parameter budget, which is exactly what our regime cannot afford.

Two papers come closest to the small-data question but leave the decisive comparison open. Medical Transformer uses gated axial attention and beats U-Net on brain ultrasound (88.84 vs 85.37 F1) and on GlaS (81.02 F1). It attributes the gain to suppressed background false positives. However, it compares against a U-Net of a different size, and the file reports no parameter count for it, so the gain cannot be separated from capacity.

Two further papers inject locality into vision transformers trained from scratch on small datasets. Enhancing Performance of Vision Transformers on Small Datasets through Local Inductive Bias Incorporation adds multi-scale depthwise convolutions to the query, key and value projections. Vision Transformer for Small-Size Datasets adds shifted patches and locality-masked attention. Both work at tens of millions of parameters and on classification.

Finally, How to Train Vision Transformer on Small-scale Datasets? argues the opposite position. It claims architecture matters less than initialization, and that self-distillation on the target data recovers the missing biases. Our design must therefore include self-supervised initialization as a competing explanation.

What is new here is not "a tiny hybrid network". It is a parameter-matched, single-stream comparison in the sub-500k regime, trained from scratch on fewer than 100 images. It is paired with an error decomposition that tests a specific mechanistic claim about what attention contributes.

Core Claim

At a fixed parameter budget below 500k, and with 55 or fewer training images, one spatial self-attention block at the coarsest stage of a three-stage convolutional hierarchy will beat an iso-parameter ASPP or dilated-convolution context module. The gain will be concentrated in distant false positives. We define these as predicted connected components lying more than a fixed distance from any ground-truth region of that class. Boundary error, measured as disagreement within that distance of the true contour, will be unchanged or slightly worse.

We further predict that cross-covariance channel attention of the Lite-Mono kind will not deliver the distant-false-positive reduction. The reason is that it mixes features without letting a location compare itself to distant locations. This would resolve the open tension between spatial and channel attention for dense tasks.

Research Program

We build one backbone with three stages at 1/1, 1/2 and 1/4 resolution, following CoNet's depth. The first two stages are purely convolutional, with depthwise-separable blocks. Kernel shapes are fixed per dataset: 9×3 for OCT, following CoNet, and square elsewhere. The coarse stage contains a single "context slot" whose implementation is the experimental variable. We test five variants:

  • an ASPP block;
  • stacked dilated convolutions;
  • spatial multi-head self-attention, with a Mix-FFN depthwise convolution for position and no positional embeddings;
  • cross-covariance channel attention;
  • an identity slot, which gives an equal-depth plain CNN with width increased to match parameters.

A SegFormer-style all-MLP decoder upsamples and merges the three stages. We instantiate each variant at three budgets of roughly 30k, 120k and 500k parameters. Parameter counts are matched within 5% by adjusting channel width, so every comparison is at equal capacity.

We also test two placement variants. One moves the attention slot to the 1/2 stage. The other uses two slots at different scales. These ask whether the hierarchy matters or only the presence of attention.

To engage the initialization argument, every variant is also trained with a self-distillation pre-stage on the training images themselves, using global and local crops as in the two-stage recipe.

Baselines

The do-nothing reference is a standard U-Net trained from scratch under our protocol. On Duke DME, Retinal Image Segmentation with Small Datasets reports 70% fluid Dice for U-Net, and we expect to reproduce roughly that. A trivial floor is also reported: the 58% fluid Dice inter-observer agreement between human experts.

The strongest existing small-data method is CoNet itself, which is reported at 88% mean Dice and 77% fluid Dice on Duke DME with 55 training images. It is the right competitor because it is already compact, already from scratch, and already has wide context through input-level ASPP. We reimplement it, count its parameters (the file gives no exact figure), and run it on our splits. Beating it means exceeding its reproduced mean and fluid Dice at an equal or smaller parameter count, with the gap larger than the seed-to-seed standard deviation over five seeds.

On GlaS the comparison is to Medical Transformer, which reports 81.02 F1 with 85 training images. On brain ultrasound it reports 88.84 F1. We will report its parameter count from our reimplementation, since the file has none.

On BUSI, CFFormer reports 86.23% Dice. This serves as a heavy-model reference rather than a target, since it uses two large encoders.

For subsampled Kvasir-SEG and ISIC-2016, no reported result was found on Lacuna for the small-subset regime, so only our reproduced baselines are compared.

The key ablation isolating our ingredient is the context-slot swap at matched parameters. Fairness rests on three controls:

  • every model, including CoNet and U-Net, gets the same augmentation policy, epochs, and 30-trial random search over learning rate and weight decay;
  • validation uses patient-level held-out folds;
  • Duke DME uses CoNet's 55/55 split plus patient-grouped re-splits, because a single split across 10 patients is fragile.

Why not just…?

Why not just use CoNet's input ASPP, which already provides wide context without attention? This is the main threat, and the experiment is built around it. If the ASPP-slot variant matches spatial attention within seed noise on overall Dice and on the distant-false-positive component, at every budget and data size, we conclude attention is unnecessary below 500k parameters. The MedT gain over U-Net is suggestive but not decisive, because it was never parameter-matched against a dilated-convolution model.

Why not just bolt one transformer block onto a small CNN bottleneck, as sequential hybrids do? That is essentially our spatial-attention variant. Our claim is not that the block is new but that it is the right one, at the right place, measured fairly. The placement ablation (coarse versus 1/2 stage) tests whether the hierarchy contributes anything beyond "add a block".

Why not just keep the architecture standard and fix initialization with self-distillation on the target images? The two-stage recipe reached 63.36% on Tiny-ImageNet from scratch, but with tens of thousands of images. With 10 to 55 images, there may be too few distinct crops for distillation to discover locality. We test this directly by applying the pre-stage to the identity-slot CNN and to every attention variant. If it closes the gap between plain and attention models, then initialization, not architecture, is the operative factor.

Why not just fine-tune an ImageNet-pretrained SegFormer-B0? It may well be more accurate, and we report it as an upper reference. Our claim concerns from-scratch models one to two orders of magnitude smaller, for deployment where pre-trained weights are too large or mismatched, as with grayscale OCT. If B0 fine-tuning dominates even at 10 images, that bounds the practical value of the tiny regime, and we will say so.

Decisive Checks

We plot learning curves at 10, 25 and 55 training images on Duke DME, and at 20, 40 and 85 on GlaS. Subsampled BUSI, Kvasir-SEG and ISIC-2016 at 50 images test generality across ultrasound, endoscopy and dermoscopy. Beyond mean Dice and F1, we report three per-image quantities: distant-false-positive area, boundary-band Dice, and 95th-percentile Hausdorff distance.

The claim is supported only if all of the following hold:

  • spatial attention beats the iso-parameter ASPP and identity variants on overall Dice;
  • its advantage over ASPP is mostly accounted for by the distant-false-positive term;
  • channel attention fails to reproduce that term;
  • the advantage survives self-distillation pre-training of the CNN.

It is refuted if any of the following hold:

  • ASPP matches attention;
  • the gain sits in boundary error, which would point to capacity or optimization effects rather than global context;
  • the gain disappears under matched initialization.

We also report latency on a CPU and an embedded board for each variant. Coarse-stage attention is meant to be cheap, and that should be measured rather than assumed.