A method for abnormal behavior detection in traffic scenarios

By using the window shift and global attention label methods in traffic scenes, combined with text data to train the video coding network, the existing technology solves the problems of traffic scene behavior recognition in long videos and real-time monitoring images, such as difficulty in processing and insufficient data. Improved detection performance and robustness.

CN118470664BActive Publication Date: 2024-09-27HUNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410937279.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-27
Estimated Expiration
2044-07-12

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively process long videos and real-time surveillance images when it comes to behavioral recognition in traffic scenes, and Transformer-based networks have insufficient detection performance when there is insufficient data, and have problems with insufficient robustness and generalization capabilities.

Method used

The method based on window shift and global attention label is used to train the video data encoding network, combined with text data for auxiliary training, and the features of spatial and temporal dimensions are extracted through the video window shift encoding module and text encoding network, and the attention encoding information is calculated and Construct a similarity matrix and optimize the loss function to train the network.

Benefits of technology

It improves the network's behavior recognition capabilities in long videos and real-time surveillance images, enhances detection performance under limited data, improves the accuracy and robustness of behavior detection, and alleviates the impact of data scarcity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470664B
    Figure CN118470664B
Patent Text Reader

Abstract

The present invention discloses an abnormal behavior detection method for traffic scenes, comprising collecting traffic scene video data, establishing a video data set and a text data set; preprocessing the video data in the video data set; constructing a video data coding network and a text data coding network, inputting the preprocessed data and the text data set into the video data coding network and the text data coding network for training respectively, so as to obtain attention coding information of the video data and attention coding information of the text data respectively; calculating the cosine similarity of the attention coding information of the video data and the attention coding information of the text data, constructing a similarity matrix, and obtaining a trained video data coding network in combination with a preset loss function; obtaining real-time traffic scene video data and inputting it into the trained video data coding network to obtain the attention coding information of the real-time video data, and inputting it into a detection head to obtain an abnormal behavior detection result; and effectively improving the accuracy of behavior 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 computer vision, and in particular relates to an abnormal behavior detection method for traffic scenes. Background Art

[0002] Understanding and analyzing video content is one of the hot research issues in the field of computer vision, which aims to identify and understand the actions or behaviors occurring in videos or images. Action recognition has broad application prospects in many fields such as video surveillance, sports analysis, medical diagnosis, virtual reality and game development. Behavior recognition refers to detecting the spatiotemporal location of behaviors in video sequences and predicting their categories, identifying specific behaviors of different pedestrian targets, and understanding the semantic characteristics of the target object's behavior. Some traditional behavior recognition methods have made extraordinary progress in recent decades. These methods can achieve good recognition results in specific scenarios, but they must rely on a specific feature or fused manual features, so they still show poor robustness in large-scale data sets or actual application scenarios.

[0003] With the rise of deep learning in the field of images, research on deep learning in the field of action recognition has received widespread attention, but research progress is still relatively slow. The main reason is that in actual scenes, there are many pedestrians, low video quality, and large changes in light intensity, which make it difficult for the network to extract effective semantic information of the target object. Most traditional deep learning methods are based on convolutional neural networks. However, due to the limitation of the receptive field of convolution operations, the captured semantic features can only be limited to a specific range in the image, and the recognition of human actions often requires consideration of the global information of the human body and even background information. Therefore, convolution calculation is not conducive to the recognition of human actions. In particular, convolution operations are difficult to model the features of the time dimension, so convolutional neural networks have a natural disadvantage in action recognition tasks in the field of video understanding.

[0004] Thanks to the global modeling capability of the self-attention mechanism, the Transformer based on the self-attention mechanism has received widespread attention in various fields since its introduction. Especially after the Vision Transformer, most tasks in the visual field can be completed by the Transformer, and the actual performance is higher than that of the convolutional neural network. Therefore, most breakthroughs in the visual field in recent years are based on the Transformer. However, the Transformer requires a large amount of data to achieve sufficient performance. How to give full play to the advantages of the Transformer structure when the data is insufficient is still a major challenge. At the same time, the traditional Transformer only performs global modeling and lacks the ability to model local features. Although in recent years, methods such as self-attention based on window shifting have been used to make up for this defect, this method still has a similar receptive field, and the network's ability to model the global world is also subject to certain limitations. Summary of the invention

[0005] In view of the above technical problems, the present invention provides an abnormal behavior detection method for traffic scenarios.

