Unsupervised video anomaly detection method and device based on masked autoencoder

By using masked autoencoders and visual Transformer networks in unsupervised video anomaly detection, constructing spatiotemporal and optical flow cubes for interval mask operations, and calculating prediction losses to achieve video anomaly detection, the problem of low detection performance in the existing technology is solved. , improves detection accuracy and reduces dependence on annotation information.

CN114724060BActive Publication Date: 2024-10-18NAT UNIV OF DEFENSE TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210249993.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-14
Publication Date
2024-10-18
Estimated Expiration
2042-03-14

AI Technical Summary

Technical Problem

Existing unsupervised video anomaly detection technology has low detection performance in surveillance videos, especially due to the lack of annotation information and insufficient feature representation, resulting in low detection accuracy.

Method used

Using a method based on masked autoencoders, a spatiotemporal cube and an optical flow cube are constructed by performing target detection and image block extraction on surveillance video data, and interval masking operations are performed in the time domain, and the visual Transformer network is used to predict the masked part. , calculate the prediction loss to achieve anomaly scores, thereby completing end-to-end video anomaly event detection.

Benefits of technology

In the absence of annotation information, high-quality video features and models are learned, which significantly improves the performance of video abnormal event detection, can effectively distinguish between normal and abnormal events, and reduces the need for manual annotation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114724060B_ABST
    Figure CN114724060B_ABST
Patent Text Reader

Abstract

This application relates to an unsupervised video anomaly detection method and apparatus based on a masked autoencoder. The method includes: performing target detection on each frame of acquired surveillance video data, extracting image blocks corresponding to the detected foreground target positions in the current frame and multiple adjacent frames; constructing cubes based on the image blocks of each frame, and performing a time-space masking operation on each cube; predicting the masked portions in each spatiotemporal cube and each optical flow cube using a visual network based on the time-space masking operation; calculating the prediction loss at the pixel level for each spatiotemporal cube and each optical flow cube; and calculating the anomaly score of each frame in the surveillance video data based on the prediction loss of each spatiotemporal cube and each optical flow cube, thereby obtaining the anomaly event detection result for the corresponding video frame. This achieves high-performance end-to-end video anomaly event detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of video image processing, and relates to an unsupervised video anomaly detection method and device based on a masked autoencoder. Background Art

[0002] With the introduction and promotion of concepts such as "safe society" and "smart city", security systems have become an effective guarantee for preventing public safety incidents. One of the most important technologies in security systems is the analysis of massive surveillance videos, which has gradually become an important research topic in the field of social security. As one of the core technologies of surveillance video analysis, video anomaly detection (VAD) aims to intelligently identify abnormal events and suspicious behaviors from surveillance videos. Through video anomaly detection technology, not only can the probability of false detection and missed detection that occurs when manually identifying massive data be reduced, but also the large amount of manpower and financial resources required can be reduced.

[0003] It is very difficult to model complex and high-dimensional video data. At the same time, abnormal events have the essential characteristics of scarcity (the frequency of abnormal events is much lower than that of normal events, and they are difficult to collect and collect), novelty (abnormal events are usually different from the usual rules and unpredictable), fuzziness (the definition of abnormal events is abstract, and there is no clear boundary between normal and abnormal samples), and inexhaustibility (abnormal events are diverse). Therefore, the task of video anomaly detection is quite challenging, and there are still some key issues that need to be solved.

[0004] At present, most video anomaly detection methods are usually based on a semi-supervised setting, that is, a model of all normal category video events in the surveillance video is constructed through a training set containing only normal events. When the test data does not match the inference of the normal model, it is identified as an abnormal event. Semi-supervised surveillance video anomaly detection technology still requires time-consuming and labor-intensive collection of pure normal events to build a training data set. In the era of big data, the need for manual labeling is a major pain point of semi-supervised video anomaly detection. In order to meet social needs and promote technological development, an attractive solution is to adopt an unsupervised setting, that is, to detect anomalies from completely unlabeled surveillance videos without any manual labeling.

[0005] As an emerging technology, unsupervised video anomaly detection has been explored far less than semi-supervised methods. At present, one type of unsupervised method focuses on change detection on videos, and another type of unsupervised method iteratively improves performance through self-trained ordinal regression based on the initial anomaly recognition results of traditional machine learning algorithms. However, in the process of implementing the present invention, the inventors found that the current unsupervised video anomaly detection technology has a technical problem of low performance in detecting abnormal events in surveillance videos. Summary of the invention

[0006] In response to the problems existing in the above-mentioned traditional methods, the present invention proposes an unsupervised video anomaly detection method based on a masked autoencoder, an unsupervised video anomaly detection device based on a masked autoencoder, a computer device and a computer-readable storage medium, which can achieve high-performance end-to-end video abnormal event detection.

[0007] In order to achieve the above objectives, the embodiments of the present invention adopt the following technical solutions:

[0008] On the one hand, a method for unsupervised video anomaly detection based on a masked autoencoder is provided, comprising the steps of:

[0009] Obtain surveillance video data;

[0010] Perform target detection on each frame of the surveillance video data, and extract the image blocks of the detected foreground target corresponding to the current frame and the adjacent previous and next frames;

[0011] Cubes are constructed according to the image blocks of each frame, and interval mask operations are performed on each cube in the time domain; the cubes include space-time cubes and optical flow cubes;

[0012] According to each spatiotemporal cube and each optical flow cube after the interval mask operation, the prediction blocks of the masked parts in each spatiotemporal cube and each optical flow cube are obtained by using the visual network prediction respectively;

