Weakly Supervised Temporal Anomaly Segmentation with Dynamic Time Warping

Dongha Lee, Sehun Yu, Hyunjun Ju, Hwanjo Yu

Locating anomalies in time-series data or video is a classic "Goldilocks" problem. Unsupervised methods are often too noisy, while fully supervised methods are prohibitively expensive due to the need for millisecond-accurate labels. In "Weakly Supervised Temporal Anomaly Segmentation with Dynamic Time Warping," Lee et al. introduce WETAS, a framework that utilizes "weak" instance-level labels—simply knowing if an anomaly occurred at some point—to precisely segment where that anomaly starts and ends.

The Problem: Bridging the Gap Between Points and Instances

Traditional anomaly detection typically falls into two categories: point-level detection (identifying specific anomalous timestamps) and instance-level classification (determining if an entire sequence is anomalous).

The gap lies in temporal segmentation: identifying the specific start and end points of an event. Point-level methods often produce "jittery" results—disconnected points that are difficult for humans to interpret as a single event. Conversely, instance-level labels are easy to acquire but lack localization. WETAS addresses the challenge of training a model to find precise boundaries using only coarse, "yes/no" labels for the entire sequence.

Methodology: The WETAS Framework

WETAS employs a two-stage approach integrated into a single training loop:

  1. Feature Extraction: A Dilated Causal Convolutional Neural Network (DiCNN) captures long-term dependencies, providing context for each time point based on its history.
  2. Sequential Pseudo-Labeling: Inspired by Class Activation Maps (CAM), the model identifies segments that contribute most to an "anomaly" classification, creating a rough "pseudo-label" sequence.
  3. Dynamic Time Warping (DTW) Alignment: This is the core innovation. Because pseudo-labels may not perfectly match the input timing, the authors use soft-DTW. This differentiable version of the DTW algorithm allows the model to "stretch" or "shrink" the alignment between input data and pseudo-labels during training.
  4. Dual Loss Function: The model optimizes for both Classification Loss ($L_c$) (correctly identifying anomalous instances) and Alignment Loss ($L_a$) (ensuring predicted scores align with pseudo-labels).
The WETAS architecture integrates DiCNN for feature extraction with a soft-DTW alignment layer to map predicted anomaly scores to sequential pseudo-labels.

Experimental Results

The researchers evaluated WETAS on four diverse real-world datasets: EMG (muscle activity), GHL (gasoil plant), SMD (server monitoring), and Subway (surveillance video).

WETAS significantly outperformed unsupervised and weakly supervised baselines like DeepMIL:

  • Performance: On the SMD dataset, WETAS achieved an F1-score of 0.4358, surpassing the best DeepMIL variant (0.3568).
  • Interpretability: Qualitative results demonstrate that while point-level detectors produce spiky, disconnected predictions, WETAS generates clean, continuous blocks that closely match ground-truth boundaries.
  • Video Domain: On the Subway dataset, WETAS achieved a 97.8% AUROC, outperforming domain-specific unsupervised detectors.
Qualitative comparison across different methods. WETAS produces continuous segments that align closely with ground-truth, avoiding the fragmentation seen in point-level or MIL-based approaches.

Conclusion

By shifting the focus from independent points to continuous segments and leveraging the flexibility of Dynamic Time Warping, WETAS provides a robust solution for real-world anomaly localization. It effectively handles variable-length anomalies without requiring expensive point-by-point ground truth, making it a practical tool for industrial and surveillance applications.

Summary updated

BibTeX
@inproceedings{lee2021weakly,
  author = {Dongha Lee and Sehun Yu and Hyunjun Ju and Hwanjo Yu},
  title = {{Weakly Supervised Temporal Anomaly Segmentation with Dynamic Time Warping}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00726},
}
Figure