Interior-Guided Sparse Boundary Refinement for Real-Time Polyp Segmentation

Many hard segmentation targets, such as early colon polyps, have no visible edge. Their color and texture fade gradually into the surrounding tissue, so a network can find the center of the lesion but has to guess where it ends. The most accurate fix so far is to split the prediction into a confident interior and an uncertain rim, then use features from the interior to decide the rim. Polyper does this and reaches 86.51% mean Dice on the difficult ETIS benchmark. However, it refines a fixed-width band around every object with full cross-attention and never reports speed. The fast models that do run at video rate behave differently. RUPNet reaches 152.60 FPS by dropping attention entirely, and pays for it with over-segmentation at ambiguous margins and 0.7658 Dice on Kvasir-SEG.

We propose to resolve ambiguous boundaries by refining only a small, fixed number of the most uncertain pixels. Each selected pixel is classified by attending to a handful of compact "prototype" vectors pooled from the object's own confident interior. Because the number of refined points and prototypes is fixed, the refinement cost stays constant regardless of image resolution or object size. The central question is whether this sparse, interior-conditioned step keeps most of Polyper's boundary advantage within a latency budget of at least 30 FPS on an embedded NVIDIA Jetson board. We also test the obvious cheaper alternative: training a fast network with a boundary-weighted loss and adding nothing at inference time.

Core Claim

The hypothesis is that errors at low-contrast boundaries come from a lack of object-specific evidence, not a lack of local capacity. A pixel on a fuzzy rim looks like both polyp and mucosa. Comparing it with this particular polyp's interior appearance separates the two better than a deeper local filter would. If that is true, the comparison does not need to be dense. A few hundred rim pixels attending to eight to sixteen interior prototypes should capture most of the gain.

The resulting refiner has three properties that distinguish it from prior work. Its cost is set by a point budget rather than by band area. The width of its uncertain region scales with the object instead of using a fixed morphological kernel. And its accuracy can be measured under realistic edge-device precision (INT8 and FP16).

Point-sampling refinement heads exist in general instance segmentation outside the material surveyed here. Those heads classify selected points with a small local network using features at that location. Our heads instead classify selected points by attending to features pooled from the object's own interior. The ablations below test directly whether this difference matters.

How This Relates to Prior Work

Three polyp models already combine boundary handling with real-time speed. All three pay for boundaries with dense, whole-image operations:

  • Parallel Res2Net with Reverse Attention erases confident foreground in several decoder passes. It then applies a hand-tuned threshold to flip remaining gray pixels, and runs at about 32 FPS on a desktop GPU.
  • SCR-Net learns a flow field that realigns upsampled deep features to shallow ones. It reaches 80.78% Dice on Kvasir-SEG at 32 FPS on a laptop GPU, but its authors report weakness on very small, camouflaged polyps.
  • CaraNet stacks dilated pyramids and repeated axial reverse attention. It reaches 74.7% mDice on ETIS and reports no speed.

These papers motivate the proposal: boundary-specific processing helps on small, ambiguous targets. They also constrain it: done densely and iteratively, that processing uses up the frame budget.

We borrow from two other sources. From Polyper we take the interior-to-rim guidance idea, whose region-separation step is worth 4.40 mIoU in its ablation. We change two things Polyper leaves open: its fixed erosion and dilation kernel, and its dense attention over the whole band. From YOLOv5m-TST we take the pattern of letting many local queries attend to a few compact global tokens. That design raised a detector from 18.6 to 64.8 FPS on a Jetson Nano at a stable ~0.880 mAP50. Its authors used it only for bounding boxes, with a key dimension of 4 that loses fine edges. We apply it only at a sparse set of boundary points, where a larger key dimension is affordable.

Finally, YolactEdge found that prediction heads break under INT8 quantization while backbones survive it. That finding shapes our deployment plan: the refiner will be tested in both precisions rather than assumed safe.

Research Program

The system has three parts.

The coarse network. The first stage is a fast segmentation network. By default this is a SimpleUNet-style fixed-width encoder-decoder, following SimpleUNet. That model reports 86.46% mDice on Kvasir-SEG at 8.60 GFLOPs, so it is already a strong and cheap starting point. The coarse network outputs a probability map $p$ at one-quarter resolution plus a shallow feature map.

Point selection. From $p$ we select a fixed budget of $K$ pixels. Selection is restricted to a band whose half-width scales with each connected component's size, $w = \mathrm{clip}(\gamma\sqrt{A},\, w_{\min},\, w_{\max})$. Here $A$ is the component's predicted area in pixels and $\gamma$ is a learned scalar. The square root makes the band a roughly constant fraction of the object's diameter. Within the band, the $K$ pixels whose $|p - 0.5|$ is smallest are chosen.

Interior prototypes and refinement. For each object, we cluster the features of its confident interior pixels ($p > 0.9$ after erosion by $w$) into $M$ prototypes, with $M$ between 8 and 16. We also pool $M$ background prototypes from a surrounding ring. Each selected point's shallow and deep features form a query. The query attends over the object and background prototypes in a single cross-attention layer with key dimension 32, and a small MLP outputs a corrected logit. The corrected logits are written back into the upsampled map.

The cost is $O(K \cdot 2M)$, so with $K = 512$ it is tiny compared with the coarse network. If an object has too few confident interior pixels to form prototypes, a common case for tiny polyps, we fall back to image-level prototypes. We report how often this fallback fires.

