TL;DR
Finding pedestrians in gigapixel, kilometer-wide images is literally a needle-in-a-haystack problem—most of the image is empty, yet existing sparse vision transformers waste massive compute staring at rustling leaves and brick walls. SpanFormer fixes this by teaching the network what actual objects look like, adjusting how much of each image to process based on crowd size, and allowing nearby object clusters to talk to each other. The result is higher detection accuracy at less than a quarter of the backbone compute cost.
What Problem Does This Paper Address?
Imagine looking down from a blimp at a sprawling city plaza with a billion-pixel camera. Unlike standard close-up datasets (like MS COCO), these High-Resolution Wide (HRW) shots have three quirks: targets occupy less than 5% of the pixels, crowd density swings from five people to five thousand across scenes, and groups of objects can stretch across thousands of pixels.
To survive the massive resolution, state-of-the-art detectors (like SparseFormer) chop images into small $7\times7$ windows and only process a fixed fraction ($top\text{-}k$) of them. However, their selection recipe has three blind spots:
- Texture obsession: They rank windows using hand-crafted pixel variance (high-frequency residuals). Busy, object-free backgrounds like foliage or patterned roofs look "interesting" and steal compute from actual targets.
- Rigid budgets: A fixed $top\text{-}k$ keep-ratio wastes compute on empty plazas and drops real people in crowded stadiums.
- Tunnel vision: Kept windows only attend internally within their tiny $7\times7$ grid, blinding the model to broader crowd context.
Methods
SpanFormer drops into standard hierarchical vision backbones (preserving standard Swin-style shifted windows and global summary tokens) and replaces the naive selection-and-attention pipeline with three lightweight modules that add less than 1% extra parameters:
- Prototype Routing (Semantic Span): Instead of measuring raw texture variance, each stage maintains two learnable template vectors—a foreground prototype and a background prototype. Window summaries are scored via cosine similarity against these templates to learn true "objectness." An anti-collapse hinge loss ($\mathcal{L}_{\text{bal}}$) ensures both prototypes stay active rather than collapsing into a single mode.
- Dynamic Top-$k$ (Compute Span): A tiny two-layer MLP looks at a pooled $3\times3$ grid of the scene and predicts a custom keep-ratio $r \in (0, 1)$ per image. Because sorting ($top\text{-}k$) isn't cleanly differentiable, the MLP is supervised directly against the ground-truth fraction of object-containing windows ($\mathcal{L}_{\text{dynk}}$).
- Cluster Memory Attention / CMA (Attention Span): On the GPU, SpanFormer links kept windows into clusters on-the-fly using Union-Find if they are both semantically similar (cosine similarity $> 0.85$) and spatially close (Chebyshev distance $\le 2$). During local self-attention, a window's Keys and Values are augmented with single-token summaries from its cluster siblings. Crucially, CMA reuses the local branch's $W_K$ and $W_V$ projection matrices, expanding the receptive field at zero added projection parameter cost.
Datasets
- PANDA: The primary evaluation benchmark, featuring gigapixel-level, human-centric wide-angle scenes. Images are tiled into $1280\times800$ patches for training and evaluated via standard COCO Average Precision (AP) protocols.
- DOTA: An aerial object detection dataset (referenced by the authors as additional validation in the appendices). No new datasets are introduced.
Key Insights and Ideas
- Variance is a terrible proxy for objectness: Simply swapping hand-crafted texture statistics for two learnable prototype vectors immediately boosts $\text{AP}_{50}$ by +1.0% while cutting FLOPs by nearly 24%, proving how much compute prior models wasted on trees and facades.
- Unconstrained adaptive budgets get "lazy": Ablations show that if you remove the ground-truth fraction supervision ($\mathcal{L}_{\text{dynk}}$), the dynamic selector refuses to prune—drifting toward keeping almost everything and ballooning compute from 17.5 GFLOPs to 91.4 GFLOPs for zero accuracy gain.
- Long-range context doesn't require heavy parameters: By routing compact window summaries rather than full $7\times7$ token grids—and sharing local $K/V$ weights—CMA connects sprawling crowds across windows while adding just 0.8 milliseconds of latency per patch.
Key Results
Plugged into the DINO detector on PANDA, SpanFormer establishes a new accuracy–efficiency Pareto frontier:
- Accuracy & Compute: Reaches 80.3% $\text{AP}_{50}$ at 17.53 backbone GFLOPs—beating the SparseFormer baseline (78.0% at 75.71 GFLOPs, a >75% FLOPs reduction) and outperforming the recent Mixture-of-Experts GigaMoE (79.1% at 51.24 GFLOPs, a >65% FLOPs reduction). Similar gains hold with a Dynamic-Head detector (78.6% $\text{AP}_{50}$ at 17.04 GFLOPs).
- Real-World Speed: On an RTX 3090 (batch size 16), backbone latency drops from 22.2 ms to 12.5 ms per patch ($1.78\times$ speedup) while lowering peak memory from 5.67 GB to 5.05 GB.
Limitations and Future Work
While the authors do not include a dedicated limitations section in the main text, a clear practical bottleneck emerges in their timing experiments: Amdahl's Law at the detection head. While SpanFormer accelerates the backbone by $1.78\times$, end-to-end DINO detector latency only improves by $1.13\times$ (from 61.1 ms to 54.2 ms per patch at batch size 3). Why? Because the unmodified DINO detection head eats up a fixed ~38 ms of runtime. Future work in gigapixel detection will likely need to extend this multi-level adaptive sparsity out of the backbone and directly into the heavy encoder/decoder detection heads.
Summary updated