BatchNorm-based Weakly Supervised Video Anomaly Detection
- Publication
- IEEE Transactions on Circuits and Systems for Video Technology 2024Journal
- First submitted to arXiv
- arXiv:2311.15367
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{anomalydetectionbnwvad2023,
title = {{BatchNorm-based Weakly Supervised Video Anomaly Detection}},
author = {Yixuan Zhou and Yi Qu and Xing Xu and Fumin Shen and Jingkuan Song and Heng Tao Shen},
year = {2023},
eprint = {2311.15367},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2311.15367}
}
However many modules a weakly supervised video anomaly detection method wraps around itself, there's one step inside that they all share. During training, nobody knows which segments of an anomalous video actually contain the incident, so you first have to set a criterion, pick out the most suspicious few segments, and train on them as pseudo-labels.
RTFM's criterion is the feature norm, where a large norm means suspicious; UR-DMU's is how much a segment looks like the anomaly memory. The way they pick is much the same too, always taking the top segments by score from each video.
Yixuan Zhou, Yi Qu, Fumin Shen, Xing Xu, Jingkuan Song and Heng Tao Shen of the University of Electronic Science and Technology of China turned their attention to a layer that every network has and hardly anyone gives a second look, BatchNorm.
Defining the problem
The authors list three problems with existing methods.
First, the criteria for picking suspicious segments are unreliable. The feature norm rests on the premise that "anomalous segments have larger norms," which is merely a plausible-looking assumption; picking with learned attention or memories is a black box.
Second, taking a fixed number of segments from every video ignores how much the anomaly ratio varies from video to video. Some videos have only a few seconds of incident; in others the fighting runs from start to finish. The XD-Violence test set has an especially large number of videos with high and scattered anomaly ratios. Pick only segments from each, and the videos with high anomaly ratios lose a whole lot of useful anomalous segments.
Third, wrong picks are bound to happen. As soon as normal segments are taken as anomalous and used to train the classifier, those wrong labels lead the classifier astray, and MIL can only mitigate this, not cure it.
Solving the problem

The BatchNorm mean is "normal"
By convention, weakly supervised video anomaly detection fills each mini-batch with half normal videos and half anomalous videos. Normal videos are all normal segments, and most of an anomalous video is normal segments too, so the vast majority of segments in a batch are normal.
BatchNorm already computes the mean and variance of features over the whole batch. With a batch made up like this, the mean is determined mainly by normal segments and can serve as a reference point for "normal," while anomalous segments look more like outliers. What's more, this reference point also absorbs the normal segments inside anomalous videos, a part the authors think explicit memory modules like UR-DMU's don't make good use of.
The paper also cites the central limit theorem to say that the features in a batch follow a normal distribution. Strictly speaking, the central limit theorem is about the distribution of the sample mean, which is a different matter from what the features themselves look like, but this has no effect on how the method that follows works.
DFM: how far from the mean
If the mean stands for normal, the farther a segment is from it, the more suspicious it is. The authors call this distance DFM (divergence of feature from mean) and compute it as a Mahalanobis distance with a diagonal covariance:
is a diagonal matrix with the per-dimension variances on its diagonal. The and here are BatchNorm's running statistics, the long-term statistics kept as an exponential moving average with momentum 0.1, rather than the values of a single batch. That's more stable, and training and testing use the same reference point.
To make DFM more discriminative, the authors design the MPP (mean-based pull-push) loss. The idea is borrowed from triplet loss, except that the anchor is always the mean . The segments with the largest DFM in normal videos are the positives, to be pulled back near the mean; the segments with the largest DFM in anomalous videos are the negatives, to be pushed farther away:
The margin is set to 1. The paper's equation leaves out the outer ; the official code uses PyTorch's TripletMarginWithDistanceLoss, which has it.
Pick per video, and per batch too

For the second problem, the authors' guess is that the anomaly ratio varies a lot from one video to another, but stays relatively stable over a whole batch. So besides picking a fixed proportion from each video (sample-level selection, SLS), you can also lay out all the anomalous videos in a batch together and pick from them as a whole (batch-level selection, BLS).
In the figure's example, picking two cells per video takes only two from the fourth video, even though it has four high-scoring cells. Picking eight cells across the batch takes all of the fourth video, but the first video, whose anomaly scores are all low, doesn't get a single cell picked. The union of the two is the authors' sample-batch selection (SBS).
Selection ratios are set per dataset. UCF-Crime picks 10% per video and 20% per batch; XD-Violence picks 20% per video and 40% per batch.
The classifier sees only normal videos

For the third problem, the authors' answer is blunt. The classifier never takes an anomaly label at all.
The classifier is trained only on normal videos, pushing the output scores of all their segments toward 0:
The suspicious segments that get picked are used only for the MPP loss and never directly as positives for the classifier. Since they're never treated as positives, wrongly picked segments have no way to teach the classifier bad habits.
The final anomaly score multiplies two signals, the classifier's output and DFM:
In the implementation, the features follow UR-DMU's setup, with I3D features interpolated to 200 segments and passed through UR-DMU's Transformer feature enhancer. After that come two Conv1d layers with kernel size 1 and outputs of 32 and 16 dimensions, each followed by BatchNorm and ReLU and each with its own MPP loss, weighted 5 and 20; the two layers' DFMs are added together. Adam, learning rate , 3000 training iterations.
Discussion
Main results
| Method | UCF-Crime AUC | XD-Violence AP |
|---|---|---|
| RTFM | 84.30 | 77.81 |
| UR-DMU (paper) | 86.97 | 81.66 |
| UR-DMU (this paper's rerun) | 86.23 | — |
| BN-WVAD | 87.24 | 84.93 |
Both datasets use RGB features only. On XD-Violence the gain is more than 3 points, beating even multimodal methods that need audio; with audio features concatenated, it reaches 85.26.
On UCF-Crime, it's only 0.27 above the number in the UR-DMU paper. The authors' take is that the gain may be small, but it's considerable when compared with the 86.23 they got by rerunning UR-DMU with its official code. This argument will come up again shortly.
Ablations
| Setting | UCF-Crime AUC | XD-Violence AP |
|---|---|---|
| Only , with Dropout | 65.21 | 61.54 |
| BatchNorm instead | 82.97 | 72.99 |
| + DFM and MPP | 86.44 | 83.33 |
| + batch-level selection | 87.24 | 84.93 |
The second row is interesting. With the classifier trained only on normal videos and no anomaly supervision at all, simply replacing Dropout with BatchNorm takes UCF-Crime from 65 to 83, on par with several early weakly supervised methods. The authors' explanation is that anomalous videos sit in the same batch and take part in BatchNorm's statistics, so when gradients flow back through BatchNorm, they carry information about the anomalous features.
Batch-level selection adds 1.6 points on XD-Violence, more noticeably than on UCF-Crime, in line with XD-Violence's high anomaly ratio.
DFM also transfers to other methods. Replacing RTFM's norm criterion with DFM takes UCF-Crime from 84.11 to 85.58 and XD-Violence from 74.80 to 80.10. The other way round, switching BN-WVAD's DFM back to the norm costs 1.4 and 2.9 points on the two datasets.
The loss ablation shows DFM's share of the work more clearly. Trained with only and MPP, DFM alone as the score gives 87.1 on UCF-Crime, the classifier by itself 86.8, and their product 87.2. On UCF-Crime, DFM does most of the work. Adding an anomaly loss that trains the classifier on the picked segments actually makes things worse, costing 6 points on XD-Violence, which bears out the design principle of "keep wrongly picked segments away from the classifier."
How to set the selection ratio
The authors swept both selection ratios. On UCF-Crime the best is 20% per batch, which they point out is close to the overall anomaly ratio of 18.2% in the UCF-Crime test set; the XD-Violence test set's anomaly ratio is 49.8%, and its best batch-level ratio is 40%.
The match is intuitive, but in real deployment nobody knows the anomaly ratio of their own test data, so this hyperparameter has to be estimated some other way. Using batch-level selection alone, without per-video selection, also hurts noticeably, because events that appear rarely in a batch, such as XD-Violence's abuse class, get crowded out entirely by the more common fighting.
Reproduction
The official code is public, adapted from UR-DMU's code, but it contains only the XD-Violence training code and one XD-Violence checkpoint.
UCF-Crime, one of the paper's headline numbers, isn't in the repository. When someone asked for it in December 2023, the authors replied that the UCF-Crime code was being reorganized and "will be updated soon," and asked everyone to "stay tuned." The repository's last commit dates from before that reply, November 30, 2023 (nearly three years tuned in, and nothing but static). Another issue asking the authors to release UCF-Crime weights got no reply at all.
So the community had to do it themselves. One person adapted a UCF-Crime version, got only 82% AUC at first, reached 84.8% at best after several reruns, and shared the packaged code in an issue. XD-Violence does have official code, and someone who trained it themselves reported 81.77, against the paper's 84.93.
Think back to the main results. Propping up a 0.27-point lead with your own reproduction numbers is fair enough, of course; it's just that when it's someone else's turn to reproduce this paper's 87.24, there isn't even code to rerun.
Conclusion
BN-WVAD's idea is economical. Most segments in a batch are normal, BatchNorm's mean is already recording "what normal looks like," and the farther a segment is from that mean, the more suspicious it is. This distance is used to pick pseudo-labels and as part of the anomaly score, and the classifier learns only from normal videos, steering clear of wrongly picked segments.
The most convincing ablations are that the criterion still works when moved over to RTFM, and that the classifier does better without anomaly labels. Batch-level selection lives or dies by the dataset's anomaly ratio, helping more the higher the ratio, and its best setting happens to sit right next to the test set's statistics.
If you want to compare against this paper on UCF-Crime, be ready to write your own UCF-Crime training code first.