[0006] The technical solution adopted by the present invention to solve the technical problem is:

[0007] A method for detecting abnormal behavior in traffic scenarios, the method comprising the following steps:

[0008] S100: Collect traffic scene video data, establish a labeled traffic scene video dataset, and establish a text dataset based on the traffic scene video dataset according to the data content in the video dataset;

[0009] S200: inputting video data in the video data set into the network for preprocessing;

[0010] S300: constructing a video data encoding network and a text data encoding network, wherein the video data encoding network includes a block module, a linear encoding layer, a video window shift encoding module and a downsampling module, and the text data encoding network includes an encoder;

[0011] S400: inputting the preprocessed data into a video data coding network, training the video data coding network using a method based on window shift and global attention label, and obtaining attention coding information of the video data;

[0012] S500: Inputting the text data set into the text data encoding network for training to obtain attention encoding information of the text data;

[0013] S600: Calculate the cosine similarity of the attention coding information of the video data and the attention coding information of the text data, construct a similarity matrix according to the cosine similarity, calculate the loss in combination with a preset loss function and perform back propagation until a preset training end condition is reached to obtain a trained video data coding network;

[0014] S700: Acquire real-time traffic scene video data and input it into a trained video data encoding network to obtain attention encoding information of the real-time video data, and input it into a detection head to obtain abnormal behavior detection results.

[0015] Preferably, S100 includes:

[0016] S110: Collecting traffic scene video data, cutting the collected data into video segments with obvious action boundaries, and each video segment is within a preset time length;

[0017] S120: dividing the data with duration in the first preset duration range into a sparse action data set, and dividing the data with duration in the first preset duration range into a dense data set; wherein the minimum value of the second preset duration range is greater than the maximum value of the first preset duration range;

[0018] S130: classify all behaviors of the two data sets, and divide them into a training set, a validation set, and a test set according to a preset ratio;

[0019] S140: Establishing a text dataset based on the traffic scene video dataset according to the data content in the video dataset.

[0020] Preferably, S200 includes:

[0021] S210: storing continuous video frames in the video data set in a buffer stack. If the maximum capacity M of the stack is exceeded, the first M / 2 data of the stack are discarded, and the newly collected video frames continue to be stored at the end.

[0022] S220: Input the data in the buffer stack into the preprocessing module, and start sampling the video frames with 1 / N, 2 / N, ..., k / N frames as the starting point, and start sampling at intervals of sampling step s. Each starting point samples m frames and then ends. A total of 1 / N, 2 / N, ..., k / N frames are sampled. Frames of video frame sequence; where N is the total number of video frame sequences, k is the number of video frame sampling points, s is the video frame sampling step, and m is the number of fragment sampling.

[0023] Preferably, S400 includes:

[0024] S410: Input the pre-processed video frame sequence into a block segmentation module for segmentation;

[0025] S420: Linearly encode the channel data of each pixel through a linear encoding layer;

[0026] S430: Inputting the linearly encoded data into a video window shift encoding module, and extracting features of the spatial dimension and the temporal dimension using a method based on window shift and global attention label;

[0027] S440: The data is then reduced in dimension through the downsampling module, the information of the spatial dimension is compressed onto the channel, and sent to the next video window shift encoding module to again use the method based on window shift and global attention label to extract the features of the spatial dimension and the temporal dimension until the preset end condition is reached to obtain the attention encoding information of the video data.

[0028] Preferably, the video window shift coding module includes a first video window shift coding unit and a second video window shift coding unit, the first video window shift coding unit includes a first standardized layer, a 3D W-MSA layer, a second standardized layer and a first MLP layer, the second video window shift coding unit includes a third standardized layer, a 3D SW-MSA layer, a fourth standardized layer and a second MLP layer, and S430 is specifically:

[0029] Data after linear encoding Before entering the 3D W-MSA structure, a global attention label GA is randomly initialized and directly concatenated to The end of the formation ;

[0030] Afterwards After the first normalization layer, it enters the 3D W-MSA layer and is connected to the output of the residual After the second normalization layer, it passes through the first MLP layer and is connected with the residual to output ;

[0031] GA from Separate the remaining part After the third normalization layer, it enters the 3D SW-MSA layer and is connected to the output of the residual After the fourth normalization layer, the second MLP layer is used, and the output obtained after the residual connection is the output of the video window shift coding module. .

