Abnormal video detection method and system based on graph neural network

Through a graph neural network-based method, combined with temporal and spatial feature extraction and a double-layer attention model, the problem of poor generalization performance and noise interference in video anomaly detection in complex scenes in the existing technology is solved, and a more efficient video is achieved. Anomaly detection.

CN117557962BActive Publication Date: 2024-09-27SHENZHEN RES INST OF BIG DATA
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202311586605.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-23
Publication Date
2024-09-27
Estimated Expiration
2043-11-23

AI Technical Summary

Technical Problem

Existing video anomaly detection technology has poor generalization performance in complex and rapidly changing scenes, and is difficult to effectively detect complex anomalies, especially due to timing changes and noise interference, and the application scope of object-based recognition methods is limited.

Method used

Using a graph neural network-based method, the video data is segmented into video segments and image blocks, and then input into the temporal branch network and spatial branch network respectively for feature extraction. It is combined with a double-layer attention model to calculate anomaly probability, paying attention to the relationship between time and space. , customize the image block size to improve detection accuracy.

Benefits of technology

It improves the accuracy and robustness of video anomaly detection, reduces noise interference, expands the application scope of detection, and can more effectively identify abnormal parts of video frames and image blocks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117557962B
    Figure CN117557962B
Patent Text Reader

Abstract

The present invention discloses an abnormal video detection method, system, device and medium based on graph neural network. By decoupling the video in time and space, the relationship between time and space is paid attention to at the same time, and the relationship between different image blocks is learned by dividing the video frame into blocks in the spatial branch, thereby solving the problems faced by the image reconstruction-based and object-based recognition methods. On the one hand, the basic object is changed from a whole image to a small image, which increases the abnormal proportion and reduces the sensitivity of abnormal detection. On the other hand, by using image blocks of custom sizes, it is possible to detect whether each image block is abnormal. In addition, a two-layer attention model is set up to detect the probability distribution of that frame of video or that image block deviates from the normal value by learning the attention relationship of different aspects between adjacent image blocks, so that video anomalies can be better detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of neural network technology, and in particular to an abnormal video detection method, system, computer equipment and storage medium based on graph neural network. Background Art

[0002] Video anomalies can be considered as the occurrence of abnormal appearance or motion attributes, or the occurrence of normal appearance or motion attributes at abnormal locations or times. Currently, the technology for detecting video anomalies is widely used in various places, such as roads, banks, hospitals and other public places, which can greatly ensure the safety of people's lives and property.

[0003] At present, the following three methods are usually used to detect video anomalies. The first is to use the method of automatic encoder to map the input image to the latent space, and then restore the original image based on the feature vector in the latent space. This method uses the learned latent features to judge the difference between normal video frames and abnormal video frames. The second is based on predicting future frames: the first t frames in the video data of frame t+1 are used as training data, and the image of frame t+1 is predicted. The difference with the real frame t+1 is used to identify whether this frame is abnormal. The third is based on scene object recognition: the objects in the video are obtained in advance using the target detection and tracking method, and then the subsequent abnormality recognition method is used on the video of multiple objects detected on this basis to detect the abnormal objects.

[0004] However, when the first method is used for video anomaly detection, in complex and rapidly changing scenes, the generalization performance is poor because the impact of temporal changes on the image is not taken into account. At the same time, since the abnormal part of most images only occupies a small part of the entire image, the difference between normal frames and abnormal frames is very small and easily affected by noise. When the second method is used for video anomaly detection, since the predicted image is sampled from the previous t frames, the newly appeared objects in the t+1 frame will also be identified as abnormal, so the application scenarios of this method are limited. When the third method is used for video anomaly detection, the object needs to be detected in advance. However, in real videos, the abnormal objects are often not determined in advance, so this method of detecting abnormal objects has a limited scope of application. Summary of the invention

[0005] Based on this, it is necessary to provide an abnormal video detection method, system, computer device and storage medium based on graph neural network to address the above technical problems, so as to solve at least one problem existing in the above-mentioned prior art.

[0006] In a first aspect, an embodiment of the present application provides an abnormal video detection method based on a graph neural network, comprising:

[0007] Acquire original video data, divide the original video data into a plurality of video segments, and divide each video frame corresponding to each video segment into a plurality of image blocks;

[0008] Inputting the video clip and the image block into a time branch network and a space branch network respectively for feature extraction to obtain a time feature and a space feature;

[0009] Inputting the temporal feature and the spatial feature into a first attention model respectively to obtain a temporal feature and a spatial feature after attention processing;

[0010] Performing pooling processing on the time features and the spatial features after the attention processing respectively to obtain a time fusion feature and a spatial fusion feature;

[0011] The temporal fusion features and the spatial fusion features are respectively input into the second attention model to respectively determine the abnormal probability values ​​corresponding to each video frame and each image block, and determine the abnormal video frame and the abnormal image block according to the abnormal probability values.

[0012] In one embodiment, the pooling process is performed on the time features and the spatial features after the attention processing to obtain the time fusion feature and the spatial fusion feature, including:

[0013] Respectively performing dimensionality reduction processing on the time features and the spatial features after the attention processing to obtain a time average feature and a spatial average feature;

[0014] The time average feature and the space-time feature are fused respectively to obtain the time fusion feature and the space fusion feature.

