Video Anomaly Detection By The Duality Of Normality-Granted Optical Flow

Hongyong Wang, Xinjian Zhang, Su Yang, Weishan ZhangarXiv 2021

TL;DR

This paper introduces a novel video anomaly detection framework that exploits the "duality" of a normality-granted optical flow model. By training a network to predict future optical flow from a single frame using only normal video data, the model generates accurate motion vectors for normal events but highly inaccurate "normal-looking" noise for anomalies. This intentional mismatch sabotages subsequent future frame predictions, making abnormal events highly conspicuous and easy to detect via standard image quality metrics.

What Problem Does This Paper Address?

Video Anomaly Detection (VAD) is crucial for automated surveillance, but it is inherently challenging because "anomalies" are diverse, unpredictable, and rarely labeled. Consequently, most state-of-the-art methods rely on unsupervised learning, training exclusively on normal video data. The core assumption is that a model trained only on normalcy will fail to accurately reconstruct or predict abnormal events, leaving a high error signal that flags the anomaly.

However, existing prediction-based methods often suffer from temporal conflict. Many architectures force the current video frame and its corresponding future optical flow to share the same latent space during reconstruction. This is fundamentally mismatched because optical flow represents future pixel displacement, while the frame represents the present appearance. Furthermore, general video prediction models try to predict all frames perfectly; for VAD, we actually want a model that fails spectacularly when encountering an anomaly, maximizing the prediction error gap between normal and abnormal events.

Methods

The authors propose a two-stage, prediction-based pipeline that cleanly separates appearance and motion to avoid temporal conflict.

Figure 2. Overview of our network. Our model consists of two sub-networks, applied for motion and frame prediction respectively. Our motion prediction model Fm marked by the blue box is to predict the optical flow from the current frame. And guided by this optical flow, our frame prediction model Ff marked by the orange box will predict the next frame. Note that, our motion and frame prediction model are different in detail of every Block, though they are the same name.
  1. Motion Prediction Sub-network ($F_m$): This U-Net-based model takes a single current frame ($I_t$) and predicts the normality-granted optical flow ($\hat{O}_{t,t+1}$). To better capture spatial features, the authors replace the first two standard convolution layers with a multi-scale feature extraction block consisting of four parallel convolutions with different kernel sizes. It is trained using an $L_1$ loss against pseudo-ground-truth optical flow generated by a pre-trained PWC-Net.
  2. Frame Prediction Sub-network ($F_f$): This network predicts the next frame ($\hat{I}_{t+1}$) using both the current frame ($I_t$) and the predicted optical flow ($\hat{O}_{t,t+1}$). Instead of directly warping the image with the flow vectors (which is highly sensitive to noise), they use a region-correspondence learning tactic by concatenating the frame and flow map along the channel dimension before passing them through convolutional layers.

Loss Functions

To optimize frame prediction, the authors combine two losses:

  • Dense Loss ($L_{dense}$): A standard $L_2$ distance to ensure the predicted frame is close to the ground truth.
  • Margin Loss ($L_{margin}$): Modified from Triplet Loss, this novel constraint forces the predicted frame to be further away from the current frame ($I_t$) by a margin $\alpha$. This prevents the model from lazily copying the current frame to the next frame and forces it to actively learn the transformation dynamics.

$$\text{Final Loss: } L_{frame} = L_{dense} + \lambda L_{margin}$$

Datasets

The model was evaluated on three standard, progressively challenging video anomaly detection benchmarks:

  • UCSD Ped2: 16 training and 12 testing videos featuring pedestrian areas invaded by anomalies like bicycles, cars, and wheelchairs.
  • CUHK Avenue: 16 training and 21 testing clips captured from a fixed camera, containing challenging anomalies like running or throwing objects.
  • ShanghaiTech: A large-scale, highly complex dataset consisting of 13 different scenes with 330 training and 107 testing videos, including sudden motion anomalies and group brawls.

Key Insights and Ideas

  • The Duality of Normality-Granted Flow: Because the motion network only learns from normal data, it acts as a rigid filter. When an anomaly occurs (e.g., a motorcycle speeding through a campus), the network cannot map this to an "abnormal" flow. Instead, it forces the prediction into a "normal mode" (e.g., predicting the motion of a typical walking pedestrian). This creates a massive discrepancy between the predicted flow and reality, turning the optical flow into destructive noise for the subsequent frame prediction step.
Figure 1. The effectiveness of duality of normality-granted optical flow in our model. As shown in the top part, the predicted optical flow of the abnormal behavior labeled by the red box is evidently different from the ground truth. But for the normal behavior of the near pedestrian, the predicted optical flow is relatively closer to the ground truth. This discrepancy will determine the optical flow guidance works for help or disturbance in the frame predic- tion, as the abnormal region in the predicted frame is more blurry. In the bottom part, we estimate the quality of the predicted frame by calculating the PSNR of patches with 64 × 64 pixels. In PSNR masks, the darker patch suggests the higher confidence to anoma- lies, where we can see that the only one potential anomaly patch in the last mask meets the abnormal region in It+1.
  • Single-Frame Flow Prediction: By predicting optical flow from just one frame rather than a sequence, the model is forced to learn the direct translation from static spatial appearances to expected normal motion patterns, preventing it from accidentally generalizing to unseen abnormal motions.
  • Convolutions Over Warping: Directly warping pixels using predicted optical flow often propagates artifacts if the flow is noisy. Using channel concatenation and subsequent convolutions allows the network to robustly fuse appearance and motion context.

Key Results

The method achieved state-of-the-art (SOTA) performance on two of the three benchmarks using the Area Under Curve (AUC) of the Receiver Operating Characteristic (ROC) metric:

  • CUHK Avenue: Achieved 88.4% AUC, outperforming the previous best method (AMC at 86.9%).
  • ShanghaiTech: Achieved 75.3% AUC, setting a new SOTA benchmark against existing models like AnoPCN (73.6%).
  • UCSD Ped2: Reached a highly competitive 94.2% AUC.
  • Inference Speed: The pipeline runs comfortably in real-time. On a single NVIDIA GeForce 1080Ti GPU, the frame prediction step runs at 77 fps, and the complete detection pipeline (including anomaly scoring via patch-based PSNR) runs at 47 fps.

An ablation study confirmed that adding the optical flow guidance provided a ~3% boost in AUC performance, while the margin loss contributed an additional ~1% improvement.

Limitations and Future Work

The authors note that their performance on the UCSD Ped2 dataset did not beat the SOTA. They attribute this to their reliance on PWC-Net to generate the ground-truth optical flow targets during training. On the low-resolution, older UCSD Ped2 dataset, PWC-Net introduces significant background noise and blends pedestrian boundaries, which trickles down and degrades their motion predictor's accuracy.

Additionally, while the model successfully amplifies errors for abnormal frames, it still generates minor prediction errors on perfectly normal frames, which keeps the system from achieving a flawless anomaly detection rate. Future work could involve exploring more robust unsupervised optical flow estimators that adapt better to low-quality video streams.

Summary updated

BibTeX
@misc{wang2021video,
  author = {Hongyong Wang and Xinjian Zhang and Su Yang and Weishan Zhang},
  title = {{Video Anomaly Detection By The Duality Of Normality-Granted Optical Flow}},
  year = {2021},
  eprint = {2105.04302},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.04302},
}
Figure