[0013] According to the prediction block, the prediction loss of each spatiotemporal cube and each optical flow cube at the pixel level is calculated respectively;

[0014] According to the prediction loss of each spatiotemporal cube and each optical flow cube, the anomaly score of each frame in the monitoring video data is calculated; the anomaly score is used to indicate the abnormal event detection result of the corresponding video frame.

[0015] On the other hand, an unsupervised video anomaly detection device based on a masked autoencoder is also provided, comprising:

[0016] Video acquisition module, used to acquire surveillance video data;

[0017] The target detection module is used to perform target detection on each frame of the surveillance video data and extract the image blocks of the corresponding positions of the detected foreground targets in the current frame and the adjacent previous and next frames;

[0018] The mask operation module is used to construct each cube according to the image blocks of each frame, and perform interval mask operation on each cube in the time domain; the cube includes a space-time cube and an optical flow cube;

[0019] A mask prediction module is used to obtain prediction blocks of masked parts in each spatiotemporal cube and each optical flow cube using a visual network prediction according to each spatiotemporal cube and each optical flow cube after the interval mask operation;

[0020] A prediction loss module is used to calculate the prediction loss of each spatiotemporal cube and each optical flow cube at the pixel level according to the prediction block;

[0021] The anomaly scoring module is used to calculate the anomaly value score of each frame in the monitoring video data according to the prediction loss of each spatiotemporal cube and each optical flow cube; the anomaly value score is used to indicate the abnormal event detection result of the corresponding video frame.

[0022] On the other hand, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned unsupervised video anomaly detection method based on mask autoencoder are implemented.

[0023] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned unsupervised video anomaly detection method based on masked autoencoder are implemented.

[0024] One of the above technical solutions has the following advantages and beneficial effects:

[0025] The above-mentioned unsupervised video anomaly detection method and device based on masked autoencoder, after performing target detection, extracting image blocks and constructing two cubes on the acquired surveillance video data, then adopts the interval masking strategy to perform masking operation in the time domain, and then uses the visual network to predict the masked part according to the visible part in the cube, and then calculates the prediction loss between the predicted block and the masked part, and finally calculates the anomaly value score of each frame according to the prediction loss of all cubes to complete the detection of abnormal events in the surveillance video data.

[0026] The above scheme can learn high-quality video features and models through the temporal mask autoencoder without any annotation information, and achieve high-performance end-to-end video abnormal event detection. Specifically, the above scheme first uses target detection to locate the foreground to more accurately describe the video event, that is, to build a space-time cube; then add a mask to the time domain of the space-time cube to mask half of the block; then, train the visual Transformer network to predict the mask part of the space-time cube through the unmasked part of the space-time cube. In addition, the optical flow is used as an auxiliary action cue to construct an optical flow cube, and the same operation as the space-time cube is performed.

[0027] Finally, compared with normal events, abnormal events are difficult to predict due to their rarity and novelty, and temporal masks further increase the difficulty of predicting abnormal events. Therefore, the distinguishing prediction error between normal and abnormal events prompts the above scheme to directly use the prediction loss as the abnormal value score of the video event, effectively achieving the purpose of high-performance end-to-end video abnormal event detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 1 is a flow chart of an unsupervised video anomaly detection method based on a masked autoencoder in one embodiment;

[0029] Figure 2 A schematic diagram of a process for detecting abnormal events in an original video frame of a surveillance video in one embodiment;

[0030] Figure 3 A schematic diagram of a process for detecting abnormal events based on optical flow of surveillance video in one embodiment;

[0031] Figure 4 A schematic diagram of visualization effect of prediction results of mask blocks of normal and abnormal video events in one embodiment;

[0032] Figure 5 Schematic diagram of the module structure of an unsupervised video anomaly detection device based on a masked autoencoder in one embodiment. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used herein in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0035] In the process of realizing the present invention, the inventors found that although no manual annotated training set is required in the unsupervised scenario, saving manpower, financial resources and time costs, its effect lags behind the performance of the semi-supervised algorithm by 5%-10% on the commonly used data sets, and there is a certain gap. The bottleneck of the existing methods mainly comes from two factors: (a) Suboptimal video feature representation: The mainstream unsupervised algorithm relies on manually designed feature operators to extract feature representation, which requires sophisticated design by experienced experts, and the manual operators designed for specific scenarios have limited versatility and are difficult to migrate to other monitoring scenarios. Recently, very few unsupervised methods use pre-trained deep neural networks (DNN) to extract features, but because the data set used by the pre-trained network is essentially different from the monitoring video data involved in this application, the extracted feature representation is often not excellent enough and contains redundant information. Feature representation will directly affect the learning quality of downstream tasks. (b) Limited model learning ability: Existing unsupervised methods all rely on traditional machine learning algorithms, and this classic model does not have end-to-end learning capabilities, cannot integrate feature learning and downstream tasks into a whole, and has extremely limited modeling capabilities.

[0036] Before starting the description of the embodiments of the present invention, the definitions of some professional terms involved are given as follows:

[0037] Mask: According to the shape specified by the mask (mosaic), the pixel values ​​at the corresponding position on the image are set to 0. In the general sense, mask is an operation on the entire unit, for example, setting all the pixel values ​​of the entire frame or block to 0, that is, turning the image into a completely black image. Mask is the Chinese translation of the mask operation, which is equivalent to mask, cover, and invisible.

[0038] Change detection: When the time series data changes dramatically, it is considered that an abnormal situation has occurred through some measurement method.

[0039] Pre-trained deep neural networks: Algorithms in the general vision field usually use deep neural networks that have been trained on publicly available large image datasets to extract features.