[0032] Preferably, S430 specifically includes:

[0033] ;

[0034] ;

[0035] ;

[0036] ;

[0037] ;

[0038] ;

[0039] Among them, GA represents the global attention label, is the input of the 3D W-MSA structure, represents the output of the 3D W-MSA layer with residual connection, The output of the 3D W-MSA structure is the remaining after GA splitting As input to the 3D SW-MSA structure, is the output of the 3D SW-MSA layer and the residual connection, Output of the 3D SW-MSA structure.

[0040] Preferably, S500 includes:

[0041] S510: The encoder in the text data encoding network adds position information to the words in the text, and then constructs a query matrix, a key matrix, and a value matrix;

[0042] S520: Inputting the text content with the position information into the query matrix, the key matrix and the value matrix to generate a query moment tensor, a key tensor and a value tensor;

[0043] S530: Performing a dot multiplication operation on the query tensor and the key tensor, normalizing the query tensor, and then multiplying the query tensor with the key tensor;

[0044] S540: After repeating S520 and S530 for a preset number of times, attention encoding information of the text data is obtained.

[0045] Preferably, the cosine similarity of the attention encoding information of the video data and the attention encoding information of the text data is calculated in S500, specifically:

[0046] ;

[0047] in, , They are the attention encoding information of video data and the attention encoding information of text data, respectively. , They are respectively the video data encoding network and the text data encoding network. Represent video data and text data respectively.

[0048] Preferably, during the video data coding network training process, n data are taken from the motion sparse data set and m data are taken from the motion dense data set. First, the n data taken from the motion sparse data set are used for training rounds, and then the m data taken from the motion dense data set are used for training rounds. A total of E rounds are trained to complete the video data coding network training.

[0049] Preferably, the attention encoding information of the real-time video data in S700 is input into the detection head to obtain the abnormal behavior detection result, including:

[0050] The attention encoding information of the real-time video data is input to the detection head, which projects the attention encoding information of the real-time video data into an N-dimensional vector through a fully connected layer, where N represents the possible action category and each element in the N-dimensional vector represents the possibility of the action existing in the input video.

[0051] False detections are filtered out through the possibility threshold to obtain the final abnormal behavior detection result.

[0052] The above abnormal behavior detection method for traffic scenarios has the following technical effects:

[0053] 1. Effectively process long videos and real-time monitoring images: The introduction of window-shifted self-attention and global attention tags is expected to improve the existing behavior recognition technology for traffic scenarios, enabling the network to better capture key moments and key behaviors, making it more effective in processing long videos and real-time monitoring images;

[0054] 2. Improved performance under limited data: Text-assisted video training can provide the network with additional information sources, thereby improving performance under limited training data, helping the network to better generalize to different traffic scenarios and alleviating the problem caused by data scarcity;

[0055] 3. Improve the detection performance based on Transformer network: The introduction of global attention tags can enhance the detection performance based on Transformer network, enabling the network to better focus on important parts of the video, thereby improving the accuracy and robustness of behavior detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 This is a flow chart of an abnormal behavior detection method for traffic scenarios in one embodiment of the present invention;

[0057] Figure 2 A structural diagram of a video window shift encoding module in one embodiment of the present invention;

[0058] Figure 3The figure is a flow chart of an abnormal behavior detection method for traffic scenarios in another embodiment of the present invention. DETAILED DESCRIPTION

[0059] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings.

[0060] In one embodiment, Figure 1 As shown, a method for detecting abnormal behavior in a traffic scene includes the following steps:

[0061] S100: Collect traffic scene video data, establish a labeled traffic scene video dataset, and establish a text dataset based on the traffic scene video dataset according to the data content in the video dataset;

[0062] S200: inputting video data in the video data set into the network for preprocessing;

[0063] S300: constructing a video data encoding network and a text data encoding network, wherein the video data encoding network includes a block module, a linear encoding layer, a video window shift encoding module and a downsampling module, and the text data encoding network includes an encoder;

[0064] S400: inputting the preprocessed data into a video data coding network, training the video data coding network using a method based on window shift and global attention label, and obtaining attention coding information of the video data;

[0065] S500: Inputting the text data set into the text data encoding network for training to obtain attention encoding information of the text data;