[0015] In one embodiment, fusing the time average feature and the space-time feature to obtain the time fusion feature and the space fusion feature includes:

[0016] Fusing the temporal average feature with the spatial feature after the attention processing to obtain the temporal fusion feature;

[0017] The spatial average feature is fused with the attention-processed temporal feature to obtain the spatial fusion feature.

[0018] In one embodiment, the temporal fusion feature and the spatial fusion feature are respectively input into the second attention model to respectively determine the abnormal probability value corresponding to each video frame and each image block, including:

[0019] Inputting the temporal fusion features and the spatial fusion features into the second attention model respectively to obtain the temporal fusion features and the spatial fusion features after attention processing;

[0020] The temporal fusion feature and the spatial fusion feature are calculated respectively by a preset activation function to obtain the abnormal probability value corresponding to each video frame and each image block respectively;

[0021] When the abnormality probability value is lower than a preset threshold, it is determined that the corresponding video frame or image block has an abnormality.

[0022] In one embodiment, the video clip and the image block are respectively input into a time branch network and a space branch network for feature extraction to obtain a time feature and a space feature, including:

[0023] Sending the video clip to a first feature extraction model for feature extraction to obtain the time feature;

[0024] The image block is sent to the second feature extraction model for feature extraction to obtain the spatial feature.

[0025] In one embodiment, the first attention model and the second attention model are trained in the following manner:

[0026] Obtain a video sample data set, wherein the video sample data set includes a plurality of video sample data with real labels;

[0027] Constructing a time and space graph structure according to the video sample data with real labels, wherein the graph structure includes graph nodes and edges;

[0028] Inputting the video sample data with real labels into the time branch network and the space branch network for feature extraction, respectively, to obtain the time feature and space feature of each graph node;

[0029] Based on the temporal characteristics and spatial characteristics of each graph node, the initial first attention model and the initial second attention model are iteratively trained until the loss value between the abnormal probability value and the true label reaches a preset convergence condition, thereby obtaining the trained first attention model and second attention model.

[0030] In one embodiment, the iterative training of the initial first attention model and the initial second attention model based on the temporal features and spatial features of each graph node includes:

[0031] Input the time feature and the spatial feature of each of the graph nodes into the initial first attention model for attention processing, so as to obtain the time feature and the spatial feature of each of the graph nodes after attention processing;

[0032] Performing pooling processing on the temporal features and spatial features of each graph node after the attention processing to obtain sample temporal fusion features and sample spatial features;

[0033] Based on the sample time fusion features and the sample space features, an abnormal probability value corresponding to each video frame and each image block is determined respectively through an initial second attention model;

[0034] When the abnormal probability value does not meet the preset convergence condition, the initial first attention model and the initial second attention model are trained by gradient descent method.

[0035] In one embodiment, the training of the initial first attention model and the initial second attention model by a gradient descent method includes:

[0036] Updating the graph node features output by the initial second attention model;

[0037] Calculate the attention weights of the edges between two adjacent graph nodes using the updated graph node features;

[0038] Based on the attention weights, graph node features output by the first attention model are updated.

[0039] In one embodiment, constructing a temporal and spatial graph structure according to the video sample data with real labels includes:

[0040] The video sample data with the real label is divided into a plurality of video sample segments, and each video frame corresponding to each of the video sample segments is divided into a plurality of sample image blocks;

[0041] Taking each of the video frames as the graph node, constructing edges between the graph nodes to obtain a time graph structure, wherein the weight of the edge is the inverse of the temporal distance;

[0042] Each of the sample image blocks is used as the graph node, and edges between the graph nodes are constructed to obtain a spatial graph structure, wherein the weight of the edge is the inverse of the distance between different sample image blocks.

[0043] In a second aspect, a graph neural network-based abnormal video detection system is provided, the system comprising:

[0044] An original video data segmentation unit, used to obtain original video data, segment the original video data into a plurality of video segments, and segment each video frame corresponding to each video segment into a plurality of image blocks;

[0045] A spatiotemporal feature extraction unit, used for inputting the video clip and the image block into a temporal branch network and a spatial branch network respectively for feature extraction to obtain temporal features and spatial features;

[0046] An attention processing unit, used for inputting the temporal feature and the spatial feature into a first attention model respectively, so as to obtain a temporal feature and a spatial feature after attention processing;

[0047] A pooling unit, used to perform pooling processing on the time features and the spatial features after the attention processing respectively, so as to obtain a time fusion feature and a spatial fusion feature;

[0048] The video anomaly determination unit is used to input the temporal fusion features and the spatial fusion features into the second attention model respectively to determine the abnormal probability values ​​corresponding to each video frame and each image block respectively, and determine the abnormal video frame and the abnormal image block according to the abnormal probability values.

[0049] In a third aspect, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the abnormal video detection method based on graph neural network as described above.

[0050] In a fourth aspect, a computer-readable storage medium is provided, storing a computer program. When the computer program is executed by a processor, the processor executes the abnormal video detection method based on graph neural network as described above.