[0040] Self-supervised learning: Self-supervised learning is a type of unsupervised learning, which aims to learn a universal feature expression for downstream tasks. It optimizes the predefined proxy task (pretext task) on completely unlabeled data and uses its own information to learn feature representation.

[0041] Feature learning: also called representation learning or representation learning, generally refers to the method by which the model automatically extracts features or representations from data, which is the process of automatic model learning.

[0042] End-to-end: End-to-end means that users directly input raw materials and get usable results directly without having to worry about the intermediate products.

[0043] Patch-level: treats an image block (patch) as the unit of operation. Others such as frame-level treat an entire frame as the unit of operation, such as adding frame noise or mask to an entire video. Others such as pixel-level treat each pixel as the unit of operation.

[0044] Transformer: A neural network structure. There is no unified Chinese translation in the industry yet.

[0045] Anomaly score: represents the probability that an object is abnormal. The larger the anomaly score, the more likely it is an abnormal event, and the smaller the score, the more likely it is a normal event.

[0046] Prediction loss is equivalent to prediction error.

[0047] The following will describe the implementation of the present invention in detail with reference to the accompanying drawings in the embodiment diagram of the present invention.

[0048] In the field of images, masked autoencoders (MAEs) have achieved great success as self-supervised learners. The core idea of ​​the MAE method is to mask some small patches in the image, and then train a deep neural network to restore the missing image patches based on the uncovered parts of the image. Through this proxy task, MAE is able to learn high-quality features for downstream tasks. At the same time, as a model based on a deep neural network, MAE itself has strong modeling capabilities. MAE can learn high-quality features and has strong modeling capabilities. Therefore, introducing this end-to-end learning paradigm into the unsupervised video anomaly detection task is expected to solve the defects of existing technologies. However, since MAE only adds masks in the spatial dimension to be applied in the image field, it does not take into account the temporal information and cannot be directly applied in the video field. It is worth noting that abnormal events usually appear as abnormalities in the context of time series.

[0049] In view of the technical problem of low performance in detecting abnormal events in surveillance videos in the above-mentioned traditional unsupervised video anomaly detection technology, this application designs a new unsupervised video anomaly detection technology based on masked autoencoders. Without the need for any video annotation information, a temporal masked autoencoder is used to achieve high-performance end-to-end detection of abnormal events in surveillance videos. This application performs the same detection and image processing operations on the original video frame and the optical flow extracted from the video frame, and finally directly uses the prediction loss as the abnormal value score of the video event. The abnormal value score can directly distinguish normal events and abnormal events in the surveillance video, thereby efficiently realizing end-to-end abnormal event detection in surveillance videos, and the detection performance has been significantly improved.

[0050] See also Figure 1 , the embodiment of the present application provides an unsupervised video anomaly detection method based on a mask autoencoder, comprising the following steps S12 to S22:

[0051] S12, obtaining surveillance video data.

[0052] It can be understood that the surveillance video data can be unlabeled surveillance video data that is given, collected through the Internet, or obtained in other ways.

[0053] S14, performing target detection on each frame of the surveillance video data, and extracting image blocks of corresponding positions of the detected foreground targets in the current frame and adjacent frames before and after.

[0054] It is understandable that for the acquired raw surveillance video data, it is necessary to locate the foreground target in the video and filter out the redundant background information. The foreground target in the video can be a person, an animal, a vehicle or other types of objects.

[0055] Perform target detection on each frame of unlabeled surveillance video data, locate the foreground target (such as a person or a car, etc.) in the form of a detection frame (e.g., each foreground target is marked with a target positioning frame), and then extract the image blocks of the target positioning frame (representing the foreground target) corresponding to the current frame and the adjacent previous and next frames (which can be recorded as D-1 frames, D is a positive integer greater than or equal to 2) for each target positioning frame. For each frame of data, after detecting and locating the foreground target of the frame, in addition to extracting the image blocks of the foreground target corresponding to the current frame (i.e., the frame processed at the current moment), the number of adjacent previous and next frames (in time sequence with the current frame) that need to be processed by the aforementioned extraction process can be selected based on a comprehensive balance of computing resource conditions, cube size, and detection accuracy.

[0056] In one embodiment, optionally, D=8, in which case the scale of the cube is more appropriate, and will not consume too many computing resources or increase detection time, thereby achieving relatively high detection performance.

[0057] S16, constructing cubes according to the image blocks of each frame, and performing interval masking operations on each cube in the time domain; the cubes include spatiotemporal cubes and optical flow cubes.

[0058] It can be understood that the spatial temporal cube (STC) is used as a description of a video event and also as a single processing unit of the Vision Transformer (ViT) network in the subsequent steps, which can be formed by stacking multiple image blocks. The optical flow cube (OFC) is used as an auxiliary action description of a video event and also as a single processing unit of the visual network in the step, which can be formed by stacking optical flow blocks on multiple image blocks.

[0059] In video processing, optical flow is widely used to describe the motion of objects. The temporal pattern that we want to learn is essentially embedded in the motion information of the object. Therefore, in this application, optical flow extracted from video frames is added as an auxiliary motion clue to ensure improved detection performance.

[0060] In one embodiment, Figure 2 As shown in FIG. 1 , the process of constructing a space-time cube based on the image blocks of each frame includes:

[0061] Multiple temporally continuous image blocks are scaled to a preset size and stacked in chronological order to obtain a space-time cube; the space-time cube is used to describe a video event.

[0062] It can be understood that for the construction of the space-time cube, specifically: after scaling multiple (such as D blocks) image blocks that are continuous in time to a uniform preset size (for example, it can be set to 32*32 or other sizes), they are stacked in chronological order to form a space-time cube, and other space-time cubes are constructed in the same way.

