arXiv:2610.29649cs.CVOct 2026

Manuscript Offprint

arXiv:2610.29649

MS2CAST: A Video Anomaly Detection Framework via Multi-Scale Spatial Cross-Attention and Efficient Spatiotemporal Networks

Ali Safaei, Mohammad Kazemi

Abstract

Video anomaly detection (VAD) is a challenging task for surveillance systems due to the scarcity and diversity of anomalous events. While semi-supervised VAD approaches have advanced the field, many rely on computationally intensive optical flow networks to capture motion dynamics. Convolutional neural networks (CNNs) are also widely used for spatial encoding, but their effective receptive field is highly local. To address these limitations, we introduce MS 2^{2}CAST, an end-to-end semi-supervised predictive VAD framework. For spatial encoding, we employ a multi-scale cross-attention encoder that fuses the hierarchical feature representations from a vision transformer (MViTv2-S) and a CNN (ConvNeXt-T) to exploit their distinct receptive fields. To model spatiotemporal dynamics without optical flow estimation, we integrate two interchangeable spatiotemporal modules in the latent space. One module (SwinLSTM) incorporates a Swin Transformer, while the other (VMRNN) integrates Vision Mamba blocks. Our objective function combines L1 loss, Gradient Difference Loss (GDL), and Multi-Scale Structural Similarity Index Measure (MS-SSIM) to ensure pixel-wise accuracy, sharpness, and structural integrity. Evaluations across the UCSD Ped2, CUHK Avenue, and ShanghaiTech datasets demonstrate frame-level Receiver Operating Characteristic (ROC) Area Under the Curve (AUC) scores that are competitive with top-tier techniques while maintaining a peak GPU memory usage of under 1 GB.

Keywords: Video anomaly detection; Multi-scale cross-attention; VMamba; Vision transformers; MS-SSIM

1. Introduction

Anomaly detection in videos aims to detect events that are non-conforming to what is normal and expected across both spatial and temporal dimensions. To ensure safe environments, video anomaly detection (VAD) plays an integral role in modern surveillance systems. However, VAD is a challenging task due to the scarcity and diversity of anomalies. Beyond traditional approaches [1], [2] recent advances in deep learning have revolutionized VAD by defining different learning tasks that are based on various supervision signals. Notably, semi-supervised VAD holds a prominent position in this area of research because it bypasses the need for exhaustively collecting rare anomalous samples. Semi-supervised VAD operates on the assumption that only normal samples are available during training, so the model will only learn normal patterns [3]. Consequently, during model inference, anomalies are detected by flagging any sample that deviates from the learned patterns. Frame reconstruction, frame prediction, and a combination of both prediction and reconstruction are three commonly used paradigms for semi-supervised VAD. For the paradigm based on frame reconstruction, the model learns how to reconstruct current normal input frames during training, which can lead to a high reconstruction error for anomalous frames during inference. However, it is possible for a high-capacity model to be occasionally good at reconstructing abnormal frames with low error, thereby increasing the false negative rate. To prevent the reconstruction of anomalous frames, subsequent studies integrated a memory module into autoencoder architecture [4], [5]. However, memory modules can undesirably increase the reconstruction errors for normal frames [6]. Moreover, a memory-augmented architecture can potentially have poor performance in cross-scene applications because memory items are set up for a specific scene [6]. The frame prediction approach can effectively mitigate the overgeneralization issue associated with reconstruction-based approaches [3].

Although predictive approaches for VAD can address the limitations of reconstruction-based methods, they introduce several challenges. Due to the success of generative adversarial networks (GANs) [7] for future frame prediction [8], they are also frequently used in the VAD literature [9], [10], [11], [12], [13], [14]. However, adversarial training is often unstable and sensitive to hyperparameter choices [15]. Incorporating optical flow to enforce motion constraints is effective and widely used [6], [9], [11], [12], [16], but it is computationally intensive. Moreover, because pre-trained optical flow networks like FlowNet 2.0 [17] and RAFT [18] are usually tuned for specific types of data, using them to estimate optical flow can pose limitations on the adaptability of a VAD model depending on the dataset [19]. Lastly, while L2 loss in pixel space is widely used as one of the training objectives [9], [10], [16], [19], it can result in blurry outputs [8], [20].

Architectures based on convolutional neural networks (CNNs) are commonly used for VAD to encode both spatial features and spatiotemporal dynamics [3]. Although recent VAD studies have introduced transformer-based architectures [19], [21], approaches combining both transformers and CNNs remain underexplored. CNNs and vision transformers (ViTs) generate remarkably different feature maps [22]. While CNNs rely on local receptive fields at early layers that grow gradually, ViTs possess a significantly more global receptive field overall [22]. Recent research on feature fusion has shown promising applications of cross-attention mechanisms across different feature representations [23], [24]. This type of fusion has also been effectively used for VAD architectures in various settings [16], [19]. Cross-attention fusion mechanisms provide a way to compute the correlation between two distinct feature representations. Because anomalies typically occur at different spatial scales, a cross-attention mechanism that fuses distinct feature maps from a CNN and a ViT can enable multi-scale anomaly detection.

Beyond spatial feature extraction, predictive VAD models should also effectively capture temporal dependencies. In the broader context of spatiotemporal forecasting, SwinLSTM [25] and VMRNN [26] were proposed to improve predictive performance over ConvLSTM [27]. SwinLSTM incorporates Swin Transformer blocks [28], utilizing window-based and shifted window-based multi-head self-attention. This design achieves the representational power of global self-attention with significantly reduced computational demands. Alternatively, VMRNN integrates Vision Mamba blocks [29], employing the 2D Selective Scan (SS2D) mechanism to extend 1D sequential scanning to 2D spatial scanning, which makes state space models (SSMs) capable of processing spatial information. As alternatives to ConvLSTM, both SwinLSTM and VMRNN are computationally much more efficient and generate higher-quality frames in future frame prediction tasks [26].

In this paper, we propose MS 2^{2}CAST, a predictive VAD framework that integrates a spatial cross-attention mechanism to leverage the feature representations of both ViTs and CNNs for spatial encoding. Our architecture employs parallel pathways to extract multi-scale spatial feature maps from RGB frames. Then, these maps are fused via a spatial cross-attention mechanism and passed through the latent space and skip connections. To effectively capture spatiotemporal dynamics, we integrate VMRNN and SwinLSTM as interchangeable modules in the latent space. Inspired by previous research in future frame prediction [8] and image restoration [20], our loss function combines L1 loss, Multi-Scale Structural Similarity Index Measure (MS-SSIM), and Gradient Difference Loss (GDL). In summary, our main contributions are:

  • We introduce MS 2^{2}CAST, a novel end-to-end framework for semi-supervised VAD, leveraging the distinct receptive fields of ViTs and CNNs through a hierarchical spatial cross-attention mechanism.

  • We seamlessly integrate VMRNN and SwinLSTM as alternative components into our architecture to efficiently capture motion dynamics without relying on computationally intensive optical flow networks.

  • We design a loss function by merging L1 loss to preserve pixel-space fidelity, MS-SSIM to maintain perceptual integrity, and GDL to generate sharp edges within predicted frames.

  • Our comprehensive evaluations across three public datasets demonstrate that our method achieves strong frame-level Receiver Operating Characteristic (ROC) Area Under the Curve (AUC) scores on par with top-tier techniques while maintaining peak GPU memory usage under 1 GB.

References (56)