[0051] The above-mentioned abnormal video detection method, system, computer device and storage medium based on graph neural network, the method implementation includes: obtaining original video data, dividing the original video data into multiple video segments, and dividing each video frame corresponding to each video segment into multiple image blocks; inputting the video segments and the image blocks into the time branch network and the space branch network for feature extraction respectively to obtain time features and space features; inputting the time features and the space features into the first attention model respectively to obtain the time features and space features after attention processing; pooling the time features and space features after attention processing respectively to obtain time fusion features and space fusion features; inputting the time fusion features and space fusion features into the second attention model respectively to determine the abnormal probability values ​​corresponding to each video frame and each image block respectively, and determine the abnormal video frame and abnormal image block according to the abnormal probability values. In the embodiment of the present application, by decoupling the video in time and space, the relationship between time and space is paid attention to at the same time, and the relationship between different image blocks is learned by dividing the video frame into blocks in the spatial branch, thereby solving the problems faced by the image reconstruction-based and object-based recognition methods. On the one hand, the basic object is changed from a whole image to a small image, so the abnormal part accounts for a basic unit, thereby reducing the sensitivity of abnormal detection. On the other hand, after the image block of custom size is defined, each block can be detected to see if an abnormality occurs, solving the problem that the scene object-based method can identify whether the object is abnormal. In addition, through the two-layer attention model, by learning the attention relationship between different aspects of adjacent image blocks, the probability distribution of that frame of video or that block of image deviates from the normal value can be detected, so that the video abnormality can be better detected. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0053] Figure 1 It is a schematic diagram of an application environment of an abnormal video detection method based on a graph neural network in one embodiment of the present invention;

[0054] Figure 2 It is a flow chart of an abnormal video detection method based on a graph neural network in one embodiment of the present invention;

[0055] Figure 3 It is a structural schematic diagram of an abnormal video detection system based on a graph neural network in one embodiment of the present invention;

[0056] Figure 4 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0058] In one embodiment, if Figure 1 The figure shows an implementation environment diagram of an abnormal video detection method based on a graph neural network. Figure 2 As shown, a method for detecting abnormal videos based on a graph neural network is provided, comprising the following steps:

[0059] In step S110, original video data is obtained, the original video data is divided into a plurality of video segments, and each video frame corresponding to each video segment is divided into a plurality of image blocks;

[0060] In an embodiment of the present application, the original video data may be a continuous long video to be detected that is captured by a preset video capture device. The continuous long video may be evenly divided into multiple video segments according to a preset number of frames. For example, each video segment may include 5 consecutive video frames, and each video frame image may be evenly divided into multiple image blocks. For example, each frame image may be divided into 9 image blocks.

[0061] In step S120, the video clip and the image block are respectively input into a time branch network and a space branch network for feature extraction to obtain a time feature and a space feature;

[0062] In an embodiment of the present application, a time branching network and a space branching network can be constructed respectively. After the original video data is divided into video segments and image blocks, the video segments can be input into the time branching network to obtain the time feature, and the image blocks can be input into the space branching network to obtain the space feature.

[0063] In one embodiment of the present application, the video clip and the image block are respectively input into a time branch network and a space branch network for feature extraction to obtain a time feature and a space feature, including:

[0064] Sending the video clip to a first feature extraction model for feature extraction to obtain the time feature;

[0065] The image block is sent to the second feature extraction model for feature extraction to obtain the spatial feature.

[0066] Specifically, the time branch network includes the first feature extraction model, and the space branch network includes the second feature extraction model. After obtaining the video clip and the image block, the video clip can be input into the first feature extraction model to obtain the time features corresponding to each frame of each video clip, and the image block can be input into the second feature extraction model to obtain the spatial features corresponding to each image block.

[0067] Among them, the first feature extraction model and the second feature extraction model can both be I3D models, and the I3D model can be pre-trained with video data in a video data sample set.

[0068] In step S130, the temporal feature and the spatial feature are respectively input into a first attention model to obtain a temporal feature and a spatial feature after attention processing;

[0069] In the embodiment of the present application, the first attention model may include two, which are used to perform attention processing on the time features extracted by the first feature extraction model in the time branch network, and to perform attention processing on the spatial features extracted by the second feature extraction model in the space branch network, see Figure 1 , when the video clip includes 5 video frames, the obtained time feature may include 5 time features, namely t1, t2, t3, t4, and t5. i When the frame image is divided into 9 image blocks, the obtained spatial features can be p1, p2...p8, p9. Then they are respectively input into the first attention model for processing, and the processed temporal features and spatial features can be obtained, namely t'1, t'2...t'5, and p'1, ​​p'2...p'8, p'9.

[0070] Among them, the first attention model can be a graph attention network (GAT) model, through which the features of adjacent graph nodes can be better aggregated and updated, so as to learn the attention relationship of different aspects between adjacent image blocks, so as to better detect the abnormal frame and image in the video.

[0071] In step S140, pooling processing is performed on the time features and spatial features after the attention processing to obtain time fusion features and spatial fusion features;

[0072] In an embodiment of the present application, the time branch network and the space branch network may respectively include a graph pooling layer, which may respectively perform pooling processing on the features processed by the first attention model. For example, the processed time features and spatial features, i.e., t'1, t'2...t'5, and p'1, ​​p'2...p'8, p'9, are respectively input into the corresponding graph pooling layers for dimensionality reduction and fusion to obtain the time fusion feature and the spatial fusion feature, i.e., t″1, t″2...t″5, and p″1, p″2...p″8, p″9.

[0073] In one embodiment of the present application, the pooling process is performed on the time features and the spatial features after the attention processing to obtain the time fusion features and the spatial fusion features, including:

[0074] Respectively performing dimensionality reduction processing on the time features and the spatial features after the attention processing to obtain a time average feature and a spatial average feature;

[0075] The time average feature and the space-time feature are fused respectively to obtain the time fusion feature and the space fusion feature.

[0076] Specifically, the time branch network and the space branch network may respectively include a graph pooling layer, which may respectively perform dimensionality reduction processing on the time features and space features processed by the first attention model to obtain a time average feature and a space average feature. The time average feature may be the mean of all time features, and the space average feature may be the mean of all space features. Then, the time average feature and the space-time feature are fused to obtain a time fusion feature and a space fusion feature for subsequent abnormal probability judgment.

[0077] Furthermore, the fusing of the time average feature and the space-time feature to obtain the time fusion feature and the space fusion feature includes:

[0078] Fusing the temporal average feature with the spatial feature after the attention processing to obtain the temporal fusion feature;

[0079] The spatial average feature is fused with the attention-processed temporal feature to obtain the spatial fusion feature.

[0080] Specifically, after obtaining the temporal average feature and the spatial average feature, the temporal average feature can be added to the spatial features after all attention processing, and the spatial average feature can be added to the temporal features after all attention processing, so as to obtain new features after the fusion of time and space, that is, the temporal fusion feature and the spatial fusion feature, which can be calculated by the following formula:

[0081]

[0082]

[0083] in, and They can represent the temporal features of the time branch network and the spatial features of the space branch network respectively. N and M represent the number of consecutive frames of the video clip in the time branch network and the number of image blocks in the space branch network respectively.

[0084] In step S150, the temporal fusion features and the spatial fusion features are respectively input into the second attention model to respectively determine the abnormal probability values ​​corresponding to each video frame and each image block, and determine the abnormal video frame and the abnormal image block according to the abnormal probability values.

[0085] In an embodiment of the present application, a two-layer graph attention model, namely a GAT model, is constructed in the time branch network and the space branch network respectively. The extracted time features and spatial features can be processed by the first layer of the GAT model, and then pooled by the graph pooling layer to obtain the time fusion features and the space fusion features. Then, after being processed again by the second layer of the GAT model, the abnormality probability value of each video frame and the abnormality probability value of each image block can be output. Based on the abnormality probability value, it can be determined which video frame and which image block have abnormalities, thereby improving the accuracy of video anomaly detection.

[0086] Among them, the second attention model can also be a graph attention network (GAT) model. Through the GAT model, the features of adjacent graph nodes can be better aggregated and updated, so as to learn the attention relationship of different aspects between adjacent image blocks, so as to better detect the abnormal frame and image in the video.

[0087] In one embodiment of the present application, based on the fusion feature, determining the abnormal probability value corresponding to each video frame and each image block through the second attention model respectively includes:

[0088] Inputting the temporal fusion features and the spatial fusion features into the second attention model respectively to obtain the temporal fusion features and the spatial fusion features after attention processing;

[0089] The temporal fusion feature and the spatial fusion feature are calculated respectively by a preset activation function to obtain the abnormal probability value corresponding to each video frame and each image block respectively;

[0090] When the abnormality probability value is lower than a preset threshold, it is determined that the corresponding video frame or image block has an abnormality.

[0091] Specifically, the temporal fusion feature and the spatial fusion feature are respectively input into the second attention model to obtain the temporal fusion feature and the spatial fusion feature after attention processing. After being processed by the second preset attention model, the feature dimension of the temporal fusion feature and the spatial fusion feature becomes 1, and then the value is mapped to a probability value of 0-1 through a preset activation function, such as sigmoid, which can be represented by t and p respectively, so that the probability value corresponding to each video frame and the probability value corresponding to each image block can be obtained. When the probability value is lower than a preset threshold, for example, lower than 0.5, it can be considered that the image block or video frame is abnormal. By finding all video frames and image blocks with probability values ​​lower than 0.5, it can be determined which video frame and image block are abnormal.

[0092] In one embodiment of the present application, the first attention model and the second attention model may be trained in the following manner:

[0093] Obtain a video sample data set, wherein the video sample data set includes a plurality of video sample data with real labels;

[0094] Constructing a time and space graph structure according to the video sample data with real labels, wherein the graph structure includes graph nodes and edges;

[0095] Inputting the video sample data with real labels into the time branch network and the space branch network for feature extraction, respectively, to obtain the time feature and space feature of each graph node;

[0096] Based on the temporal characteristics and spatial characteristics of each graph node, the initial first attention model and the initial second attention model are iteratively trained until the loss value between the abnormal probability value and the true label reaches a preset convergence condition, thereby obtaining the trained first attention model and second attention model.

[0097] Specifically, the video sample data set may include multiple video sample data, and abnormal data in the video sample data can be annotated by manual annotation to form a true label, and then the video sample data is divided into continuous preset frames, such as 5 video frame segments, and each frame image of the video frame segment is divided into multiple image blocks, for example, evenly divided into 9 image blocks, and a time graph structure and a space graph structure can be constructed according to the video segment and the image block. The graph structure may include graph nodes, and the graph nodes can be connected by edges. At the same time, the video segment and the image block can be respectively input into the processing time branch network and the space branch network for feature extraction to obtain the time feature and spatial feature of each graph node, and then the initial first attention model and the initial second attention model are iteratively trained through the time feature and spatial feature of each graph node until the loss value between the abnormal probability value and the true label reaches the preset convergence condition, thereby obtaining the trained first attention model and the second attention model.