[0063] In one embodiment, Figure 2 As shown in FIG. 1 , the process of performing interval masking operations on each space-time cube in the time domain includes:

[0064] For each space-time cube, a masking operation is performed on the image block level in the time domain in the manner of image block interval masking to obtain a space-time cube after the masking operation; in the space-time cube after the masking operation, half of the image blocks are visible and the other half are masked.

[0065] It can be understood that for each spatiotemporal cube, a patch-level masking operation is performed in the time domain. Each spatiotemporal cube contains D blocks that are continuous in time. In this embodiment, half of the image blocks are masked, that is, D / 2 blocks are visible (i.e., the unmasked part); D / 2 blocks are masked (i.e., the unknown part).

[0066] Specifically, an interval masking strategy is adopted. For a given space-time cube C = [x1, x2, ..., x D ], where {x i |i=2,4,…D-2,D} blocks as masks, and the remaining {x i The blocks |i=1,3,…D-3,D-1} are used as the visible part for input into the visual Transformer network model in subsequent steps.

[0067] In one embodiment, Figure 3 As shown in FIG. 1 , the process of constructing an optical flow cube according to the image blocks of each frame includes:

[0068] Performing optical flow extraction on multiple temporally continuous image blocks respectively to obtain multiple temporally continuous optical flow blocks;

[0069] Multiple temporally continuous optical flow blocks are scaled to a preset size and stacked in chronological order to obtain an optical flow cube; the optical flow cube is used to describe the action of a video event.

[0070] It can be understood that for the construction of the optical flow cube, after extracting the image blocks of each frame, it is necessary to extract the corresponding optical flow of the continuous D blocks, so as to obtain the optical flow blocks corresponding to each image block, which are used to describe the action information of the foreground target. After obtaining the optical flow blocks, multiple (such as D blocks) optical flow blocks that are continuous in time are scaled to a uniform preset size (for example, it can be set to 32*32 or other sizes), and then stacked in time order to form an optical flow cube, and other optical flow cubes are constructed in the same way.

[0071] In one embodiment, Figure 3 As shown in FIG. 1 , the process of performing interval masking operations on each optical flow cube in the time domain includes:

[0072] For each optical flow cube, a mask operation is performed on the optical flow block level in the time domain according to the optical flow block interval masking method to obtain an optical flow cube after the mask operation; half of the optical flow blocks in the optical flow cube after the mask operation are visible, and the other half of the optical flow blocks are masked.

[0073] It can be understood that for each optical flow cube, a masking operation is performed on the optical flow block level in the time domain. Each optical flow cube contains D blocks that are continuous in time, and half of the optical flow blocks are covered, that is, D / 2 blocks are visible (i.e., the unmasked part) and D / 2 blocks are masked (i.e., the unknown part). Specifically, this embodiment adopts an interval masking strategy, such as for a given optical flow cube where {x i |i=2,4,…D-2,D} blocks as masks, and the remaining {x i The blocks |i=1,3,…D-3,D-1} are used as the visible part for input into the visual Transformer network model in subsequent steps.

[0074] S18, according to each spatiotemporal cube and each optical flow cube after the interval mask operation, respectively obtain the prediction blocks of the masked parts in each spatiotemporal cube and each optical flow cube by using the visual network prediction.

[0075] It can be understood that through the above step S16, the space-time cube and the optical flow cube are masked in the time domain to construct a self-supervised proxy task. Half of the image blocks (optical flow blocks) of each space-time cube (optical flow cube) are masked as the network prediction part, and the remaining unmasked part is input into the visual Transformer network as the visible part.

[0076] In the proxy task, the subsequent prediction loss uses the mean squared error to calculate the error between the original pixel value of the masked block in the space-time cube (optical flow cube) and the output of the visual Transformer network (the prediction of the masked block in the space-time cube (optical flow cube)).

[0077] In one embodiment, Figure 2 As shown, according to each spatiotemporal cube after the interval mask operation, the process of using the visual network to predict the predicted blocks of the masked parts in each spatiotemporal cube includes:

[0078] For each space-time cube after the interval mask operation, the visible part of the space-time cube is pre-operated and then input into the visual network; the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it into a set low-dimensional space, and then adding a learnable position code;

[0079] The output vector of the visual network is projected to the original dimension before pre-operation and deformed to the size before pre-operation to obtain the predicted block of the masked part in each spatiotemporal cube.

[0080] Specifically, for each visible part of the spatiotemporal cube (D / 2 blocks), it is first flattened into a one-dimensional vector (1D token), and then linearly projected to a set low-dimensional space; in order to preserve the temporal information, the projected one-dimensional vector is added with a learnable position embedding. The D / 2 unmasked vectors are input into the visual Transformer network, and the output vector of the visual Transformer network is projected to the original dimension and reshaped to the same size as the aforementioned D / 2 blocks as the prediction (block) of the masked part of the spatiotemporal cube.

[0081] In one embodiment, Figure 3 As shown, according to each optical flow cube after the interval mask operation, the process of using the visual network to predict the predicted blocks of the masked parts in each optical flow cube includes:

[0082] For each optical flow cube after the interval mask operation, the visible part of the optical flow cube is pre-operated and then input into the visual network; the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it into a set low-dimensional space, and then adding a learnable position code;

[0083] The output vector of the visual network is projected to the original dimension before pre-operation and deformed to the size before pre-operation to obtain the predicted block of the masked part in each optical flow cube.