[0066] S600: Calculate the cosine similarity of the attention coding information of the video data and the attention coding information of the text data, construct a similarity matrix according to the cosine similarity, calculate the loss in combination with a preset loss function and perform back propagation until a preset training end condition is reached to obtain a trained video data coding network;

[0067] S700: Acquire real-time traffic scene video data and input it into a trained video data encoding network to obtain attention encoding information of the real-time video data, and input it into a detection head to obtain abnormal behavior detection results.

[0068] The above-mentioned abnormal behavior detection method for traffic scenarios solves the problem that the existing behavior recognition technology for traffic scenarios cannot effectively complete time series modeling when facing long videos or even real-time monitoring images, and the problem that it is difficult to make the Transformer-based network have sufficient detection performance under limited data, thereby effectively improving the detection performance.

[0069] In one embodiment, S100 includes:

[0070] S110: Collecting traffic scene video data, cutting the collected data into video segments with obvious action boundaries, and each video segment is within a preset time length;

[0071] S120: dividing the data with duration in the first preset duration range into a sparse action data set, and dividing the data with duration in the first preset duration range into a dense data set; wherein the minimum value of the second preset duration range is greater than the maximum value of the first preset duration range;

[0072] S130: classify all behaviors of the two data sets, and divide them into a training set, a validation set, and a test set according to a preset ratio;

[0073] S140: Establishing a text dataset based on the traffic scene video dataset according to the data content in the video dataset.

[0074] Specifically, a labeled traffic scene dataset is established by collecting video data from surveillance, driving recorders, etc. in traffic scenes. The collected data is cut into video clips with obvious action boundaries, and each video clip is less than 10 seconds. Data with a duration of 0 to 5 seconds is divided into a sparse action dataset, and data with a duration of 5 to 10 seconds is divided into a dense dataset. All behaviors of the two datasets are classified into six categories: Car_crash, Danger, Fell_Over, Normal, Normal_traffic, and Sports, and the training set, validation set, and test set are divided in a ratio of 7:2:1.

[0075] Furthermore, according to the data content in the video dataset, a text dataset based on the traffic scene video dataset is established. The elements in the text dataset correspond one-to-one to the elements in the video dataset. Text data is a text description of the video data, which gives a brief description of the content in the video, focusing on describing the subject of the action that appears or is about to appear in the video and what action appears or is about to appear. Assuming that there is no correspondence between data of different modalities, the video dataset and the text dataset are trained together to share semantic information between the two modalities. Through the joint training of different modalities, the model can extract richer and more meaningful representations from the data than a single modality. Although the method of manually identifying the action boundaries of long videos and cutting them out for labeling is effective, it is quite time-consuming and labor-intensive. The cost of labeling a large amount of data for specific tasks and specific modes is potentially reduced through the joint training of video and text dual modalities.

[0076] In one embodiment, S200 includes:

[0077] S210: storing continuous video frames in the video data set in a buffer stack. If the maximum capacity M of the stack is exceeded, the first M / 2 data of the stack are discarded, and the newly collected video frames continue to be stored at the end.

[0078] S220: Input the data in the buffer stack into the preprocessing module, and start sampling the video frames with 1 / N, 2 / N, ..., k / N frames as the starting point, and start sampling at intervals of sampling step s. Each starting point samples m frames and then ends. A total of 1 / N, 2 / N, ..., k / N frames are sampled. Frames of video frame sequence; where N is the total number of video frame sequences, k is the number of video frame sampling points, s is the video frame sampling step, and m is the number of fragment sampling.

[0079] Specifically, the video data is input into the network for preprocessing. First, the continuous video frames are stored in the buffer stack. If the maximum capacity of the stack M is exceeded, the first M / 2 data of the stack are discarded, and the newly collected video frames are stored at the end. During the actual detection process, the buffer stack continuously reads the real-time video frames captured by the camera. When the model detection is completed, all the data in the buffer stack can be read at any time for the next round of detection.

[0080] The built-in video frame preprocessing method of mmaction is used. The data in the buffer stack is input into the preprocessing module. The video frame sequence is set to i=1,2,...,N, the number of video frame sampling points k, the video frame sampling step s, and the number of fragment sampling m. First, the video frames are sampled starting from 1 / N, 2 / N,..., k / N frames, and the interval sampling step s. Each starting point samples m frames and then ends. A total of 10 frames are sampled. A sequence of video frames.

[0081] In one embodiment, S400 includes:

