Transformer Based Self-Context Aware Prediction for Few-Shot Anomaly Detection in Videos
Video anomaly detection faces challenges from diverse anomaly types and severe scarcity of labeled anomalies. This paper proposes a self-context-aware one-class few-shot Transformer framework that trains video-specific models using only the initial normal frames of each video. Leveraging self-supervised temporal attention, the model predicts subsequent frame features and localizes anomalies at the frame level via prediction–ground-truth feature residuals. Crucially, it requires no anomalous samples, enabling both video-specific modeling and dynamic contextual adaptation. The core innovation lies in deeply integrating self-attention with one-class few-shot temporal forecasting to establish an end-to-end reconstruction-residual detection paradigm. Extensive experiments demonstrate significant improvements over state-of-the-art methods across multiple standard benchmarks. Ablation studies confirm that the self-context mechanism critically enhances both detection accuracy and cross-scenario generalization.