Weakly Supervised Video Anomaly Detection and Localization with Spatio-Temporal Prompts

Peng Wu, Xuerong Zhou, Guansong Pang, Zhiwei Yang, Qingsen Yan, Yanning Zhang

Introduction

Weakly Supervised Video Anomaly Detection (WSVAD) is a critical task in surveillance, aiming to identify abnormal events using only video-level labels. Traditional methods often struggle with the "needle in a haystack" problem: anomalies typically occupy only a small spatial region and a short temporal window. When models extract global features from entire frames, the dominant "normal" background—such as static buildings or empty roads—frequently drowns out the subtle signal of an anomaly. This leads to low sensitivity and a lack of spatial interpretability, as models cannot pinpoint the specific cause of an alarm.

The STPrompt Framework

To address these challenges, we present STPrompt, a novel framework that decouples temporal detection from spatial localization. By leveraging pre-trained vision-language models (VLMs) like CLIP and large language models (LLMs), STPrompt identifies both when and where an anomaly occurs without requiring expensive pixel-level annotations.

Examples of anomaly detection and spatial localization across various categories in the UCF-Crime dataset.

Motion Prior-aware Spatial Attention Aggregation ($SA^2$)

A core component of STPrompt is the $SA^2$ module, which implements a "divide-and-conquer" strategy. Instead of processing the entire frame uniformly, $SA^2$ utilizes a motion prior calculated from consecutive frame differences. By selecting the "Top-K" most active patches, the model filters out irrelevant background noise and focuses on regions with significant movement, where anomalies are most likely to occur.

Temporal Contextualization

To capture the temporal evolution of events, a lightweight temporal adapter is integrated on top of frozen CLIP features. Unlike standard self-attention, this adapter employs an adjacency matrix based on relative temporal distance, encouraging the model to focus on local temporal patterns essential for recognizing actions like fighting or accidents.

Dual-Branch Prompt Learning

The framework utilizes two distinct branches for anomaly prediction:

  1. Classification Branch: A linear layer that predicts an overall anomaly score.
  2. Alignment Branch: This branch aligns video features with text embeddings of specific anomaly categories (e.g., "Arson," "Shooting"). It uses learnable prompts, inspired by Context Optimization (CoOp), to bridge the domain gap between general CLIP knowledge and specialized surveillance contexts.

Training-Free Spatial Localization

For spatial localization, STPrompt employs a training-free approach powered by LLMs. An LLM generates descriptive text for both normal backgrounds ("a picture of a tree") and anomalous events ("people fighting"). At inference, CLIP matches image patches to these text queries, generating a spatial heatmap that localizes the anomaly within the frame.

Experimental Results

STPrompt was evaluated on three major benchmarks: UCF-Crime, ShanghaiTech, and UBnormal. The model achieves state-of-the-art results, significantly outperforming previous methods like VadCLIP. Notably, STPrompt maintains high efficiency with only 31.5 million parameters, making it more lightweight than many traditional I3D-based architectures.

  • UCF-Crime: Achieved 88.08% AUC for temporal detection and 23.90% TIoU for spatial localization.
  • UBnormal: Reached 63.98% AUC, demonstrating strong generalization to synthetic and unseen anomaly types.

Conclusion

STPrompt demonstrates that effectively ignoring background noise through motion priors and leveraging the zero-shot capabilities of VLMs and LLMs can significantly advance WSVAD. While the training-free spatial localization is a major step forward, future work will focus on refining the query-and-retrieve mechanism to reduce false positives caused by complex backgrounds or unusual non-anomalous movements.

Summary updated

BibTeX
@inproceedings{wu2024weakly,
  author = {Peng Wu and Xuerong Zhou and Guansong Pang and Zhiwei Yang and Qingsen Yan and Peng Wang and Yanning Zhang},
  title = {{Weakly Supervised Video Anomaly Detection and Localization with Spatio-Temporal Prompts}},
  booktitle = {ACM Multimedia},
  year = {2024},
  url = {https://openreview.net/forum?id=2es1ojI14x},
}
Figure