Skip to content

NK-II/Context-Aware-Zero-Shot-Anomaly-Detection-in-Surveillance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

This repository contains the research implementation of our thesis on Zero-Shot Anomaly Detection in surveillance video.
Our framework integrates transformer-based spatiotemporal encoding (TimeSformer), predictive coding via DPC-RNN, and semantic alignment through CLIP.
We further employ context conditioning with FiLM modulation for scene-aware generalization.

📄 Read the full manuscript on arXiv


Key Contributions

  • Transformer-based encoder: TimeSformer captures long-range spatiotemporal features from video sequences.
  • Predictive coding: DPC-RNN forecasts future representations to model temporal consistency.
  • Semantic alignment: CLIP-based contrastive learning bridges vision and language for zero-shot generalization.
  • Context conditioning: FiLM modulation dynamically adapts representations to scene attributes.
  • Training objectives: InfoNCE and CPC losses drive robust temporal and semantic learning.
  • Evaluation: Validated on the UCF-Crime dataset for anomaly detection.

Getting Started

Installation

git clone https://github.com/NK-II/Context-Aware-Zero-Shot-Anomaly-Detection-in-Surveillance
.git
cd Context-Aware-Zero-Shot-Anomaly-Detection-in-Surveillance
python -m venv .venv
source .venv/bin/activate   # (Linux/Mac)
.venv\Scripts\activate      # (Windows)
pip install -r requirements.txt

---

### Dataset
We use the [UCA(UCF Crime Annotation) Dataset](https://www.kaggle.com/datasets/vigneshwar472/ucaucf-crime-annotation-dataset) (Kaggle).  
- Place raw videos under `videos/` (ignored in `.gitignore`).  
- Data splits are provided under `data/` (train/val/test lists).  
See `DATASET.md` for setup instructions.  

---

## Repository Structure
project/
├── src/                # Core implementation
├── data/               # Split files (kept in repo)
├── videos/             # Raw dataset (not pushed, user downloads separately)
├── configs/            # Configurations
├── docs/
│   └── paper.pdf       # Full thesis / preprint
├── requirements.txt
├── README.md
└── .gitignore

Citation

If you use this work, please cite our paper and repository:

Paper (preferred):

@article{anomaly2025,
  title   = {Context-Aware Zero-Shot Anomaly Detection in Surveillance Using Contrastive and Predictive Spatiotemporal Modeling},
  author  = {Khan, Md. Rashid Shahriar and Hasan, Md. Abrar and Justice, Mohammod Tareq Aziz},
  journal = {arXiv preprint arXiv:2508.xxxxx}, 
  year    = {2025}
}

Code (if you reference the implementation directly):

@misc{anomaly2025code,
  title        = {Context-Aware Zero-Shot Anomaly Detection in Surveillance Using Contrastive and Predictive Spatiotemporal Modeling},
  author       = {Khan, Md. Rashid Shahriar and Hasan, Md. Abrar and Justice, Mohammod Tareq Aziz},
  year         = {2025},
  howpublished = {\url{https://github.com/NK-II/Context-Aware-Zero-Shot-Anomaly-Detection-in-Surveillance}},
  note         = {GitHub repository}
}

License

This project is licensed under the MIT License – see the LICENSE file for details.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages