A compressed domain video anomaly detection method based on conditional diffusion model

By using a conditional diffusion model and sparse sampling techniques in the compressed domain, the complexity and accuracy issues of video anomaly detection on edge servers are resolved, achieving efficient and low-complexity video anomaly detection that is adaptable to different scenarios.

CN117376575BActive Publication Date: 2026-11-20XI AN JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311343737.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-17
Publication Date
2026-11-20
Estimated Expiration
2043-10-17

AI Technical Summary

Technical Problem

Existing video anomaly detection methods are difficult to deploy on edge servers, have high complexity, and insufficient detection accuracy. In particular, the need for complete decoding of compressed video and optical flow extraction leads to excessive computational and storage resource requirements.

Method used

A compressed-domain video anomaly detection method based on a conditional diffusion model is adopted. By sparse sampling to preserve I-frames and motion vectors, and combining reconstruction and frame prediction, anomaly detection is performed in the compressed domain using a conditional diffusion model, including an autoencoder and a Unet noise predictor. This method operates directly in the compressed domain, avoiding decoding and optical flow extraction.

Benefits of technology

It achieves efficient and low-complexity video anomaly detection on edge servers, reducing time and memory consumption, improving detection accuracy, avoiding mode collapse, and adapting to different scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117376575B_ABST
    Figure CN117376575B_ABST
Patent Text Reader

Abstract

The application discloses a compressed domain video anomaly detection method based on a conditional diffusion model, which comprises the following steps: sparse sampling of input compressed video stream; regarding one I frame and three P frames after the I frame as a group of pictures (GoP); regarding the mean square error (MSE) of reconstructed MV and original MV as an abnormal reconstruction score; regarding the last I frame in the input as a target I frame, performing diffusion operation on the frame, and then adding noise; taking the target I frame after adding noise as input, taking the splicing of the reconstructed MV and the I frame corresponding in time sequence on a channel as a condition, and inputting into a noise predictor Unet to perform noise prediction; weighting the abnormal reconstruction score and the abnormal prediction score obtained in the above steps, so that the final abnormal score is obtained; processing different video streams in the data set, so that the abnormal score of the entire data set is obtained, and the final compressed domain video anomaly detection result is obtained. The application reduces complexity while maintaining high detection performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of electronic information technology, specifically relating to a compressed domain video anomaly detection method based on a conditional diffusion model. Background Technology

[0002] Video anomaly detection (VAD) is a key and challenging task in computer vision. With the widespread application of surveillance technology, manual anomaly identification has become increasingly difficult. Therefore, this task must be delegated to automated systems. The main objective of this task is to detect anomalies interspersed within normal scenes; these anomalies are typically categorized into appearance anomalies and motion information anomalies. The diversity of anomalies and the difficulty of collecting them make it impossible to treat this task as a simple binary classification problem. Therefore, a model capable of distinguishing between normal and anomalous samples in an unsupervised setting must be constructed. Unsupervised methods require learning normal patterns using a training set containing only normal samples. Subsequently, anomalous events in the test set are identified by evaluating the distance between instances and the acquired normal patterns.

[0003] Traditional cloud-based video anomaly detection involves compressing the video at the terminal, transmitting it to the cloud for full decoding, and then performing anomaly detection. However, this method introduces significant time latency and memory usage during the transmission and decoding phases. Driven by the rise of the Internet of Things (IoT), the computing power of edge servers is constantly increasing, enabling the deployment of various technologies at the edge. Therefore, compressed video can now be processed effectively on nearby edge servers, significantly improving overall efficiency. However, existing video anomaly detection methods either have overly complex network architectures or insufficient performance. Furthermore, these methods require full decoding of the compressed video stream, making them unsuitable for deployment on edge servers with limited computing resources and storage capacity. Therefore, researching a lightweight anomaly detection method that can be deployed on edge servers with high detection accuracy remains a challenging task.

[0004] Video anomaly detection has garnered significant attention from researchers due to its promising prospects in industry. In the early stages of this field, researchers primarily approached anomaly detection from a statistical perspective, combining handcrafted features with traditional machine learning algorithms. In this category, methods rely on predefined, handcrafted features integrated into the model for anomaly detection. These features are typically designed based on prior knowledge of a specific scene. However, a drawback of this approach is its limited adaptability to diverse scenarios, often resulting in below-standard detection accuracy.

[0005] With the emergence of deep learning, numerous anomaly detection methods based on deep neural networks have appeared. Due to the powerful feature extraction capabilities of deep neural networks, this type of algorithm has become the mainstream of VAD (Visual Anomaly Detection) algorithms today. Deep learning-based methods can be further divided into two main baselines: reconstruction-based methods and frame prediction-based methods. Reconstruction-based methods rely on learning patterns in normal data, then reconstructing test data, and identifying anomalies by evaluating the reconstruction error. However, these reconstruction-based methods have a limitation: they reconstruct each frame independently, resulting in the loss of motion information in the temporal domain. Frame prediction-based methods, on the other hand, understand the temporal patterns of consecutive frames to predict future frames, and identify anomalies by evaluating the prediction error. These frame prediction methods typically use autoencoders, variational autoencoders, and generative adversarial networks for frame prediction, but these generative models struggle to learn the distribution of the dataset, often generating blurry images, leading to higher misclassification rates or pattern collapse, making training extremely difficult.

[0006] Furthermore, in both methods, researchers typically employ optical flow reconstruction or prediction to identify anomalies in motion patterns. For detecting appearance anomalies, they usually compare the reconstructed or predicted frames to the true image in the fully decoded RGB domain. However, these processes are not suitable for deployment on edge servers because optical flow extraction and full video decoding are highly complex and time-consuming.

[0007] In summary, existing video anomaly detection methods face several key challenges that need to be addressed: 1) The complexity arising from motion information extraction and full video decoding. Many current VAD algorithms operate only in the image domain, requiring full decoding of the compressed video stream. Some of these methods also require optical flow extraction as an auxiliary information source, which introduces complexity and time consumption, and increases the demand for storage and computational resources. 2) Existing generative models have limited ability to learn normal pattern distributions. Methods relying on autoencoders for frame prediction or reconstruction often require the integration of supplementary temporal feature extraction modules and tend to perform poorly. Variational autoencoders can lead to frame distortion and increase the misclassification rate. Generative adversarial networks are prone to pattern collapse, making them difficult to adapt to different application scenarios and producing less diverse generated frames. Summary of the Invention

[0008] The purpose of this invention is to provide a compressed domain video anomaly detection method based on a conditional diffusion model that has low complexity, high detection accuracy, and can be deployed on an edge server.

[0009] This invention is achieved through the following technical solution:

[0010] A compressed domain video anomaly detection method based on a conditional diffusion model includes the following steps:

[0011] Step 1: Sparsely sample the input compressed video stream, retain all independent coded frames (I-frames), and extract the motion vector MV from the inter-coded frames (P-frames).

[0012] Step 2: One I-frame and the next three P-frames are called a group of GoP. When processing the video stream sequentially, the I-frames of the four GoPs, the MV, and the I-frame of the next GoP are used as input.

[0013] Step 3: Take the 4 sets of MVs in the input as the input of the reconstruction end, reconstruct them in groups, and use the mean square error (MSE) between the reconstructed MV and the original MV as the outlier reconstruction score.

[0014] Step 4: Take the last I-frame in the input as the target I-frame and perform a diffusion operation on it. Conditional diffusion model is a generative model that aims to learn the distribution of the dataset during the process of adding and removing noise, thereby generating new data that conforms to the distribution. The diffusion operation is the first process of the conditional diffusion model, which adds noise to the data. This operation randomly samples a value between [0, T] as the noise level t of the image, and then adds noise to the target I-frame to the level t, where T represents the noise level threshold, i.e. the maximum noise level.

[0015] Step 5: Using the noisy target I-frame as input, the reconstruction of the MV and the I-frames corresponding to its time sequence on the channel is used as a condition and input into the noise predictor Unet for noise prediction. This step is the second process of the conditional diffusion model - the inverse diffusion process, which is to denoise the noisy image. The mean square error (MSE) between the predicted I-frame and the target I-frame obtained here will be used as the anomaly prediction score.

[0016] Step 6: Weight the anomaly reconstruction score and the anomaly prediction score obtained in Step 3 and Step 5 to obtain the final anomaly score;

[0017] Step 7: Repeat steps 2-6 to process different video streams in the dataset to obtain the anomaly score of the entire dataset. Compare the anomaly score with the original labeled anomaly score of the dataset. Frames that exceed the set threshold will be judged as anomalous frames, and the final anomaly detection result of the compressed domain video will be obtained.

[0018] A further improvement of the present invention is that, in step 1, the compressed video stream includes independently coded I-frames and inter-frame coded P-frames.

[0019] A further improvement of this invention is that I-frames are directly retained; for inter-frame coded P-frames, the official codec HM of the HEVC standard is used to sample the MV in the P-frame, retaining only the MV as input.

[0020] A further improvement of the present invention is that the MV reconstruction method in step 3 includes:

[0021] S31, First, regarding the training process, based on the requirement that the difference between the reconstructed MV and the original MV in the training set be as small as possible, the objective function of the autoencoder at the reconstruction end is obtained as follows:

[0022]

[0023] Where φ is the encoder of the autoencoder, and ψ is the decoder. This is the loss function used to calculate the difference between the reconstructed MV and the original MV, as shown in the following formula:

[0024]

[0025] This allows for the training of the reconstructed autoencoder, after which testing can be performed.

[0026] S32, the reasoning process is to input the MV in the test set into the trained reconstruction autoencoder to obtain the reconstructed MV.

[0027] A further improvement of the present invention is that the method for performing the diffusion operation on the target I-frame in step 4 includes:

[0028] S41, Diffusion process q t It is a Markov process, where each state is determined by the previous state. Let x0 represent the I-frame, then the diffusion degree [1, T] can be expressed as:

[0029]

[0030]

[0031] The hyperparameter is a value greater than 0 and less than 1;

[0032] S42, as described in step 4, randomly sample a value t from [0, T] as the noise level. This noise-adding method differs from S41; it directly adds noise to the level t, as shown in the equation:

[0033]

[0034] In the formula

[0035] A further improvement of the present invention is that, in step 4, T = 1000 is selected.

[0036] A further improvement of the present invention is that the method for performing inverse diffusion on the noisy I-frame in step 5 includes:

[0037] S51, Reverse diffusion process p tThat is, to denoise the noisy I-frames, Unet is used for noise prediction.

[0038]

[0039] It can be known

[0040]

[0041] Where ∈ represents random sampling noise in a Gaussian distribution, and the input noise will be predicted using a conditional denoising Unet with θ as a parameter, as shown in the equation:

[0042]

[0043] In the formula, y represents a series of conditions;

[0044] S52, now using the old I-frame and reconstruction Assuming splicing is a condition, the reverse diffusion process at this point is p. θ For example:

[0045]

[0046] In the formula Where ∈ θ for

[0047]

[0048] S53, during training, a denoising U-Net is optimized, conditioned on MV and P, with the noisy target I-frame T as input. The main objective of the denoising U-Net is to predict the noise present in the noisy target I-frame, and its loss function is:

[0049] in

[0050] S54, during the inference process, the target I-frame is predicted based on a noise map randomly sampled in a Gaussian distribution.

[0051] A further improvement of this invention is that the method for calculating the abnormal score in step 6 is as follows:

[0052] S61, the abnormal reconstruction score is in It's the original music video. It's about refactoring the music video;

[0053] S62, Anomaly Prediction Score Among them I i It is the original target I-frame. It predicts the target I-frame;

[0054] S63, the final abnormal score is S = w r S R +w p S P , where w r It is the weight of the abnormal reconstruction score, w p It is the weight of the anomaly prediction score.

[0055] The present invention has at least the following beneficial technical effects:

[0056] This invention provides a compressed-domain video anomaly detection method based on a conditional diffusion model. This method operates directly in the compressed domain, reducing complexity while maintaining high detection performance. First, a sparse sampling strategy is applied to the compressed video, processing i-frames and motion vectors as appearance and motion information. The video anomaly detection task is completed through the fusion of reconstruction and frame prediction. It has the following advantages:

[0057] First, it operates directly within the compressed domain, allowing it to be deployed on edge servers;

[0058] Second: By processing directly in the compression domain, the complete decoding of the video is avoided, thereby reducing time loss;

[0059] Third: Introducing motion vectors as motion information makes extraction and processing faster and more efficient than traditional optical flow methods, while also reducing memory usage and minimizing time and memory burden on edge servers.

[0060] Fourth: The network structure that needs to be trained in the algorithm is simple, with only one autoencoder for reconstruction and Unet for noise prediction. Compared with the current mainstream algorithms, it has fewer network parameters and a simpler model.

[0061] Fifth: To address some shortcomings of previous generative models, we introduced a diffusion model into video anomaly detection and used it to build a conditional diffusion model with I-frames and motion as conditions. This ensures both the temporal consistency of generated frames and effective learning of normal pattern distributions, while also yielding higher-quality predicted frames and robust training without pattern collapse.

[0062] Sixth: A unique sparse sampling strategy is adopted, which improves the detection efficiency of the algorithm. Attached Figure Description

[0063] Figure 1 This is a structural diagram of the invention.

[0064] Video is acquired at the monitoring terminal, compressed using HEVC (High Efficient Video Compression), and sparsely sampled in the compressed video to obtain I-frames and MVs. The MVs are reconstructed, and the reconstructed MVs are concatenated with the I-frames as a condition for the diffusion model. Then, the target I-frame is predicted.

[0065] Figure 2 The flowchart shows the specific process of sparse sampling, where I-frames are retained in each GoP, and MV is extracted from the P-frames.

[0066] Figure 3 The diagram shows an autoencoder for reconstructing MV, with a symmetrical five-layer structure at both the encoding and decoding ends.

[0067] Figure 4 The specific structure of Unet for noise prediction in this invention is shown below. Unet consists of a resnet block and an attention block.

[0068] Figure 5 This is a ROC curve diagram of an embodiment of the present invention. Detailed Implementation

[0069] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the disclosure to those skilled in the art. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0070] A compressed video anomaly detection method based on a conditional diffusion model includes the following steps:

[0071] Step 1: Sparsely sample the input compressed video stream, retain all independent coded frames (I-frames), and extract motion vectors (MV) from inter-coded frames (P-frames).

[0072] Step 2: One I-frame and its following three P-frames are referred to as a Group of Pictures (GoP). When processing the video stream sequentially, the I-frames of these four GoPs, along with the MV and the I-frame of the next GoP, are used as input. See details... Figure 1 The compressed domain information extraction part and Figure 2 ;

[0073] Step 3: Use the four sets of MVs from the input as input to the reconstruction end, reconstruct them in groups, and use the reconstructed MVs and their mean squared error as the training loss function for the reconstruction autoencoder. The specific process can be found in [link to documentation]. Figure 1 The motion vector reconstruction part in the code, the structure of its reconstruction autoencoder is as follows: Figure 3 As shown;

[0074] Step 4: Take the last I-frame in the input as the target I-frame and perform a diffusion operation on the frame. The diffusion operation is a process of the diffusion model. Its purpose is to convert the image into an isotropic Gaussian noise. The specific operation is to randomly sample a value between [0, T] (T is 1000 in this invention) as the number of times the image is denoised, and then denoise the target I-frame to a degree t.

[0075] Step 5: Using the noisy target I-frame as input, the concatenation of the MV and its temporally corresponding I-frames on the channel is reconstructed and input into the noise predictor Unet for noise prediction. The L2 distance between the predicted noise and the added noise is used as the loss function to train Unet. The specific process can be found in [link to relevant documentation]. Figure 1 The training process of the target I-frame prediction part in the algorithm;

[0076] Step 6: Repeat steps 2-5 multiple times for different video streams in the dataset to complete the training.

[0077] The reasoning process includes the following steps:

[0078] Step 1: Sparsely sample the input compressed video stream, retain all independent coded frames (I-frames), and extract motion vectors from inter-coded frames (P-frames).

[0079] The sampling methods in step 1 include:

[0080] S11: The compressed video stream contains independently coded I-frames and inter-coded P-frames, and I-frames are directly preserved;

[0081] S12: For inter-frame coded frames (P-frames), the official HEVC codec HM (HEVC Test Model) is used to sample the MV in the P-frame, retaining only the MV as input.

[0082] Step 2: When processing the video stream sequentially, use 4 GoP I-frames, MV, and the next GoP I-frame as input;

[0083] Step 3: Take the four sets of MVs from the input as input to the reconstruction end, and reconstruct them in groups.

[0084] Step 4: Sample a noise z from a standard Gaussian distribution;

[0085] Step 5: Using noise z as input, the concatenation of the MV and its corresponding I-frames in the channel is reconstructed and fed into the noise predictor Unet for noise prediction. The predicted noise is then removed from the noise z to obtain the final predicted target I-frame. The detailed process can be found in [link to relevant documentation]. Figure 1 The reasoning process of the target I-frame prediction part in the text;

[0086] Step 6: Calculate the original MV and the reconstructed MV, the mean square error of the original target I-frame and the predicted target I-frame, and weight the two mean square errors to calculate the final anomaly score. If the score exceeds the predetermined threshold, the frame is regarded as an anomaly frame. For unsampled P-frames in the video stream, since the changes between adjacent frames are very small, the evaluation anomaly scores of the two adjacent I-frames can be used as their anomaly scores. This operation can also reduce the overall algorithm time.

[0087] Example

[0088] like Figure 1 As shown, the present invention provides a compressed domain video anomaly detection method based on a conditional diffusion model, comprising the following steps:

[0089] Step 1: Using the UCSD Ped2 dataset as the specific test object, firstly, the original dataset is compressed and encoded using HEVC to obtain a compressed video stream. Then, the input compressed video stream is sparsely sampled, retaining all independent coded frames (I-frames), and the motion vector MV is extracted from the inter-coded frames (P-frames).

[0090] Step 2 will take 4 GoP I-frames and MV and the next GoP I-frame as input;

[0091] Step 3: Use the 4 sets of MVs in the input as the input of the reconstruction end, reconstruct them in groups, and use the mean square error (MSE) between the reconstructed MV and the original MV as the outlier reconstruction score.

[0092] Step 4: Take the last I-frame in the input as the target I-frame, and perform a diffusion operation on the frame. This operation randomly samples a value between [0, T] as the noise level t of the image, and then adds noise to the target I-frame to the level t.

[0093] Step 5: Using the noisy target I-frame as input, the reconstruction of the MV and the splicing of the I-frames corresponding to its time sequence on the channel is used as a condition and input into the noise predictor Unet for inverse diffusion operation, i.e. noise prediction. The mean square error (MSE) between the predicted I-frame and the target I-frame obtained here will be used as the anomaly prediction score.

[0094] Step 6: Weight the anomaly reconstruction score and the anomaly prediction score obtained in Step 3 and Step 5 to obtain the final anomaly score;

[0095] Step 7: Perform anomaly detection on all video frames of UCSD Ped2, and finally compare them with the labeled anomaly tags. The calculated AUC (area under the curve) is 98.245%. The specific ROC curve is shown below. Figure 5 As shown.

[0096] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.

Claims

1. A compressed domain video anomaly detection method based on a conditional diffusion model, characterized in that, Includes the following steps: Step 1: Sparsely sample the input compressed video stream, retain all independent coded frames (I-frames), and extract the motion vector MV from the inter-coded frames (P-frames). Step 2: One I-frame and the next three P-frames are called a group of GoP. When processing the video stream sequentially, the I-frames of the four GoPs, the MV, and the I-frame of the next GoP are used as input. Step 3: Take the 4 sets of MVs in the input as the input of the reconstruction end, reconstruct them in groups, and use the mean square error (MSE) between the reconstructed MV and the original MV as the outlier reconstruction score. Step 4: Take the last I-frame in the input as the target I-frame and perform a diffusion operation on the frame. The diffusion operation is the first process of the conditional diffusion model, which adds noise to the data. This operation randomly samples a value between [0,T] as the noise level t of the image, and then adds noise to the target I-frame to the level t, where T represents the noise level threshold, i.e. the maximum noise level. Methods for performing a diffusion operation on a target I-frame include: S41, Diffusion process It is a Markov process, where each state is determined by the previous state. Let x0 represent the I-frame, then the diffusion degree [1,T] can be expressed as: The hyperparameter is a value greater than 0 and less than 1; S42, as described in step 4, randomly sample a value t from [0,T] as the noise level. This noise-adding method differs from S41; it directly adds noise to the level t, as shown in the equation: In the formula ; Step 5: Using the noisy target I-frame as input, the concatenation of the MV and its temporally corresponding I-frames on the channel is reconstructed and input into the noise predictor Unet for noise prediction. This step is the second process of the conditional diffusion model—the inverse diffusion process, i.e., denoising the noisy image. The mean square error (MSE) between the predicted I-frame and the target I-frame obtained here will be used as the anomaly prediction score. The methods for performing inverse diffusion on the noisy I-frame include: S51, Reverse Diffusion Process That is, to denoise the noisy I-frames, Unet is used for noise prediction. It can be known in This is random sampling noise in a Gaussian distribution, which will be utilized using... The conditional denoising Unet, used as a parameter, predicts the input noise, as shown in the following equation: In the formula, y represents a series of conditions; S52, now using the old I-frame and reconstructing MV Assuming splicing is performed, the reverse diffusion process at this point is: For example: In the formula ,in for S53, during training, a denoising U-Net is optimized, conditioned on MV and P, with the noisy target I-frame T as input. The main objective of the denoising U-Net is to predict the noise present in the noisy target I-frame, and its loss function is: in , S54, In the inference process, the target I-frame is predicted based on the noise map randomly sampled in a Gaussian distribution; Step 6: Weight the anomaly reconstruction score and the anomaly prediction score obtained in Steps 3 and 5 to obtain the final anomaly score; Step 7: Repeat steps 2-6 to process different video streams in the dataset to obtain the anomaly score of the entire dataset. Compare the anomaly score with the original labeled anomaly score of the dataset. Frames that exceed the set threshold will be judged as anomalous frames, and the final anomaly detection result of the compressed domain video will be obtained.

2. The compressed domain video anomaly detection method based on a conditional diffusion model according to claim 1, characterized in that, In step 1, the compressed video stream contains independently coded I-frames and inter-frame coded P-frames.

3. The compressed domain video anomaly detection method based on a conditional diffusion model according to claim 2, characterized in that, I-frames are directly retained; for inter-frame coded P-frames, the official HEVC codec HM is used to sample the MV in the P-frame, retaining only the MV as input.

4. The compressed domain video anomaly detection method based on a conditional diffusion model according to claim 1, characterized in that, The MV reconstruction method in step 3 includes: S31, First, regarding the training process, based on the requirement that the difference between the reconstructed MV and the original MV in the training set be as small as possible, the objective function of the autoencoder at the reconstruction end is obtained as follows: in It is a self-encoder encoder. It's a decoder. This is the loss function used to calculate the difference between the reconstructed MV and the original MV, as shown in the following formula: This allows for the training of the reconstructed autoencoder, after which testing can be performed. S32, the reasoning process is to input the MV in the test set into the trained reconstruction autoencoder to obtain the reconstructed MV.

5. The compressed domain video anomaly detection method based on a conditional diffusion model according to claim 1, characterized in that, In step 4, T=1000 is selected.

6. The compressed domain video anomaly detection method based on a conditional diffusion model according to claim 1, characterized in that, The method for calculating the outlier score in step 6 is as follows: S61, the anomaly reconstruction score is ,in It's the original music video. It's about refactoring the music video; S62, Anomaly Prediction Score ,in It is the original target I-frame. It predicts the target I-frame; S63, the final abnormal score is ,in It is the weight of the abnormal reconstruction score. It is the weight of the anomaly prediction score.