# Innovative Approaches to Traffic Anomaly Detection and Classification Using AI
## 2 Algorithms and Methods
### Transformers
CViT operates by training solely on normal video sequences to learn typical behavioral patterns. An encoder-decoder structure, enhanced with CViT blocks on the encoder side, processes video frames. The encoder extracts both local and global features, while the decoder reconstructs the original frame. Anomalies are detected by calculating the difference between the original and reconstructed frames, with larger differences indicating higher likelihoods of anomalies. For frames flagged as anomalous, the localization module uses YOLO to identify objects and compare them with anomalous regions. Overlapping areas are highlighted with red boxes, pinpointing the locations of detected anomalies. The model employs a composite loss function combining intensity, gradient, and structural similarity index measure (SSIM) losses to ensure high-quality reconstructions in both appearance and detail. Evaluations on proprietary data and benchmarks like UCSD, CUHK Avenue, and ShanghaiTech demonstrate that CViT outperforms state-of-the-art methods in detection accuracy and supports real-time processing, making it highly suitable for video surveillance applications. The paper [48] introduces Malta audio-visual anomaly detection (MAVAD), the first dataset specifically designed for anomaly detection in real-world traffic videos. MAVAD includes 764 videos spanning various weather and lighting conditions, with anomalies categorized into 11 classes. Figure 15: Pipeline of the proposed approach for abnormal behavior detection. There is a simple pre-processing part from where the frames are extracted and used for the training of the proposed model. It is also presented the corresponding training feedback for updating parameters and optimizing the model to extract the best feature representation of the frames. At the end, the trained model is applied to different images to validate the correct output of the model. From [47]. The paper also proposes audio-visual anomaly cross-attention (AVACA), a novel method that integrates visual and audio features for anomaly detection. AVACA employs a dual-pathway architecture--one for visual processing and one for audio--fused using a Transformer-based cross-attention layer, as shown in Figure 16. This fusion enables more effective anomaly detection by combining audio and visual cues. Experiments showed that incorporating audio embeddings improves detection performance by 5.2%, with the two Transformers enriching visual representations using audio context. This multimodal approach is particularly effective in scenarios where audio and visual information are closely linked. AVACA is trained with two loss functions: dynamic multiple instance learning loss (LDMIL), which separates anomalous from normal instances, and center loss (LC), which minimizes intra-class variation among normal instances. Additionally, the study evaluates image anonymization's impact on AVACA, reporting an average performance reduction of just 1.7%, demonstrating its robustness even under such conditions. The paper [49] presents a hybrid model that combines GANs with a Transformer model to improve traffic incident detection. The approach addresses challenges such as class imbalance, high false alarm rates, and the need for real-time detection. GANs are used to generate synthetic data, mitigating the dominance of \"non-incident\" events in the dataset, while the Transformer captures global contextual features and complex dependencies. The integration of GANs and Transformers enhances data balance and model adaptability to real-world variations. Experimental evaluations on traffic datasets such as PeMS, I-880 [50], Whitemud Drive [51], and NGSIM demonstrate superior performance, achieving high detection accuracy with low false alarm rates. This paper [52] introduces MOVAD, a real-time video anomaly detection (VAD) architecture designed to enhance the safety of autonomous vehicles by enabling rapid detection of traffic anomalies.