[0084] Similarly, for each visible part of the optical flow cube (D / 2 blocks), it is first flattened into a one-dimensional vector, and then linearly projected to a set low-dimensional space. In order to retain the temporal information, the projected one-dimensional vector is added with a learnable position code. The D / 2 unmasked vectors are input into the visual Transformer network, and the output vector of the visual Transformer network is projected to the original dimension and deformed to the same size as the aforementioned D / 2 blocks as the prediction (block) of the masked part of this optical flow cube.

[0085] S20, according to the prediction block, respectively calculate the prediction loss of each spatiotemporal cube and each optical flow cube at the pixel level.

[0086] It can be understood that the prediction loss uses the mean square error (MSE) to calculate the error between the original pixel value of the masked block in the spatiotemporal cube (optical flow cube) and the output of ViT (the prediction of the masked block in the spatiotemporal cube (optical flow cube)).

[0087] In one embodiment, the prediction loss of the space-time cube at the pixel level is calculated by the following formula:

[0088]

[0089] Among them, C represents a space-time cube, C mask Represents the original pixel value of the masked part in the space-time cube, C pred Represents the predicted pixel value for the masked portion of the space-time cube.

[0090] Specifically, for each spatiotemporal cube that can be regarded as a video event, the pixel-level prediction error is the above-mentioned MSE(C).

[0091] In one embodiment, the prediction loss of the optical flow cube at the pixel level is calculated by the following formula:

[0092]

[0093] in, represents an optical flow cube, Represents the original pixel value of the masked part in the optical flow cube, Represents the predicted pixel value of the masked part of the optical flow cube.

[0094] Specifically, for each optical flow cube that can be regarded as an action description of a video event, the prediction error at the pixel level is

[0095] S22, calculating the abnormal value score of each frame in the monitoring video data according to the prediction loss of each spatiotemporal cube and each optical flow cube; the abnormal value score is used to indicate the abnormal event detection result of the corresponding video frame.

[0096] It is understandable that compared with normal events, abnormal events are difficult to predict due to their rarity and novelty, and time domain masking further increases the difficulty of predicting abnormal events. Therefore, the prediction error of normal events is often small, while the prediction error of abnormal events is usually large.

[0097] like Figure 4 As shown in the figure, on different public data sets, the prediction errors of abnormal events and normal events are highly distinguishable from each other through the last row. Based on this phenomenon and rule, for each spatiotemporal cube that can be regarded as a video event and its auxiliary action clue optical flow cube, the outlier score can directly adopt the overall prediction loss.

[0098] In one embodiment, the above step S22 may specifically include the following processing steps:

[0099] Calculate the overall prediction loss of the surveillance video data based on the prediction losses of all spatiotemporal cubes and optical flow cubes;

[0100] For each frame of surveillance video data, based on the overall prediction loss, the maximum outlier score of all cubes on the frame is taken as the outlier score of the corresponding video frame.

[0101] It can be understood that the overall prediction loss is directly used to score the outliers, and finally, the maximum outlier score of all cubes on a frame is taken as the outlier score of this video frame. The higher the outlier score, the greater the probability that the abnormal event detection result of the video frame is an abnormal video event (abnormal video events and normal video events can be directly divided according to the set score limit).

[0102] In one embodiment, the overall prediction loss Score (C) is calculated by the following formula:

[0103]

[0104] Among them, C represents a space-time cube, α and β represent the hyperparameters that control the proportion of the two parts of the prediction loss, and MSE(C) represents the prediction loss of the space-time cube at the pixel level. represents the prediction loss of the optical flow cube at the pixel level, μ and σ represent the mean and variance of the MSE loss of all spatiotemporal cubes, respectively. and Represent the mean and variance of the MSE loss of all optical flow cubes, respectively.

[0105] In some embodiments, optionally, α can take a value of 1.0 and β can take a value of 0.5 to achieve relatively better detection performance.

[0106] The above-mentioned unsupervised video anomaly detection method based on masked autoencoder performs target detection, image block extraction and construction of two cubes on the acquired surveillance video data, and then uses the interval masking strategy to perform masking operation in the time domain. Then, the visual network is used to predict the masked part according to the visible part in the cube, and the prediction loss between the predicted block and the masked part is calculated. Finally, the anomaly value score of each frame is calculated according to the prediction loss of all cubes to complete the detection of abnormal events in the surveillance video data.

[0107] The above scheme can learn high-quality video features and models through the temporal mask autoencoder without any annotation information, and achieve high-performance end-to-end video abnormal event detection. Specifically, the above scheme first uses target detection to locate the foreground to more accurately describe the video event, that is, to build a space-time cube; then add a mask to the time domain of the space-time cube to mask half of the block; then, train the visual Transformer network to predict the mask part of the space-time cube through the unmasked part of the space-time cube. In addition, the optical flow is used as an auxiliary action cue to construct an optical flow cube, and the same operation as the space-time cube is performed.

[0108] Finally, compared with normal events, abnormal events are difficult to predict due to their rarity and novelty, and temporal masks further increase the difficulty of predicting abnormal events. Therefore, the distinguishing prediction error between normal and abnormal events prompts the above scheme to directly use the prediction loss as the abnormal value score of the video event, effectively achieving the purpose of high-performance end-to-end video abnormal event detection.

[0109] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps can be executed in other orders. Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequentially, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0110] See also Figure 5In one embodiment, an unsupervised video anomaly detection device 100 based on a mask autoencoder is also provided, comprising a video acquisition module 11, a target detection module 13, a mask operation module 15, a mask prediction module 17, a prediction loss module 19 and an anomaly scoring module 21. The video acquisition module 11 is used to acquire surveillance video data. The target detection module 13 is used to perform target detection on each frame of the surveillance video data, and extract the image blocks of the corresponding positions of the detected foreground targets in the current frame and the adjacent previous and next frames. The mask operation module 15 is used to construct each cube according to the image blocks of each frame, and perform an interval mask operation on each cube in the time domain; the cube includes a space-time cube and an optical flow cube. The mask prediction module 17 is used to use the visual network to predict the masked parts of each space-time cube and each optical flow cube according to each space-time cube and each optical flow cube after the interval mask operation. The prediction loss module 19 is used to calculate the prediction loss of each space-time cube and each optical flow cube at the pixel level according to the prediction block. The anomaly scoring module 21 is used to calculate the anomaly value score of each frame in the monitoring video data according to the prediction loss of each spatiotemporal cube and each optical flow cube; the anomaly value score is used to indicate the abnormal event detection result of the corresponding video frame.

[0111] The above-mentioned unsupervised video anomaly detection device 100 based on masked autoencoder, through the collaboration of various modules, performs target detection, extracts image blocks and constructs two cubes on the acquired surveillance video data, and then uses the interval masking strategy to perform masking operations in the time domain, and then uses the visual network to predict the masked part according to the visible part in the cube, and then calculates the prediction loss between the predicted block and the masked part, and finally calculates the abnormal value score of each frame according to the prediction loss of all cubes to complete the detection of abnormal events in the surveillance video data.

[0112] The above scheme can learn high-quality video features and models through the temporal mask autoencoder without any annotation information, and achieve high-performance end-to-end video abnormal event detection. Specifically, the above scheme first uses target detection to locate the foreground to more accurately describe the video event, that is, to build a space-time cube; then add a mask to the time domain of the space-time cube to mask half of the block; then, train the visual Transformer network to predict the mask part of the space-time cube through the unmasked part of the space-time cube. In addition, the optical flow is used as an auxiliary action cue to construct an optical flow cube, and the same operation as the space-time cube is performed.

[0113] Finally, compared with normal events, abnormal events are difficult to predict due to their rarity and novelty, and temporal masks further increase the difficulty of predicting abnormal events. Therefore, the distinguishing prediction error between normal and abnormal events prompts the above scheme to directly use the prediction loss as the abnormal value score of the video event, effectively achieving the purpose of high-performance end-to-end video abnormal event detection.

[0114] In one embodiment, the process of constructing a space-time cube according to the image blocks of each frame includes:

[0115] Multiple temporally continuous image blocks are scaled to a preset size and stacked in chronological order to obtain a space-time cube; the space-time cube is used to describe a video event.

[0116] In one embodiment, the process of performing the interval masking operation on each space-time cube in the time domain includes:

[0117] For each space-time cube, a masking operation is performed on the image block level in the time domain in the manner of image block interval masking to obtain a space-time cube after the masking operation; in the space-time cube after the masking operation, half of the image blocks are visible and the other half are masked.

[0118] In one embodiment, the process of constructing an optical flow cube according to the image blocks of each frame includes:

[0119] Performing optical flow extraction on multiple temporally continuous image blocks respectively to obtain multiple temporally continuous optical flow blocks;

[0120] Multiple temporally continuous optical flow blocks are scaled to a preset size and stacked in chronological order to obtain an optical flow cube; the optical flow cube is used to describe the action of a video event.

[0121] In one embodiment, the process of performing the interval masking operation on each optical flow cube in the time domain includes:

[0122] For each optical flow cube, a mask operation is performed on the optical flow block level in the time domain according to the optical flow block interval masking method to obtain an optical flow cube after the mask operation; half of the optical flow blocks in the optical flow cube after the mask operation are visible, and the other half of the optical flow blocks are masked.

[0123] In one embodiment, according to each spatiotemporal cube after the interval mask operation, the process of using the visual network to predict the predicted blocks of the masked parts in each spatiotemporal cube includes:

[0124] For each space-time cube after the interval mask operation, the visible part of the space-time cube is pre-operated and then input into the visual network; the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it into a set low-dimensional space, and then adding a learnable position code;

[0125] The output vector of the visual network is projected to the original dimension before pre-operation and deformed to the size before pre-operation to obtain the predicted block of the masked part in each spatiotemporal cube.

[0126] In one embodiment, according to each optical flow cube after the interval mask operation, the process of using the visual network to predict the predicted block of the masked part in each optical flow cube includes:

[0127] For each optical flow cube after the interval mask operation, the visible part of the optical flow cube is pre-operated and then input into the visual network; the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it into a set low-dimensional space, and then adding a learnable position code;

[0128] The output vector of the visual network is projected to the original dimension before pre-operation and deformed to the size before pre-operation to obtain the predicted block of the masked part in each optical flow cube.

[0129] In one embodiment, the prediction loss of the space-time cube at the pixel level is calculated by the following formula:

[0130]

[0131] Among them, C represents a space-time cube, C mask Represents the original pixel value of the masked part in the space-time cube, C pred Represents the predicted pixel value for the masked portion of the space-time cube.

[0132] In one embodiment, the prediction loss of the optical flow cube at the pixel level is calculated by the following formula:

[0133]

[0134] in, represents an optical flow cube, Represents the original pixel value of the masked part in the optical flow cube, Represents the predicted pixel value of the masked part of the optical flow cube.

[0135] In one embodiment, the above-mentioned abnormality scoring module 21 can be used to implement the following processing functions:

[0136] Calculate the overall prediction loss of the surveillance video data based on the prediction losses of all spatiotemporal cubes and optical flow cubes;