[0098] Among them, in the time branch network, the true label of the abnormal video frame can be 1, and the true label of the normal video frame can be 0, which is expressed as y t In the spatial branch network, the true label of the abnormal image block can be 1, and the true label of the normal image block can be 0, which is expressed as y s , therefore, the loss function can use cross entropy, and the specific calculation formula is as follows:

[0099]

[0100] Among them, α is the weight hyperparameter for measuring time and space, and its value is 0-1.

[0101] After the loss value is calculated by the loss function, the above steps are repeated based on the loss value to iteratively train the first attention module and the second attention module. When the loss value reaches the preset convergence condition, the first attention model and the second attention model that have been trained are obtained.

[0102] Further, the iterative training of the initial first attention model and the initial second attention model based on the temporal features and spatial features of each graph node includes:

[0103] Input the time feature and the spatial feature of each of the graph nodes into the initial first attention model for attention processing, so as to obtain the time feature and the spatial feature of each of the graph nodes after attention processing;

[0104] Performing pooling processing on the temporal features and spatial features of each graph node after the attention processing to obtain sample temporal fusion features and sample spatial features;

[0105] Based on the sample time fusion features and the sample space features, an abnormal probability value corresponding to each video frame and each image block is determined respectively through an initial second attention model;

[0106] When the abnormal probability value does not meet the preset convergence condition, the initial first attention model and the initial second attention model are trained by gradient descent method.

[0107] Specifically, when training the first attention model and the second attention model, the temporal features and spatial features of each of the graph nodes can be first input into the initial first attention model for attention processing to obtain the temporal features and spatial features of each of the graph nodes after attention processing, and then input into the pooling layer for dimensionality reduction and fusion respectively. The fused features are processed by the second attention module respectively, and finally the abnormal probability values ​​corresponding to each video frame and each image block are obtained. When the abnormal probability values ​​do not meet the preset convergence conditions, the initial first attention model and the initial second attention model can be trained by the gradient descent method, and a prediction evaluation score can be given at the same time.

[0108] Further, the training of the initial first attention model and the initial second attention model by the gradient descent method includes:

[0109] Update the graph node features output by the initial second attention model;

[0110] Calculate the attention weights of the edges between two adjacent graph nodes using the updated graph node features;

[0111] Based on the attention weights, graph node features output by the first attention model are updated.

[0112] Specifically, firstly, the initial time and space relationship matrix, that is, the initial time graph structure and the initial space graph structure, can be constructed for the video sample data according to the distance. The matrix is ​​specifically as follows:

[0113]

[0114] Among them, i and j are the corresponding video frame subscripts in the time branch or the corresponding image block subscripts in the space branch, respectively. The relationship parameter between two different frames or blocks is the inverse of the corresponding subscript distance, otherwise it is 1.

[0115] Furthermore, the learning process of the GAT model is as follows, where the features of each image are represented as h i and h j , the following is the formula for learning the weight of the edge between two nodes:

[0116]

[0117] Among them, LeakyReLU is the activation function, which performs nonlinear transformation on the features, N i is the neighbor set corresponding to the image node i, W is the learnable parameter of the node, a T is the learnable parameter of the edge, and || means concatenating the features.

[0118] The graph node feature h' i The features of neighbor image nodes can be aggregated according to the multi-head attention weights of the edge and the initialization spatiotemporal relationship weights, that is, the features of multiple heads are spliced ​​together, which can be calculated by the following formula:

[0119]

[0120] Among them, K represents the number of heads, that is, considering the attention weights between nodes from different angles, and σ is the ReLU activation function.

[0121] From the above method, it can be seen that after the features of the graph nodes are updated, the weights of the edges between the graph nodes can also be updated, thereby realizing the learning of the edge weights. Through the gradient descent method, the second-layer GAT model is reversed to the first-layer GAT model, and the weights are continuously learned to realize the learning of the double-layer GAT model.

[0122] In an embodiment of the present application, constructing a time and space graph structure according to the video sample data with real labels includes:

[0123] The video sample data with the real label is divided into a plurality of video sample segments, and each video frame corresponding to each of the video sample segments is divided into a plurality of sample image blocks;

[0124] Taking each of the video frames as the graph node, constructing edges between the graph nodes to obtain a time graph structure, wherein the weight of the edge is the inverse of the temporal distance;

[0125] Each of the sample image blocks is used as the graph node, and edges between the graph nodes are constructed to obtain a spatial graph structure, wherein the weight of the edge is the inverse of the distance between different sample image blocks.

[0126] Specifically, by constructing the temporal graph structure and the spatial graph structure, for example, in the spatial graph structure, each image block can be regarded as a graph node, and the graph nodes are connected by edges, and the weight of the edge is composed of two parts: the constructed initial temporal relationship matrix and the representation relationship weight learned by GAT. In the temporal graph structure, the weight of the edge can be the reciprocal of the temporal distance, and in the spatial graph structure, the weight of the edge can be the reciprocal of the distance between different sample image blocks. By constructing the graph structure, the graph attention model GAT learns the weight of the edge, which can effectively solve the problems faced by image reconstruction-based and object-based recognition methods. By decoupling the video in time and space, the abnormal probability distribution is learned from two aspects at the same time, and it can detect in which frame of the video and in which block of the image the abnormality occurs.

