Context-Aware Zero-Shot Anomaly Detection in Surveillance Using Contrastive and Predictive Spatiotemporal Modeling

Md. Rashid Shahriar Khan, Md. Abrar Hasan, Mohammod Tareq Aziz Justice
8/25/2025
cs.CVcs.LG

Official code: NK-II/Context-Aware-Zero-Shot-Anomaly-Detection-in-Surveillance (1 star, MIT, PyTorch, last commit 2025-08-27).

Abstract

Detecting anomalies in surveillance footage is inherently challenging due to their unpredictable and context-dependent nature. This work introduces a novel context-aware zero-shot anomaly detection framework that identifies abnormal events without exposure to anomaly examples during training. The proposed hybrid architecture combines TimeSformer, DPC, and CLIP to model spatiotemporal dynamics and semantic context. TimeSformer serves as the vision backbone to extract rich spatial-temporal features, while DPC forecasts future representations to identify temporal deviations. Furthermore, a CLIP-based semantic stream enables concept-level anomaly detection through context-specific text prompts. These components are jointly trained using InfoNCE and CPC losses, aligning visual inputs with their temporal and semantic representations. A context-gating mechanism further enhances decision-making by modulating predictions with scene-aware cues or global video features. By integrating predictive modeling with vision-language understanding, the system can generalize to previously unseen behaviors in complex environments. This framework bridges the gap between temporal reasoning and semantic context in zero-shot anomaly detection for surveillance. The code for this research has been made available at https://github.com/NK-II/Context-Aware-Zero-Shot-Anomaly-Detection-in-Surveillance.

View on arXivView PDF

Code Implementations(1)

PyTorchMIT

A research implementation of a context-conditioned, zero-shot video anomaly detection framework that integrates spatiotemporal features extracted via TimeSformer with contrastive predictive coding and semantic alignment through CLIP. The repository includes training and evaluation pipelines, configuration files, and the accompanying thesis/paper.

11PythonAug 21, 20251 years agoMIT
clipcontrastive-learningcontrastive-predictive-codingpredective-modelingpytorch+5 more

Similar Papers

Cite this paper

@article{khan2025contextaware,
  title  = {Context-Aware Zero-Shot Anomaly Detection in Surveillance Using Contrastive and Predictive Spatiotemporal Modeling},
  author = {Md. Rashid Shahriar Khan and Md. Abrar Hasan and Mohammod Tareq Aziz Justice},
  year   = {2025},
  eprint = {2508.18463},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.18463v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.18463.svg)](https://codeofpaper.com/paper/2508.18463)

Discussion