[0137] For each frame of surveillance video data, based on the overall prediction loss, the maximum outlier score of all cubes on the frame is taken as the outlier score of the corresponding video frame.

[0138] In one embodiment, the overall prediction loss Score (C) is calculated by the following formula:

[0139]

[0140] Among them, C represents a space-time cube, α and β represent the hyperparameters that control the proportion of the two parts of the prediction loss, and MSE(C) represents the prediction loss of the space-time cube at the pixel level. represents the prediction loss of the optical flow cube at the pixel level, μ and σ represent the mean and variance of the MSE loss of all spatiotemporal cubes, respectively. and Represent the mean and variance of the MSE loss of all optical flow cubes, respectively.

[0141] Regarding the specific limitations of the unsupervised video anomaly detection device 100 based on masked autoencoder, please refer to the corresponding limitations of the unsupervised video anomaly detection method based on masked autoencoder above, which will not be repeated here. Each module in the above-mentioned unsupervised video anomaly detection device 100 based on masked autoencoder can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of a device with a specific data processing function in the form of hardware, or can be stored in the memory of the aforementioned device in the form of software, so that the processor can call and execute the operations corresponding to the above modules. The aforementioned device can be, but is not limited to, various types of computing / monitoring devices already available in the art.

[0142] On the other hand, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the following processing steps when executing the computer program: acquiring surveillance video data; performing target detection on each frame of the surveillance video data, and extracting image blocks of the detected foreground targets corresponding to positions in the current frame and multiple adjacent frames before and after; constructing cubes according to the image blocks of each frame, and performing interval masking operations on each cube in the time domain; the cubes include spatiotemporal cubes and optical flow cubes; according to each spatiotemporal cube and each optical flow cube after the interval masking operation, respectively using visual network prediction to obtain prediction blocks of masked parts in each spatiotemporal cube and each optical flow cube; according to the prediction blocks, respectively calculating the prediction losses of each spatiotemporal cube and each optical flow cube at the pixel level; according to the prediction losses of each spatiotemporal cube and each optical flow cube, calculating the abnormal value scores of each frame in the surveillance video data; the abnormal value scores are used to indicate the abnormal event detection results of the corresponding video frames.

[0143] In one embodiment, when the processor executes the computer program, the added steps or sub-steps in each embodiment of the above-mentioned unsupervised video anomaly detection method based on mask autoencoder can also be implemented.

[0144] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the following processing steps are implemented: acquiring surveillance video data; performing target detection on each frame of the surveillance video data, and extracting image blocks of the detected foreground targets corresponding to positions in the current frame and multiple adjacent frames before and after; constructing cubes according to the image blocks of each frame, and performing interval masking operations on each cube in the time domain; the cubes include spatiotemporal cubes and optical flow cubes; according to each spatiotemporal cube and each optical flow cube after the interval masking operation, using a visual network to predict the masked parts of each spatiotemporal cube and each optical flow cube; according to the prediction blocks, calculating the prediction losses of each spatiotemporal cube and each optical flow cube at the pixel level; according to the prediction losses of each spatiotemporal cube and each optical flow cube, calculating the abnormal value scores of each frame in the surveillance video data; the abnormal value scores are used to indicate the abnormal event detection results of the corresponding video frames.

[0145] In one embodiment, when the computer program is executed by a processor, the added steps or sub-steps in each embodiment of the above-mentioned unsupervised video anomaly detection method based on mask autoencoder can also be implemented.

[0146] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus dynamic random access memory (RambusDRAM, referred to as RDRAM) and interface dynamic random access memory (DRDRAM).

[0147] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0148] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and all of them belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. An unsupervised video anomaly detection method based on masked autoencoder, characterized in that: Includes steps: Obtain surveillance video data; Performing target detection on each frame of the surveillance video data, respectively, and extracting image blocks of the detected foreground target corresponding to the position in the current frame and the adjacent previous and next frames; Each cube is constructed according to the image blocks of each frame, and an interval mask operation is performed on each cube in the time domain; the cube includes a space-time cube and an optical flow cube, wherein a plurality of time-continuous image blocks are scaled to a preset size and stacked in time order to obtain a space-time cube; for each space-time cube, an image block-level mask operation is performed in the time domain in an image block interval mask manner to obtain the space-time cube after the mask operation; the space-time cube is used to describe a video event, and half of the image blocks in the space-time cube after the mask operation are visible , the other half of the image block is masked; optical flow extraction is performed on multiple image blocks that are continuous in time respectively to obtain multiple optical flow blocks that are continuous in time; multiple optical flow blocks that are continuous in time are scaled to a preset size and stacked in time order to obtain an optical flow cube; for each optical flow cube, a mask operation is performed on the optical flow block level in the time domain in a manner of optical flow block interval masking to obtain the optical flow cube after the mask operation; the optical flow cube is used as an action description of a video event, and half of the optical flow blocks in the optical flow cube after the mask operation are visible, and the other half of the optical flow blocks are masked; According to each of the space-time cubes and each of the optical flow cubes after the interval mask operation, the prediction blocks of the masked parts in each of the space-time cubes and each of the optical flow cubes are respectively obtained by using the visual network prediction; wherein, for each of the space-time cubes after the interval mask operation, the visible part on the space-time cube is pre-operated and then input into the visual network; the output vector of the visual network is projected to the original dimension before the pre-operation and deformed to the size before the pre-operation, and the prediction block of the masked part in each of the space-time cubes is obtained; wherein, the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it into a set low-dimensional space, and then adding a learnable position code; for each of the optical flow cubes after the interval mask operation, the visible part on the optical flow cube is pre-operated and then input into the visual network; the output vector of the visual network is projected to the original dimension before the pre-operation and deformed to the size before the pre-operation, and the prediction block of the masked part in each of the optical flow cubes is obtained; wherein, the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it into a set low-dimensional space, and then adding a learnable position code; According to the prediction block, respectively calculating the prediction loss of each of the space-time cubes and each of the optical flow cubes at the pixel level; According to the prediction losses of each of the space-time cubes and each of the optical flow cubes, an abnormal value score of each frame in the monitoring video data is calculated; the abnormal value score is used to indicate the abnormal event detection result of the corresponding video frame.