What the refiner cannot fix. A lesion the coarse network misses entirely is never refined. Polyper shares this limitation. We will therefore report lesion-level recall separately, so boundary gains cannot hide missed polyps.

Training. The refiner is trained jointly with the coarse network. Point-level cross-entropy is computed at the selected points, with extra points sampled randomly from the band early in training so selection does not collapse.

Baselines

The naive reference is the coarse network alone, trained with standard Dice plus cross-entropy and run at the same resolution and precision. It shows what the refiner adds on top of an already strong fast model. The file reports 86.46% mDice on Kvasir-SEG for SimpleUNet; we will retrain it under our protocol.

The zero-inference-cost competitor is the same coarse network trained with a boundary-weighted loss. Pixels inside the adaptive band are up-weighted, and an auxiliary contour term is added in the manner of the contour-loss method. This is the baseline most likely to make the refiner unnecessary, because it spends extra effort on the rim during training and costs nothing at deployment.

The strongest accuracy competitor is Polyper, which reports 86.51% mDice on ETIS against 81.00% for SegT. We will retrain Polyper on our exact data split, keep its dense band attention, and profile it on the same Jetson hardware. Its published number was obtained under its own protocol, so the retrained number is the one we compare against. The refiner beats Polyper if it recovers at least three-quarters of the ETIS Dice gap between the plain coarse network and Polyper, while running at least three times faster on-device.

The strongest real-time competitors are SCR-Net and Parallel Res2Net with Reverse Attention. SCR-Net reports 80.78% Dice on Kvasir-SEG at 32 FPS on a GTX 965M. Parallel Res2Net reports about 32 FPS with 81.14% to 88.94% precision. We add RUPNet (152.60 FPS, 0.7658 Dice on Kvasir-SEG) as the speed-first extreme. All of these are retrained with the same augmentation, the same epoch budget, and a small matched hyperparameter sweep of eight learning-rate and weight-decay configurations each. They are then exported through the same TensorRT pipeline. The refiner beats them if it achieves higher boundary F-score on ETIS and CVC-ColonDB at equal or better Jetson frame rate.

Four ablations isolate the key ingredient:

  • Dense band refinement. Replace the $K$-point refiner with dense attention over the whole band. This shows whether sparsity costs accuracy.
  • Local classification. Replace interior-prototype attention with a local MLP on point features alone, the generic point-refinement design. This tests whether interior conditioning is what helps.
  • Fixed-width band. Replace the adaptive band width with Polyper's fixed width.
  • Random points. Replace uncertainty-based point selection with random points inside the band.

Why not just…?

Why not just train the fast network with a boundary-weighted loss and skip the refiner? This is the real threat, and the proposal is designed to lose cleanly to it if the hypothesis is wrong. A training-time loss can make the network put more capacity into rims. It cannot give a rim pixel access to this particular object's interior appearance at test time, which is what the hypothesis says ambiguous pixels need. The matched-latency comparison on ETIS small polyps settles the question. If the boundary-loss model is within one Dice point and one boundary-F point of the refiner there, we will report that the extra module is not worth its cost.

Why not just use threshold polarization after a fast network? Parallel Res2Net with Reverse Attention shows that flipping gray pixels by a size-based rule raises precision. However, the rule decides every uncertain pixel the same way, whatever the object looks like, and its threshold is hand-tuned. We will apply the same polarization to our coarse network as an additional baseline. We expect it to help precision on large polyps and hurt recall on small ones, and the size-stratified results will show whether that happens.

Why not just prune and quantize Polyper? Polyper's cost comes from dense attention over a band whose area grows with object size and resolution. Pruning channels shrinks the constant but not that growth. The dense-band ablation plus a pruned-Polyper variant, compressed to the refiner's latency, answers this directly. If pruned Polyper matches the refiner at equal FPS, sparsity is not the contribution, and we will say so.

Proposed Experiments

Data. Following the standard polyp protocol used across these papers, we train on Kvasir-SEG and CVC-ClinicDB. We test on the held-out portions of each and, out of distribution, on ETIS, CVC-ColonDB, and CVC-300.

Metrics. We report mDice and mIoU, boundary F-score within a 3-pixel tolerance, and 95th-percentile Hausdorff distance. Results are stratified by lesion size, with polyps under 6% of image area as the small stratum following Polyper. Lesion-level recall is reported separately.

Latency. Latency is measured at batch size 1 at 352 and 512 pixel resolution on a Jetson Nano and a Jetson AGX Xavier, the platforms used for YOLOv5m-TST. Timings are end to end, including point selection, prototype clustering, and write-back. Each model is profiled in FP16, full INT8, and mixed precision (INT8 coarse network with FP16 refiner). This directly tests whether YolactEdge's head-quantization failure also affects interior-conditioned boundary attention.

Video stress test. For motion and specular artifacts, we run all models on SUN and KUMC colonoscopy video streams. These datasets supply boxes rather than masks. We therefore report box-level recall of the predicted mask and frame-to-frame mask stability, and make no claim of pixel accuracy on them.

Decisive checks. The decisive result is a single plot of boundary F-score on small ETIS polyps against measured Jetson frame rate for every model and ablation. The proposal succeeds if three things hold together:

  • The refiner sits above the boundary-loss baseline at equal latency.
  • The local-MLP ablation falls below the refiner, showing that interior conditioning is doing the work.
  • The mixed-precision refiner stays within one Dice point of FP16.

If the local-MLP ablation matches the refiner, the claim reduces to a known sparse point head. If the boundary-loss baseline matches it, the claim fails outright. Both outcomes will be reported.