Multi-Scale Representations by Varying Window Attention for Semantic Segmentation

Haotian Yan, Ming Wu, Chuang Zhang

Semantic segmentation requires models to interpret visual information across vastly different scales—from fine-grained textures to global scene structures. Traditional approaches, such as Atrous Spatial Pyramid Pooling (ASPP) or hierarchical backbones like Swin Transformers, attempt to capture this multi-scale context. However, these methods often suffer from "scale inadequacy" and "field inactivation," where the Effective Receptive Field (ERF) is either too sparse or fails to cover critical scales.

To address these limitations, researchers introduced Varying Window Attention (VWA) and the VWFormer decoder. This approach disentangles the query and context windows, allowing for a more flexible and efficient multi-scale representation that significantly outperforms industry standards.

The Limitations of Current Multi-Scale Learning

Analysis of Effective Receptive Fields (ERF) reveals that many state-of-the-art models do not utilize their theoretical receptive fields effectively. Two primary issues emerge:

  1. Scale Inadequacy: Models may capture global context but lose the local precision necessary for sharp boundaries, or vice versa. They often miss specific scales required for complex scene parsing.
  2. Field Inactivation: Large receptive fields often contain "dead zones" where the model fails to attend to relevant pixels. This leads to sparse and inefficient feature learning, where the model is "looking" at a large area but not actually "seeing" the data within it.

Varying Window Attention (VWA)

The core innovation of this work is the Varying Window Attention (VWA) mechanism. In standard Local Window Attention (LWA), the query and context windows are identical in size. VWA breaks this symmetry: while the query window remains local, the context window is expanded by a ratio $R$. This allows the model to gather information from a broader area without losing the local specificity of the query.

To make this computationally feasible and robust, the authors introduced three key techniques:

  • Pre-scaling via Densely Overlapping Patch Embedding (DOPE): Simply enlarging the context window would increase computational costs by $R^2$. Instead, DOPE downsamples the context before the attention calculation. This keeps the memory footprint and FLOPs nearly identical to standard local attention while providing a much larger field of view.
  • Copy-Shift Padding (CSP): Standard zero-padding at image boundaries often leads to "attention collapse," where the model focuses on uninformative zeros. CSP shifts the context window back toward valid image features, ensuring every query has a rich, non-zero context even at the edges of an image.
  • VWFormer Decoder: This is a multi-scale decoder that takes features from a backbone and processes them through parallel VWA branches with different enlargement ratios (e.g., $R=2, 4, 8$).

Experimental Performance

The effectiveness of VWFormer was validated on major benchmarks, including ADE20K, Cityscapes, and COCOStuff-164k. The results demonstrate that a smarter decoder can make a medium-sized backbone perform like a much larger one.

Efficiency vs. UPerNet

On the ADE20K dataset, VWFormer paired with a Swin-B backbone achieved a 52.5 mIoU using only 120G FLOPs. In comparison, the standard UPerNet achieved a lower 50.8 mIoU while consuming 306G FLOPs. This represents a significant accuracy boost while slashing computational costs by approximately 45%.

Outperforming SegFormer

VWFormer consistently outperformed the popular SegFormer (MLP-decoder) across all backbone sizes, from the lightweight MiT-B0 to the large MiT-B5. Qualitative results show that VWFormer is particularly better at maintaining "inner consistency"—for instance, correctly identifying an entire large object like a sofa rather than mislabeling segments of it as different furniture types.

Plug-and-Play Gains

The mechanism is highly versatile. When added to the state-of-the-art Mask2Former, VWFormer provided a "free" boost of 1.0% – 1.3% mIoU with negligible computational overhead (approximately 10G FLOPs).

Conclusion and Future Work

Varying Window Attention represents a significant step forward in efficient multi-scale modeling. By disentangling query and context and optimizing the receptive field through DOPE and CSP, VWFormer achieves superior accuracy with significantly lower computational requirements.

While the current work focuses on the decoder, future research may involve integrating VWA directly into hierarchical backbones. Additionally, exploring automated ways to determine optimal context ratios ($R$) for specialized imagery—such as medical or satellite data—remains a promising avenue for further study.

Summary updated

BibTeX
@inproceedings{yan2024multi,
  author = {Haotian Yan and Ming Wu and Chuang Zhang},
  title = {{Multi-Scale Representations by Varying Window Attention for Semantic Segmentation}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=lAhWGOkpSR},
}
Figure