2. The unsupervised video anomaly detection method based on masked autoencoder according to claim 1, characterized in that: The prediction loss of the space-time cube at the pixel level is calculated by the following formula: Where C represents a space-time cube, C mask represents the original pixel value of the masked part in the space-time cube, C pred Represents the predicted pixel value of the masked part in the space-time cube.

3. The unsupervised video anomaly detection method based on masked autoencoder according to claim 1, characterized in that: The prediction loss of the optical flow cube at the pixel level is calculated by the following formula: in, represents an optical flow cube, represents the original pixel value of the masked part in the optical flow cube, Represents the predicted pixel value of the masked part in the optical flow cube.

4. The unsupervised video anomaly detection method based on masked autoencoder according to claim 1, 2 or 3, characterized in that: The step of calculating the abnormal value score of each frame in the monitoring video data according to the prediction loss of each of the space-time cubes and each of the optical flow cubes comprises: Calculating the overall prediction loss of the surveillance video data according to the prediction losses of all the space-time cubes and the optical flow cubes; For each frame of the monitoring video data, according to the overall prediction loss, the maximum value of the outlier scores of all cubes on the frame is taken as the outlier score of the corresponding video frame.

5. The unsupervised video anomaly detection method based on masked autoencoder according to claim 4 is characterized in that: The overall prediction loss is calculated by the following formula: Wherein, C represents a space-time cube, α and β represent hyperparameters for controlling the weight of the two parts of prediction loss, MSE(C) represents the prediction loss of the space-time cube at the pixel level, represents the prediction loss of the optical flow cube at the pixel level, μ and σ represent the mean and variance of the MSE loss of all spatiotemporal cubes, respectively. and Represent the mean and variance of the MSE loss of all optical flow cubes, respectively.

6. An unsupervised video anomaly detection device based on masked autoencoder, characterized in that: include: Video acquisition module, used to acquire surveillance video data; The target detection module is used to perform target detection on each frame of the monitoring video data, and extract the image blocks of the corresponding positions of the detected foreground targets in the current frame and the adjacent previous and next frames; A mask operation module is used to construct each cube according to the image blocks of each frame, and perform an interval mask operation on each cube in the time domain; the cube includes a space-time cube and an optical flow cube, wherein a plurality of time-continuous image blocks are scaled to a preset size and stacked in time order to obtain a space-time cube; for each space-time cube, an image block-level mask operation is performed in the time domain in an image block interval masking manner to obtain the space-time cube after the mask operation; the space-time cube is used to describe a video event, and half of the space-time cube after the mask operation The image block is visible, and the other half of the image block is masked; optical flow extraction is performed on multiple image blocks that are continuous in time, respectively, to obtain multiple optical flow blocks that are continuous in time; the multiple optical flow blocks that are continuous in time are scaled to a preset size and stacked in time order to obtain an optical flow cube; for each optical flow cube, a mask operation is performed on the optical flow block level in the time domain in a manner of optical flow block interval masking to obtain the optical flow cube after the mask operation; the optical flow cube is used as an action description of a video event, and half of the optical flow blocks in the optical flow cube after the mask operation are visible, and the other half of the optical flow blocks are masked; The mask prediction module is used to use the visual network to predict the predicted blocks of the masked parts in each of the space-time cubes and each of the optical flow cubes after the interval mask operation; wherein, for each of the space-time cubes after the interval mask operation, the visible part on the space-time cube is pre-operated and then input into the visual network; the output vector of the visual network is projected to the original dimension before the pre-operation and deformed to the size before the pre-operation to obtain the predicted block of the masked part in each of the space-time cubes; wherein, the pre-operation includes Flatten the visible part into a one-dimensional vector, linearly project it to a set low-dimensional space, and then add a learnable position code; for each optical flow cube after the interval mask operation, perform a pre-operation on the visible part on the optical flow cube and then input it into the visual network; project the output vector of the visual network to the original dimension before the pre-operation and deform it to the size before the pre-operation to obtain a prediction block of the masked part in each optical flow cube; wherein the pre-operation includes flattening the visible part into a one-dimensional vector, linearly projecting it to a set low-dimensional space, and then adding a learnable position code; A prediction loss module, used to calculate the prediction loss of each of the spatiotemporal cubes and each of the optical flow cubes at a pixel level according to the prediction block; The anomaly scoring module is used to calculate the anomaly value score of each frame in the monitoring video data according to the prediction loss of each of the spatiotemporal cubes and each of the optical flow cubes; the anomaly value score is used to indicate the abnormal event detection result of the corresponding video frame.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the unsupervised video anomaly detection method based on masked autoencoder according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the unsupervised video anomaly detection method based on masked autoencoder according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and device for detecting abnormal events in surveillance videos

    CN108427928A

  • Unsupervised monitoring video prediction frame anomaly detection method

    CN114067251A

  • Video frame interpolation method robust against exceptional motion, and apparatus therefor

    WO2021085757A1