[0127] The embodiments of the present application provide an abnormal video detection method, system, computer device and storage medium based on a graph neural network. The method implementation includes: obtaining original video data, dividing the original video data into multiple video segments, and dividing each video frame corresponding to each video segment into multiple image blocks; inputting the video segments and the image blocks into a time branch network and a space branch network for feature extraction to obtain time features and space features; inputting the time features and the space features into a first attention model to obtain time features and space features after attention processing; pooling the time features and space features after attention processing to obtain time fusion features and space fusion features; inputting the time fusion features and space fusion features into a second attention model to determine the abnormal probability values ​​corresponding to each video frame and each image block, and determine the abnormal video frame and abnormal image block according to the abnormal probability values. In the embodiment of the present application, by decoupling the video in time and space, the relationship between time and space is paid attention to at the same time, and the relationship between different image blocks is learned by dividing the video frame into blocks in the spatial branch, thereby solving the problems faced by the image reconstruction-based and object-based recognition methods. On the one hand, the basic object is changed from a whole image to a small image, so the abnormal part accounts for a basic unit, thereby reducing the sensitivity of abnormal detection. On the other hand, after the image block of custom size is defined, each block can be detected to see if an abnormality occurs, solving the problem that the scene object-based method can identify whether the object is abnormal. In addition, through the two-layer attention model, by learning the attention relationship between different aspects of adjacent image blocks, the probability distribution of that frame of video or that block of image deviates from the normal value can be detected, so that the video abnormality can be better detected.

[0128] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0129] In one embodiment, a graph neural network-based abnormal video detection system is provided, and the graph neural network-based abnormal video detection system corresponds to the graph neural network-based abnormal video detection method in the above embodiment. Figure 3 As shown, the abnormal video detection system based on graph neural network includes an original video data segmentation unit 10, a spatiotemporal feature extraction unit 20, an attention processing unit 30, a pooling unit 40 and a video abnormality determination unit 50. The functional modules are described in detail as follows:

[0130] The original video data segmentation unit 10 is used to obtain original video data, segment the original video data into a plurality of video segments, and segment each video frame corresponding to each video segment into a plurality of image blocks;

[0131] A spatiotemporal feature extraction unit 20, configured to input the video clip and the image block into a temporal branch network and a spatial branch network respectively for feature extraction, so as to obtain temporal features and spatial features;

[0132] An attention processing unit 30, configured to input the temporal feature and the spatial feature into a first attention model respectively, so as to obtain a temporal feature and a spatial feature after attention processing;

[0133] A pooling unit 40, used to perform pooling processing on the time features and the spatial features after the attention processing, so as to obtain a time fusion feature and a spatial fusion feature;

[0134] The video anomaly determination unit 50 is used to input the temporal fusion features and the spatial fusion features into the second attention model respectively to determine the abnormal probability values ​​corresponding to each video frame and each image block respectively, and determine the abnormal video frame and the abnormal image block according to the abnormal probability values.

[0135] In one embodiment of the present application, the pooling unit 40 is further used for:

[0136] Respectively performing dimensionality reduction processing on the time features and the spatial features after the attention processing to obtain a time average feature and a spatial average feature;

[0137] The time average feature and the space-time feature are fused respectively to obtain the time fusion feature and the space fusion feature.

[0138] In one embodiment of the present application, the pooling unit 40 is further used for:

[0139] Fusing the temporal average feature with the spatial feature after the attention processing to obtain the temporal fusion feature;

[0140] The spatial average feature is fused with the attention-processed temporal feature to obtain the spatial fusion feature.

[0141] In one embodiment of the present application, the video abnormality determination unit 50 is further configured to:

[0142] Inputting the temporal fusion features and the spatial fusion features into the second attention model respectively to obtain the temporal fusion features and the spatial fusion features after attention processing;

[0143] The temporal fusion feature and the spatial fusion feature are calculated respectively by a preset activation function to obtain the abnormal probability value corresponding to each video frame and each image block respectively;

[0144] When the abnormality probability value is lower than a preset threshold, it is determined that the corresponding video frame or image block has an abnormality.

[0145] In one embodiment of the present application, the spatiotemporal feature extraction unit 20 is further used to:

[0146] Sending the video clip to a first feature extraction model for feature extraction to obtain the time feature;

[0147] The image block is sent to the second feature extraction model for feature extraction to obtain the spatial feature.

[0148] In one embodiment of the present application, the system further includes: an attention model training unit, configured to:

[0149] Obtain a video sample data set, wherein the video sample data set includes a plurality of video sample data with real labels;

[0150] Constructing a time and space graph structure according to the video sample data with real labels, wherein the graph structure includes graph nodes and edges;

[0151] Inputting the video sample data with real labels into the time branch network and the space branch network for feature extraction, respectively, to obtain the time feature and space feature of each graph node;

[0152] Based on the temporal characteristics and spatial characteristics of each graph node, the initial first attention model and the initial second attention model are iteratively trained until the loss value between the abnormal probability value and the true label reaches a preset convergence condition, thereby obtaining the trained first attention model and second attention model.

[0153] In one embodiment of the present application, the attention model training unit is further used to:

[0154] Input the time feature and the spatial feature of each of the graph nodes into the initial first attention model for attention processing, so as to obtain the time feature and the spatial feature of each of the graph nodes after attention processing;

[0155] Performing pooling processing on the temporal features and spatial features of each graph node after the attention processing to obtain sample time average features and sample space average features;

[0156] Performing pooling processing on the temporal features and spatial features of each graph node after the attention processing to obtain sample temporal fusion features and sample spatial features;

[0157] Based on the sample time fusion features and the sample space features, an abnormal probability value corresponding to each video frame and each image block is determined respectively through an initial second attention model;

[0158] When the abnormal probability value does not meet the preset convergence condition, the initial first attention model and the initial second attention model are trained by gradient descent method.

[0159] In one embodiment of the present application, the attention model training unit is further used to:

[0160] Update the graph node features output by the initial second attention model;

[0161] Calculate the attention weights of the edges between two adjacent graph nodes using the updated graph node features;

[0162] Based on the attention weights, graph node features output by the first attention model are updated.

[0163] In one embodiment of the present application, the attention model training unit is further used to:

[0164] The video sample data with the real label is divided into a plurality of video sample segments, and each video frame corresponding to each of the video sample segments is divided into a plurality of sample image blocks;

[0165] Taking each of the video frames as the graph node, constructing edges between the graph nodes to obtain a time graph structure, wherein the weight of the edge is the inverse of the temporal distance;

[0166] Each of the sample image blocks is used as the graph node, and edges between the graph nodes are constructed to obtain a spatial graph structure, wherein the weight of the edge is the inverse of the distance between different sample image blocks.

[0167] In the embodiment of the present application, by decoupling the video in time and space, the relationship between time and space is paid attention to at the same time, and the relationship between different image blocks is learned by dividing the video frame into blocks in the spatial branch, thereby solving the problems faced by the image reconstruction-based and object-based recognition methods. On the one hand, the basic object is changed from a whole image to a small image, so the abnormal part accounts for a basic unit, thereby reducing the sensitivity of abnormal detection. On the other hand, after the image block of custom size is defined, each block can be detected to see if an abnormality occurs, solving the problem that the scene object-based method can identify whether the object is abnormal. In addition, through the two-layer attention model, by learning the attention relationship between different aspects of adjacent image blocks, the probability distribution of that frame of video or that block of image deviates from the normal value can be detected, so that the video abnormality can be better detected.

[0168] For the specific limitations of the abnormal video detection system based on graph neural networks, please refer to the limitations of the abnormal video detection method based on graph neural networks above, which will not be repeated here. Each module in the above-mentioned abnormal video detection system based on graph neural networks can be implemented in whole or in part through software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0169] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium. The readable storage medium stores computer-readable instructions. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instructions are executed by the processor, a parking lot recommendation method is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.

[0170] In an embodiment of the present application, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and when the processor executes the computer-readable instructions, the steps of the parking lot recommendation method described above are implemented.

[0171] In an embodiment of the application, a readable storage medium is provided, wherein the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the roadside parking lot recommendation method as described above are implemented.

[0172] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they may 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 may 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. By way of 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 (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0173] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0174] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. An abnormal video detection method based on graph neural network, characterized in that: The method comprises: Acquire original video data, divide the original video data into a plurality of video segments, and divide each video frame corresponding to each video segment into a plurality of image blocks; Inputting the video clip and the image block into a time branch network and a space branch network respectively for feature extraction to obtain a time feature and a space feature; Inputting the temporal feature and the spatial feature into a first attention model respectively to obtain a temporal feature and a spatial feature after attention processing; Performing pooling processing on the time features and the spatial features after the attention processing respectively to obtain a time fusion feature and a spatial fusion feature; Inputting the temporal fusion features and the spatial fusion features into the second attention model respectively to determine the abnormal probability values ​​corresponding to each video frame and each image block respectively, and determining the abnormal video frame and the abnormal image block according to the abnormal probability values; Among them, the first attention model and the second attention model are trained in the following manner: obtaining a video sample data set, the video sample data set including a plurality of video sample data with real labels; constructing a time and space graph structure according to the video sample data with real labels, the graph structure including graph nodes and edges; inputting the video sample data with real labels into the time branch network and the space branch network respectively for feature extraction to obtain the time features and space features of each graph node; iteratively training the initial first attention model and the initial second attention model based on the time features and space features of each graph node until the abnormal probability value is consistent with the real label When the loss value between them reaches the preset convergence condition, the first attention model and the second attention model that have been trained are obtained; the temporal and spatial graph structures are constructed according to the video sample data with real labels, including: dividing the video sample data with real labels into multiple video sample segments, and dividing each video frame corresponding to each of the video sample segments into multiple sample image blocks; taking each of the video frames as the graph node, constructing edges between the graph nodes to obtain a temporal graph structure, and the weight of the edges is the inverse of the temporal distance; taking each of the sample image blocks as the graph node, constructing edges between the graph nodes to obtain a spatial graph structure, and the weight of the edges is the inverse of the distance between different sample image blocks.