[0082] S410: Input the pre-processed video frame sequence into a block segmentation module for segmentation;

[0083] S420: Linearly encode the channel data of each pixel through a linear encoding layer;

[0084] S430: Inputting the linearly encoded data into a video window shift encoding module, and extracting features of the spatial dimension and the temporal dimension using a method based on window shift and global attention label;

[0085] S440: The data is then reduced in dimension through the downsampling module, the information of the spatial dimension is compressed onto the channel, and sent to the next video window shift encoding module to again use the method based on window shift and global attention label to extract the features of the spatial dimension and the temporal dimension until the preset end condition is reached to obtain the attention encoding information of the video data.

[0086] In one embodiment, the video window shift coding module includes a first video window shift coding unit and a second video window shift coding unit, the first video window shift coding unit includes a first standardized layer, a 3D W-MSA layer, a second standardized layer and a first MLP layer, the second video window shift coding unit includes a third standardized layer, a 3D SW-MSA layer, a fourth standardized layer and a second MLP layer, and S430 is specifically:

[0087] Data after linear encoding Before entering the 3D W-MSA structure, a global attention label GA is randomly initialized and directly concatenated to The end of the formation ;

[0088] Afterwards After the first normalization layer, it enters the 3D W-MSA layer and is connected to the output of the residual After the second normalization layer, it passes through the first MLP layer and is connected with the residual to output ;

[0089] GA from Separate the remaining part After the third normalization layer, it enters the 3D SW-MSA layer and is connected to the output of the residual After the fourth normalization layer, the second MLP layer is used, and the output obtained after the residual connection is the output of the video window shift coding module. .

[0090] Specifically, 3D W-MSA stands for window multi-head self-attention, 3D SW-MSA stands for moving window multi-head self-attention, and MLP stands for multi-layer perceptron; further, the output of the video window shift encoding module is obtained After that, GA After entering the second video window shift encoding module, The end splicing forms , and repeat the above operation for 4 cycles.

[0091] In one embodiment, S430 specifically includes:

[0092] ;

[0093] ;

[0094] ;

[0095] ;

[0096] ;

[0097] ;

[0098] Among them, GA represents the global attention label, is the input of the 3D W-MSA structure, represents the output of the 3D W-MSA layer with residual connection, The output of the 3D W-MSA structure is the remaining after GA splitting As input to the 3D SW-MSA structure, is the output of the 3D SW-MSA layer and the residual connection, Output of the 3D SW-MSA structure.

[0099] In convolutional neural networks, due to the special calculation method of convolution operation, there is a special concept called receptive field. Receptive field refers to the response range of a unit (neuron) on the feature map output by a certain layer of the neural network to the area of ​​the input image. That is, it indicates how "sensitive" a certain layer of neurons is to the local area of ​​the input image. Due to the existence of receptive field, a neuron in the convolutional neural network can only pay attention to part of the input. Although the Transformer operation can construct global attention information, the window shift operation limits the scope of attention calculation to a fixed-size window. Although the shifting allows overlap between windows and indirectly constructs global attention information, the attention information from the upper layer may be ignored in the next layer during network downsampling. Therefore, window shifting still has similar receptive field limitations.

[0100] By adding the Global-Attention token to the 3D W-MSA, the Global-Attention token can learn the input attention information and pass it between different encoding layers. A separate Global-Attention token can ensure that the attention information is relatively complete and passed to the next layer during the downsampling process, reducing the problem of attention information loss at a long distance that may be caused by the window self-attention operation.

[0101] In one embodiment, S500 includes:

[0102] S510: The encoder in the text data encoding network adds position information to the words in the text, and then constructs a query matrix, a key matrix, and a value matrix;

[0103] S520: Inputting the text content with the position information into the query matrix, the key matrix and the value matrix to generate a query moment tensor, a key tensor and a value tensor;

[0104] S530: Performing a dot multiplication operation on the query tensor and the key tensor, normalizing the query tensor, and then multiplying the query tensor with the key tensor;

[0105] S540: After repeating S520 and S530 for a preset number of times, attention encoding information of the text data is obtained.

[0106] Specifically, the number of video window shift coding models is the specific value of the preset number of times.

[0107] In one embodiment, the cosine similarity of the attention encoding information of the video data and the attention encoding information of the text data is calculated in S500, specifically:

[0108] ;

