Local Memory Attention for Fast Video Semantic Segmentation

Matthieu Paul, Martin Danelljan, Luc Van Gool, Radu Timofte

Abstract

Video semantic segmentation is critical for autonomous systems but often suffers from high computational costs or temporal inconsistency. We present LMANet, a lightweight module that leverages a local memory attention mechanism to incorporate temporal context from preceding frames. By restricting attention to local neighborhoods, LMANet avoids the quadratic complexity of global attention while effectively filtering spatial noise. Our approach achieves significant accuracy improvements on the Cityscapes dataset—up to +2.1% mIoU—with minimal inference overhead, making it suitable for real-time applications.

1. Introduction

Semantic segmentation—the task of assigning a class label to every pixel—is a cornerstone of autonomous driving. While most models process video frame-by-frame, this approach ignores the rich temporal context available in a video stream. Existing methods to exploit this data usually rely on computationally expensive optical flow or difficult-to-train Recurrent Neural Networks (RNNs).

Overview of the LMANet pipeline showing temporal memory integration.

LMANet addresses this gap with a simple, fast, and general module that can be integrated into virtually any existing architecture to improve temporal consistency and accuracy without sacrificing real-time performance.

2. Methodology

The Local Memory Attention Network (LMANet) consists of three main components designed for efficiency and accuracy.

2.1 Memory Module

LMANet maintains an explicit memory that stores "Keys" (low-dimensional features) and "Values" (rich semantic features) from the last few frames ($S=3$ to $5$). Unlike RNNs, this memory is updated at every step, providing a stable temporal reference.

2.2 Local Key Matching

Standard Transformer-style attention compares every pixel in the current frame to every pixel in memory, resulting in $O((HW)^2)$ complexity. LMANet exploits a temporal prior: an object at a given position is likely to remain in the same neighborhood in the next frame. By limiting the search to a local radius ($R$), complexity is reduced to $O(HW \cdot R^2)$, which also filters out "wrong correlations" from similar-looking objects elsewhere in the scene.

Detailed architectural diagram of LMANet, illustrating the encoder-decoder structure with memory read and fusion blocks.

2.3 Attention-based Fusion

Once relevant features are read from memory, a fusion module decides how much to trust the memory versus the current frame. It uses sigmoid-activated gates to handle dynamic events like occlusions or new objects entering the frame.

3. Experimental Results

The researchers evaluated LMANet on the Cityscapes dataset, using both the lightweight ERFNet and the accuracy-focused PSPNet backbones.

  • Quantitative Gains: ERFNet + LMANet improved mIoU by 1.67% (72.05% → 73.72%) with only 1.5ms of overhead. PSPNet + LMANet saw a 2.14% mIoU boost.
  • Efficiency: Local attention is significantly more memory-efficient. For a search radius of $R=21$, GPU memory overhead was only 13%, compared to 166% for global matching.
  • Qualitative Stability: The model showed much better temporal stability, specifically reducing flickering on thin or distant objects like traffic lights and barriers.

4. Conclusion and Future Work

LMANet demonstrates that locality is a powerful inductive bias for video segmentation. While the current two-step training process and fixed search radius are areas for improvement, the module provides a superior speed-to-accuracy trade-off. Future work may explore adaptive search regions or integrating sparse global memory to handle long-term occlusions.

Summary updated

Abstract

We propose a novel neural network module that transforms an existing single-frame semantic segmentation model into a video semantic segmentation pipeline. In contrast to prior works, we strive towards a simple, fast, and general module that can be integrated into virtually any single-frame architecture. Our approach aggregates a rich representation of the semantic information in past frames into a memory module. Information stored in the memory is then accessed through an attention mechanism. In contrast to previous memory-based approaches, we propose a fast local attention layer, providing temporal appearance cues in the local region of prior frames. We further fuse these cues with an encoding of the current frame through a second attention-based module. The segmentation decoder processes the fused representation to predict the final semantic segmentation. We integrate our approach into two popular semantic segmentation networks: ERFNet and PSPNet. We observe an improvement in segmentation performance on Cityscapes by 1.7% and 2.1% in mIoU respectively, while increasing inference time of ERFNet by only 1.5ms. Source code is available at https://github.com/mattpfr/lmanet.
BibTeX
@inproceedings{paul2021local,
  author = {Matthieu Paul and Martin Danelljan and Luc Van Gool and Radu Timofte},
  title = {{Local Memory Attention for Fast Video Semantic Segmentation}},
  booktitle = {IEEE/RSJ International Conference on Intelligent Robots and Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=ohTEqkGxRK1},
}
Figure