2. The abnormal video detection method of graph neural network according to claim 1, characterized in that: The pooling process is performed on the time features and the space features after the attention processing to obtain the time fusion features and the space fusion features, including: Respectively performing dimensionality reduction processing on the time features and the spatial features after the attention processing to obtain a time average feature and a spatial average feature; Feature fusion is performed on the temporal average feature and the spatial average feature respectively to obtain the temporal fusion feature and the spatial fusion feature.

3. The abnormal video detection method of graph neural network according to claim 2, characterized in that: The fusing the temporal average feature and the spatial average feature to obtain the temporal fusion feature and the spatial fusion feature includes: Fusing the temporal average feature with the spatial feature after the attention processing to obtain the temporal fusion feature; The spatial average feature is fused with the attention-processed temporal feature to obtain the spatial fusion feature.

4. The abnormal video detection method of graph neural network according to claim 1, characterized in that: The step of inputting the temporal fusion features and the spatial fusion features into the second attention model to respectively determine the abnormal probability values ​​corresponding to each video frame and each image block, including: Inputting the temporal fusion features and the spatial fusion features into the second attention model respectively to obtain the temporal fusion features and the spatial fusion features after attention processing; The temporal fusion feature and the spatial fusion feature are calculated respectively by a preset activation function to obtain the abnormal probability value corresponding to each video frame and each image block respectively; When the abnormality probability value is lower than a preset threshold, it is determined that the corresponding video frame or image block has an abnormality.

5. The abnormal video detection method of graph neural network according to claim 1, characterized in that: The video clip and the image block are respectively input into the time branch network and the space branch network for feature extraction to obtain time features and space features, including: Sending the video clip to a first feature extraction model for feature extraction to obtain the time feature; The image block is sent to a second feature extraction model for feature extraction to obtain the spatial feature.

6. The abnormal video detection method of graph neural network according to claim 1, characterized in that: The iterative training of the initial first attention model and the initial second attention model based on the temporal features and spatial features of each graph node includes: Input the time feature and the spatial feature of each of the graph nodes into the initial first attention model for attention processing, so as to obtain the time feature and the spatial feature of each of the graph nodes after attention processing; Performing pooling processing on the temporal features and spatial features of each graph node after the attention processing to obtain sample time average features and sample space average features; Performing pooling processing on the temporal features and spatial features of each graph node after the attention processing to obtain sample temporal fusion features and sample spatial features; Based on the sample time fusion features and the sample space features, an abnormal probability value corresponding to each video frame and each image block is determined respectively through an initial second attention model; When the abnormal probability value does not meet the preset convergence condition, the initial first attention model and the initial second attention model are trained by gradient descent method.

7. The abnormal video detection method of graph neural network according to claim 6, characterized in that: The step of training the initial first attention model and the initial second attention model by the gradient descent method includes: Updating the graph node features output by the initial second attention model; Calculate the attention weights of the edges between two adjacent graph nodes using the updated graph node features; Based on the attention weights, graph node features output by the first attention model are updated.

8. An abnormal video detection system based on graph neural network, characterized in that: The system comprises: An original video data segmentation unit, used to obtain original video data, segment the original video data into a plurality of video segments, and segment each video frame corresponding to each video segment into a plurality of image blocks; A spatiotemporal feature extraction unit, used for inputting the video clip and the image block into a temporal branch network and a spatial branch network respectively for feature extraction to obtain temporal features and spatial features; An attention processing unit, used for inputting the temporal feature and the spatial feature into a first attention model respectively, so as to obtain a temporal feature and a spatial feature after attention processing; A pooling unit, used to perform pooling processing on the time features and the spatial features after the attention processing respectively, so as to obtain a time fusion feature and a spatial fusion feature; A video anomaly determination unit, used to input the temporal fusion feature and the spatial fusion feature into a second attention model, respectively, to determine an abnormal probability value corresponding to each video frame and each image block, respectively, and to determine an abnormal video frame and an abnormal image block according to the abnormal probability value; The system further includes an attention model training unit, which is used to: obtain a video sample data set, wherein the video sample data set includes a plurality of video sample data with real labels; construct a time and space graph structure according to the video sample data with real labels, wherein the graph structure includes graph nodes and edges; input the video sample data with real labels into the time branch network and the space branch network for feature extraction, respectively, to obtain the time feature and space feature of each graph node; iteratively train the initial first attention model and the initial second attention model based on the time feature and space feature of each graph node until the loss value between the abnormal probability value and the real label reaches a preset convergence condition, thereby obtaining the trained first attention model and the second attention model; Among them, the attention model training unit is also used to: divide the video sample data with real labels into multiple video sample segments, and divide each video frame corresponding to each of the video sample segments into multiple sample image blocks; use each of the video frames as the graph node, construct edges between the graph nodes to obtain a time graph structure, and the weight of the edge is the inverse of the temporal distance; use each of the sample image blocks as the graph node, construct edges between the graph nodes to obtain a spatial graph structure, and the weight of the edge is the inverse of the distance between different sample image blocks.

Citation Information

Patent Citations

  • Video saliency detection method based on deep fusion

    CN110909594A

  • Generative adversarial network video anomaly detection method based on self-attention mechanism

    CN113313037A

  • Video anomaly detection method based on combination of residual attention block and self-selection learning

    CN116152722A

  • Multi-modal anomaly detection method based on graph attention network and time convolution network

    CN116701992A

  • Obstacle determination method, device and equipment and readable storage medium

    CN116824548A