[0109] in, , They are the attention encoding information of video data and the attention encoding information of text data, respectively. , They are respectively the video data encoding network and the text data encoding network. Represent video data and text data respectively.

[0110] The cosine similarity of the attention encoding information of each video data and the attention encoding information of the text data is combined to obtain a similarity matrix, which represents the degree of correlation between the video data and the text data in the dataset, and finally the loss is calculated with the true value.

[0111] By adding text modality data for training, video modality data can extract more meaningful information representation, avoid overfitting, and reduce the time and labor cost of labeling large amounts of data.

[0112] In one embodiment, during the video data coding network training process, n data are taken from the motion sparse data set and m data are taken from the motion dense data set. First, the n data taken from the motion sparse data set are used for training rounds, and then the m data taken from the motion dense data set are used for training rounds. A total of E rounds are trained to complete the video data coding network training.

[0113] Specifically, using this iterative method, the network is trained by switching between motion-dense datasets and motion-sparse datasets in E training rounds, so as to enhance the model's modeling and resolution capabilities for long sequence videos.

[0114] In one embodiment, the attention encoding information of the real-time video data in S700 is input into the detection head to obtain abnormal behavior detection results, including:

[0115] The attention encoding information of the real-time video data is input to the detection head, which projects the attention encoding information of the real-time video data into an N-dimensional vector through a fully connected layer, where N represents the possible action category and each element in the N-dimensional vector represents the possibility of the action existing in the input video.

[0116] False detections are filtered out through the possibility threshold to obtain the final abnormal behavior detection result.

[0117] The above abnormal behavior detection method for traffic scenarios has the following technical effects with respect to the existing technology:

[0118] 1. Effectively process long videos and real-time monitoring images: The introduction of window-shifted self-attention and global attention tags is expected to improve the existing behavior recognition technology for traffic scenarios, enabling the network to better capture key moments and key behaviors, making it more effective in processing long videos and real-time monitoring images;

[0119] 2. Improved performance under limited data: Text-assisted video training can provide the network with additional information sources, thereby improving performance under limited training data, helping the network to better generalize to different traffic scenarios and alleviating the problem caused by data scarcity;

[0120] 3. Improve the detection performance based on Transformer network: The introduction of global attention tags can enhance the detection performance based on Transformer network, enabling the network to better focus on important parts of the video, thereby improving the accuracy and robustness of behavior detection.

[0121] The present invention can improve the performance of existing behavior recognition technology in traffic scenarios when processing long videos, real-time monitoring images and limited data, and help improve the accuracy, robustness and generalization of the system.

[0122] The above is a detailed introduction to the abnormal behavior detection method for traffic scenarios provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the core idea of ​​the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting abnormal behavior in traffic scenarios, characterized in that: The method comprises the following steps: S100: Collect traffic scene video data, establish a labeled traffic scene video dataset, and establish a text dataset based on the traffic scene video dataset according to the data content in the video dataset; S200: inputting video data in the video data set into the network for preprocessing; S300: constructing a video data encoding network and a text data encoding network, wherein the video data encoding network includes a block module, a linear encoding layer, a video window shift encoding module and a downsampling module, and the text data encoding network includes an encoder; S400: input the preprocessed data into a video data coding network, train the video data coding network using a method based on window shift and global attention label, and obtain attention coding information of the video data; S400 includes: S410: Input the pre-processed video frame sequence into a block segmentation module for segmentation; S420: Linearly encode the channel data of each pixel through a linear encoding layer; S430: Inputting the linearly encoded data into a video window shift encoding module, and extracting features of the spatial dimension and the temporal dimension using a method based on window shift and global attention label; S440: The data is then reduced in dimension through a downsampling module, the information of the spatial dimension is compressed onto a channel, and sent to the next video window shift encoding module to extract the features of the spatial dimension and the temporal dimension again using a method based on window shift and global attention label, until a preset end condition is reached, and the attention encoding information of the video data is obtained; The video window shift coding module includes a first video window shift coding unit and a second video window shift coding unit, the first video window shift coding unit includes a first standardized layer, a 3D W-MSA layer, a second standardized layer and a first MLP layer, the second video window shift coding unit includes a third standardized layer, a 3D SW-MSA layer, a fourth standardized layer and a second MLP layer, S430 is specifically: Data after linear encoding Before entering the 3D W-MSA structure, a global attention label GA is randomly initialized and directly concatenated to The end of the formation ; Afterwards After the first normalization layer, it enters the 3D W-MSA layer and is connected to the output of the residual After the second normalization layer, it passes through the first MLP layer and is connected with the residual to output ; Change GA from Separate the remaining part After the third normalization layer, it enters the 3D SW-MSA layer and is connected to the output of the residual After the fourth normalization layer, the second MLP layer is used, and the output obtained after the residual connection is the output of the video window shift coding module. ; S500: Inputting the text data set into the text data encoding network for training to obtain attention encoding information of the text data; S600: Calculate the cosine similarity of the attention coding information of the video data and the attention coding information of the text data, construct a similarity matrix according to the cosine similarity, calculate the loss in combination with a preset loss function and perform back propagation until a preset training end condition is reached to obtain a trained video data coding network; S700: Acquire real-time traffic scene video data and input it into a trained video data encoding network to obtain attention encoding information of the real-time video data, and input it into a detection head to obtain abnormal behavior detection results.

2. The method according to claim 1, characterized in that S100 includes: S110: Collecting traffic scene video data, cutting the collected data into video segments with obvious action boundaries, and each video segment is within a preset time length; S120: dividing the data with duration in the first preset duration range into a sparse action data set, and dividing the data with duration in the first preset duration range into a dense data set; wherein the minimum value of the second preset duration range is greater than the maximum value of the first preset duration range; S130: classify all behaviors of the two data sets, and divide them into a training set, a validation set, and a test set according to a preset ratio; S140: Establishing a text dataset based on the traffic scene video dataset according to the data content in the video dataset.

3. The method according to claim 2, characterized in that S200 includes: S210: Storing continuous video frames in the video data set in a buffer stack. If the maximum capacity M of the stack is exceeded, the first M / 2 data of the stack are discarded, and the newly collected video frames continue to be stored at the end. S220: Input the data in the buffer stack into the preprocessing module, and start sampling the video frames with 1 / N, 2 / N, ..., k / N frames as the starting point, and start sampling at intervals of sampling step s. Each starting point samples m frames and then ends. A total of 1 / N, 2 / N, ..., k / N frames are sampled. wherein N is the total number of video frame sequences, k is the number of video frame sampling points, s is the video frame sampling step, and m is the number of fragment samplings.

4. The method according to claim 3, characterized in that S430 is specifically: ; ; ; ; ; ; Among them, GA represents the global attention label, is the input of the 3D W-MSA structure, represents the output of the 3D W-MSA layer with residual connection, The output of the 3D W-MSA structure is the remaining after GA splitting As input to the 3D SW-MSA structure, is the output of the 3D SW-MSA layer and the residual connection, Output of the 3D SW-MSA structure.

5. The method according to claim 4, characterized in that S500 includes: S510: The encoder in the text data encoding network adds position information to the words in the text, and then constructs a query matrix, a key matrix, and a value matrix; S520: Inputting the text content with the position information into the query matrix, the key matrix and the value matrix to generate a query moment tensor, a key tensor and a value tensor; S530: Performing a dot multiplication operation on the query tensor and the key tensor, normalizing the query tensor, and then multiplying the query tensor with the key tensor; S540: After repeating S520 and S530 for a preset number of times, attention encoding information of the text data is obtained.

6. The method according to claim 5, characterized in that In S500, the cosine similarity of the attention encoding information of the video data and the attention encoding information of the text data is calculated, specifically: ; in, , They are the attention encoding information of video data and the attention encoding information of text data, respectively. , They are respectively the video data encoding network and the text data encoding network. Represents video data and text data respectively.

7. The method according to claim 6, characterized in that During the video data coding network training process, n data are taken from the motion sparse dataset and m data are taken from the motion dense dataset. First, the n data taken from the motion sparse dataset are used for training rounds, and then the m data taken from the motion dense dataset are used for training rounds. A total of E rounds are trained to complete the video data coding network training.

8. The method according to claim 7, characterized in that The attention encoding information of the real-time video data in S700 is input into the detection head to obtain abnormal behavior detection results, including: The attention encoding information of the real-time video data is input to the detection head, which projects the attention encoding information of the real-time video data into an N-dimensional vector through a fully connected layer, where N represents the possible action category and each element in the N-dimensional vector represents the possibility of the action existing in the input video. False detections are filtered out through the possibility threshold to obtain the final abnormal behavior detection result.