Weak supervision video abnormal behavior space-time detection method based on pre-training large model

By constructing the ST-VadCLIP model, combined with the frozen CLIP model and the multi-instance learning mechanism, the spatial positioning challenge of video abnormal behavior spatio-temporal detection under weak supervision conditions is solved, and efficient video abnormal behavior detection and spatial positioning are achieved.

CN118537775AActive Publication Date: 2024-08-23NORTHWESTERN POLYTECHNICAL UNIV

Patent Information

Application Number
CN202410627296.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-21
Publication Date
2024-08-23
Estimated Expiration
2044-05-21

AI Technical Summary

Technical Problem

It is difficult for existing technology to effectively apply large models for spatiotemporal detection of abnormal video behaviors under weak supervision conditions, especially in the fine positioning of spatial dimensions.

Method used

Construct the ST-VadCLIP model, combining the frozen CLIP image encoder, CLIP text encoder, local attention focusing module, temporal modeling module and spatial positioning module, and use freezing through the local attention aggregation, temporal modeling and spatial positioning modules The pre-trained large model extracts video frame-level features and calculates abnormal confidence to locate the spatial location of abnormal behavior.

Benefits of technology

It achieves spatio-temporal detection of abnormal video behaviors under weak supervision conditions, improving the performance of the model in the absence of strong supervision signals. The combination of local video features and text label features enhances the accuracy of spatial abnormal behavior detection. Multi-instance learning mechanism Cross-modal alignment is optimized and the strong generalization ability of pre-trained knowledge is retained.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537775A
    Figure CN118537775A
Patent Text Reader

Abstract

The invention relates to a weak supervision video abnormal behavior space-time detection method based on a pre-training large model, and belongs to the field of image detection. An ST-VadCLIP model is constructed; inputting a training video into the ST-VadCLIP model for training, respectively extracting global image features and spatial local image features by using a frozen CLIP image encoder, and extracting tag features of a global text tag and a local text tag by using a frozen CLIP text encoder; performing attention aggregation on the local image features, and fusing the local image features with the global image features to obtain video frame level features; sending the video frame level features to a dichotomy auxiliary detection head for coarse classification, and then calculating cosine similarity with global text label features to obtain frame level time sequence anomaly confidence; and selecting abnormal frames according to the frame-level time sequence anomaly confidence, calculating the cosine similarity of the spatial local image features and the local text label features of the frames, and obtaining an abnormal event spatial positioning result in combination with an abnormal activity motion measurement priori rule.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video abnormal behavior detection, and in particular to a method for spatiotemporal detection of video abnormal behavior, and in particular to a weakly supervised spatiotemporal detection method for video abnormal behavior based on a pre-trained large model. Background Art

[0002] In recent years, weakly supervised video anomaly detection has attracted more and more attention due to its broad application prospects. For example, with the help of video anomaly detection algorithms, more powerful intelligent video surveillance systems and video content review systems can be developed. The core requirement of weakly supervised video anomaly detection is that the anomaly detector is expected to generate anomaly confidence at the video frame level when only video-level annotations are provided. At present, most of the research in this field follows the following process. The initial step is to extract frame-level features using a pre-trained visual model, such as a three-dimensional convolutional neural network, and then input these features into a binary classifier based on multi-instance learning for model training. The last step is to detect abnormal behavior using the anomaly confidence predicted by the model. For example, the methods of Sultani et al. in the literature "Sultani W, Chen C, Shah M. real-world anomaly detection in surveillance videos. ieee conference on computer vision and pattern recognition. 2018" and Zhou et al. in the literature "Zhou H, Yu J, Yang W. dual memory units with uncertainty regulation for weakly supervised video anomaly detection. aaai conference on artificial intelligence. 2023" are based on the above process. With the development of large visual-language models, methods that use large visual-language models to participate in weakly supervised video anomaly detection have gradually emerged, such as CLIP-TSA, which uses the CLIP model to extract image features, and VadCLIP, which uses CLIP for visual-text alignment retrieval of anomalies. Previous weakly supervised video anomaly detection tasks assumed that only video-level labels were used for model training, and trained the model to detect which frames in the video had anomalies. Compared with weakly supervised video anomaly detection, weakly supervised spatiotemporal detection of abnormal video behavior is a more challenging task, which assumes that the model should detect anomalies at a finer level, that is, the spatial dimension, while keeping the supervisory signal unchanged. This requires the model to not only detect frames with anomalies in the time series, but also to locate the location of abnormal events in space. Summary of the invention

[0003] The technical problems to be solved by the present invention are:

[0004] In order to avoid the shortcomings of the prior art, the present invention provides a spatiotemporal detection method for abnormal behavior in weakly supervised videos based on a pre-trained large model, so as to solve the problem in the prior art that a large model containing rich knowledge cannot be effectively applied to the video field.

[0005] According to an embodiment of the present disclosure, a method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model is provided, the method comprising:

[0006] Constructing an ST-VadCLIP model, the ST-VadCLIP model includes a CLIP image encoder, a CLIP text encoder, a local attention focusing module, a temporal modeling module, a temporal positioning module and a spatial positioning module; wherein,

[0007] The CLIP image encoder and the CLIP text encoder are respectively the frozen CLIP image encoder and the frozen CLIP text encoder, the temporal modeling module includes a temporal Transformer encoder with fixed distance relationship attention weights, the local attention focusing module generates a module for focusing on local image features with weighted attention by measuring the degree of motion change in the local area, the temporal positioning module includes a binary classification auxiliary detection head and a text label feature similarity detection head, and the spatial positioning module uses local text description labels and motion change priors to jointly locate abnormal behavior areas;

[0008] Input the training video into the ST-VadCLIP model for training, use the frozen CLIP image encoder to extract global and local image features of the training video, and use the frozen CLIP text encoder to extract label features of global text labels and local positioning text labels corresponding to the training video;

[0009] Processing the image features using the local attention aggregation and the temporal modeling to obtain video frame level features;

[0010] The cosine similarity is calculated using video frame-level features and global text labels with trainable hint parameters to obtain anomaly confidence. At the same time, a binary classification auxiliary detection head is set to assist the network in distinguishing normal and abnormal video frame-level features.

[0011] Use the abnormal confidence to locate frames that may have abnormal behavior, and use the spatial positioning module to locate the spatial position of the abnormal behavior, including using local image features and local text label features to calculate cosine similarity, and combining motion change priors to jointly locate the abnormal behavior position;

[0012] A prediction result of the training video is obtained according to the video frame level features and the text label features.

[0013] The local image feature aggregation module of the disclosed embodiment is used to focus on the image features of abnormal areas from different spatial scales; the temporal modeling module improves the performance of the Transformer structure in weakly supervised video anomaly detection by fixing the prior distance attention weight; the normal and abnormal description labels generated by the large language model are combined with the prior rules of abnormal activity motion measurement, so that the frozen ST-VadCLIP model can effectively adapt to the weakly supervised video abnormal behavior spatiotemporal detection task.

[0014] The step of extracting the image features of the training video using the frozen CLIP image encoder further includes:

[0015] Every preset value frame, a frame is sampled and sent to the CLIP image encoder to obtain the image features.

[0016] When each complete frame of the image passes through the CLIP image encoder, according to the principle of Vision Transformer, the image will be divided into multiple non-overlapping blocks to represent each area of ​​the image; when extracting global image features, all blocks are input into the CLIP image encoder, and when extracting local image features, the blocks representing the specified area are input into the CLIP image encoder to obtain image features representing the local area.

[0017] The step of extracting label features of text labels corresponding to the training video using the frozen CLIP text encoder includes:

[0018] Convert the text label into a category vector through Tokenizer;

[0019] concatenating the category vector with a learnable cue to obtain a vector sequence;

[0020] The CLIP text encoder extracts the vector sequence to obtain the label feature.

[0021] The step of processing the local image features by using the local attention aggregation to obtain video frame level features includes:

[0022] Compressing and aggregating the local image features using the local attention aggregation;

[0023] The local aggregated image features and the global image features are added to obtain the video frame level features.

[0024] The temporal Transformer encoder obtains the attention weight by calculating the distance length between two frames, rather than the dot product attention of the traditional Transformer.

[0025] The timing positioning module comprises:

[0026] The aggregated video frame-level features are used to calculate the cosine similarity with the global text label, and then the anomaly confidence is obtained through the Softmax normalization function.

[0027] The binary classification auxiliary detection head includes a fully connected layer, and the number of neurons in the fully connected layer is 1.

[0028] The spatial positioning module comprises:

[0029] According to the abnormal confidence, a threshold is set. If the threshold is exceeded, it means that the frame has abnormal behavior and is extracted to the spatial positioning module;

[0030] The cosine similarity is calculated between the local image features of possible abnormal frames and the local text description features obtained through the large language model to obtain the spatial abnormality confidence.

[0031] The local image features contain two scales, and the local text description features contain the part describing abnormal behavior and the part describing things that may appear in normal scenes;

[0032] Motion change prior: calculate the change degree of each local block compared with the blocks at the same position in the previous and next two frames, set a threshold to filter out blocks with small changes, and set the abnormal confidence of these blocks to 0;

[0033] The bounding box of the abnormal behavior is located according to the results of spatial anomaly confidence.

[0034] The method for calculating the degree of change of each block includes:

[0035] Select a local block position, calculate the feature of the block, subtract the feature of the block from the previous frame and the next frame, and then find the result of the L2 norm;

[0036] The result is used to measure the degree of change of the current area. If it is less than the threshold, it means that the current area has not changed much in these three frames.

[0037] The method further includes:

[0038] The test video is input into the trained ST-VadCLIP model to obtain the prediction result of the test video.

[0039] The step of inputting the training video into the ST-VadCLIP model for training further includes:

[0040] For the temporal localization module, for both the anomaly confidence and the auxiliary detection head, the multi-instance learning mechanism is used to select the average of K high anomaly confidences in the abnormal and normal videos as the video-level prediction of the test video, and then the classification loss is calculated using the binary cross entropy between the video-level prediction and the true label;

[0041] For all global text label features, calculate the average similarity between each text label feature and other text label features as the text separation loss;

[0042] A total loss function is calculated according to the classification loss and the text separation loss.

[0043] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0044] In the embodiments of the present disclosure, through the above-mentioned method for spatiotemporal detection of abnormal behavior in videos, the attention aggregation mechanism of local image features can capture the characteristics of small-sized abnormal behaviors in videos; the distance attention weight improves the performance of the Transformer timing adapter in the absence of strong supervision signals; the text label features with learnable prompts can effectively complete the weakly supervised abnormal behavior timing detection task, and the auxiliary detection head can improve the performance of the model; the local video features and local text label features utilize the powerful generalization ability of the CLIP model to locate abnormal areas in space, and the motion change prior improves the accuracy of spatial abnormal behavior detection by introducing artificial priors; the cross-modal alignment mechanism based on multi-instance learning realizes optimization under weak supervision, thereby retaining pre-trained knowledge as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0046] Figure 1 A step diagram showing a method for spatiotemporal detection of abnormal video behavior in an exemplary embodiment of the present disclosure;

[0047] Figure 2 A framework diagram showing the ST-VadCLIP model in an exemplary embodiment of the present disclosure;

[0048] Figure 3 A flow chart showing a method for detecting abnormal behavior in a video in an exemplary embodiment of the present disclosure is shown;

[0049] Figure 4A qualitative schematic diagram of time series abnormal behavior detection on the UCF-Crime dataset in an exemplary embodiment of the present disclosure is shown;

[0050] Figure 5 A qualitative schematic diagram of spatial abnormal behavior detection on the UCF-Crime dataset in an exemplary embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0051] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0052] In addition, the accompanying drawings are only schematic illustrations of the embodiments of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities.

[0053] This example implementation first provides a method for detecting abnormal behavior in a video. Figure 1 As shown in , the method for detecting abnormal behavior in a video may include: steps S101 to S106.

[0054] Step S101: constructing a VadCLIP model, wherein the VadCLIP model includes a CLIP image encoder, a CLIP text encoder, a local attention focusing module, a temporal modeling module, a temporal positioning module and a spatial positioning module; wherein,

[0055] The CLIP image encoder and the CLIP text encoder are respectively the frozen CLIP image encoder and the frozen CLIP text encoder, the temporal modeling module includes a temporal Transformer encoder with fixed distance relationship attention weights, the local attention focusing module generates a module for focusing on local image features with weighted attention by measuring the degree of motion change in the local area, the temporal positioning module includes a binary classification auxiliary detection head and a text label feature similarity detection head, and the spatial positioning module uses local text description labels and motion change priors to jointly locate abnormal behavior areas;

[0056] Step S102: inputting the training video into the VadCLIP model for training, using the frozen CLIP image encoder to extract global and local image features of the training video, and using the frozen CLIP text encoder to extract label features of global text labels and local positioning text labels corresponding to the training video;

[0057] Step S103: Processing the image features by using the local attention aggregation and the temporal modeling to obtain video frame level features;

[0058] Step S104: Calculate the cosine similarity using the video frame level features and the global text label with trainable hint parameters to obtain the anomaly confidence, and set a binary classification auxiliary detection head to assist the network in distinguishing normal and abnormal video frame level features;

[0059] Step S105: locating frames that may have abnormal behavior using the abnormal confidence, and locating the spatial position of the abnormal behavior using the spatial positioning module, including calculating cosine similarity using local image features and local text label features, and locating the abnormal behavior position in combination with motion change priors;

[0060] Step S106: obtaining a prediction result of the training video according to the video frame level features and the text label features.

[0061] Through the above-mentioned method of spatiotemporal detection of abnormal behaviors in videos, the attention aggregation mechanism of local image features can capture the characteristics of small-sized abnormal behaviors in videos; the distance attention weight improves the performance of the Transformer timing adapter in the absence of strong supervision signals; the text label features with learnable prompts can effectively complete the weakly supervised abnormal behavior temporal detection task, and the auxiliary detection head can improve the performance of the model; local video features and local text label features utilize the powerful generalization ability of the CLIP model to locate abnormal areas in space, and the motion change prior improves the accuracy of spatial abnormal behavior detection by introducing artificial priors; the cross-modal alignment mechanism based on multi-instance learning realizes optimization under weak supervision, thereby retaining pre-trained knowledge as much as possible.

[0062] Next, we will refer to Figure 1 Method for Spatiotemporal Detection of Abnormal Video Behavior The various steps of the method for spatiotemporal detection of abnormal video behavior in this example implementation are described in more detail.

[0063] The present application provides a new paradigm for weakly supervised video abnormal behavior detection, which directly uses a frozen pre-trained large model (i.e., CLIP model) to build an anomaly detection model (i.e., ST-VadCLIP model), which does not require any pre-training and fine-tuning process. The pre-trained large model used in this application is the CLIP (Contrastive Language-Image Pre-Training) model open sourced by OpenAI, which is a large-scale image-text cross-modal contrastive learning model, consisting of an image encoder based on a transformer structure and a text encoder based on a transformer structure, and is trained through contrastive learning of 400 million pairs of high-quality image-text pairs, which gives CLIP a high image recognition accuracy and strong generalization ability, and can complete many downstream tasks without additional training or fine-tuning of parameters.

[0064] like Figure 2 As shown, the present application fully utilizes the advantages of the pre-trained large model and constructs a dual-branch network to realize abnormal behavior temporal detection and abnormal behavior spatial detection. The temporal detection branch uses image features and text label features to obtain abnormal confidence, while the spatial detection branch makes full use of the generalization ability of CLIP and uses the similarity of local image features and local text label features to locate the abnormal behavior position in the image. With the advantages of dual branches, the present application effectively transfers the pre-trained knowledge to the weakly supervised video abnormal behavior detection task, while realizing the temporal dimension detection and spatial dimension positioning of video abnormal behavior under weak supervision. As shown Figure 3 As shown, it is a flow chart of the method for spatiotemporal detection of abnormal video behavior of the present application. The technical solution adopted by the present application to solve its technical problem includes the following steps:

[0065] In step S101, a training video is input to obtain global and local image features:

[0066] Given a video in the training set, we first use the CLIP image encoder of the frozen pre-trained large model to extract frame-level global image features X clip and local image features X patch .

[0067] Specifically, given a video in the training set, the CLIP image encoder of the frozen pre-trained large model is first used as a video frame feature extractor, and the feature dimension after extraction is 512 dimensions. When extracting global image features, the complete frame image is directly input into the CLIP image encoder to obtain an image feature. When extracting local image features, the first 2D convolutional layer of the CLIP image encoder divides the image into 14×14 patch blocks, re-divides the patch into 2×2 adjacent non-overlapping blocks, and inputs them into the subsequent layers of the encoder to obtain local image features that divide the original image into 7×7 blocks. Due to computing resource constraints, for a given training video, one frame is sampled every 16 frames when extracting features and sent to the image encoder. Finally, the video frame-level feature X is obtained. clip In this application, the longest time sequence length supported for video input is 256, that is, the frame-level image feature X clip The maximum length is 256. If the length exceeds the maximum time series length, it is directly truncated into multiple segments with a maximum length of 256. If the length is less than the maximum length, it is padded with 0.

[0068] In step S102, input the corresponding tag and obtain the tag feature

[0069] For the global text label corresponding to the video and the local text label used for abnormal behavior spatial positioning, the CLIP text encoder of the frozen pre-trained large model is used to extract the label feature t out and t patch .

[0070] Specifically, for global text labels, which are usually words or phrases, they are too concise and cannot summarize abnormal events well. Therefore, we use a large language model to expand the number of text labels. Specifically, we ask the large language model ChatGPT3.5 to give synonyms of abnormal and normal text labels. In order to learn the robust transferability of text embedding, learnable hints are added to the original label information. Specifically, the original text label is first converted into a category vector through Tokenizer. The conversion process is as follows,

[0071] t=Tokenizer(Label) (1)

[0072] where “Label” is a discrete text label, such as battle, shooting, traffic accident, etc. Then t is combined with a set of l learnable cues {c1,...,c l} are connected to form a complete sentence vector sequence as the input of the text encoder. The vector sequence is as follows:

[0073] t p ={c1, ... , t, ... , cl} (2)

[0074] This vector sequence is added to the position encoding to obtain the position information, and then input into the CLIP text encoder of the pre-trained large model to generate the video label feature t out .

[0075] The local text description labels used for spatial positioning of abnormal behaviors are also generated by the large language model ChatGPT3.5. The model is queried using fixed prompt words to obtain fine-grained local text descriptions that describe normal images and abnormal behavior images respectively. These text descriptions are input into the text encoder of CLIP to generate local text description label features t patch .

[0076] In step S103, local attention aggregation and the temporal modeling process the image features to obtain video frame level features

[0077] The purpose of extracting local image features is to be able to focus on abnormal events in a small range. The global image features are insufficient for the characterization of many small-scale abnormal events, so this application uses local image features to compensate for this problem. In order to focus on the area where the abnormal event occurs, this application designs a local attention aggregation method. This method introduces an artificial prior, that is, when an abnormal event occurs, the image in the corresponding area changes greatly. For example, when a fight, explosion, car accident, etc. occurs, it is a continuously changing dynamic event.

[0078] Specifically, in order to describe the degree of change of the local area image, the present application designs the following method: Take a local feature X of the tth frame of the area number i patch_i t , subtract it from the features of the previous frame and the next frame at the same position, and then calculate the L2 norm. The result is the degree of regional change. This operation can be described by the following formula:

[0079] Mo i t =|| 2X patch_i t -X patch_i t+1 -X patch_i t-1 || L2 (3)

[0080] When the image in this area changes slightly, the feature similarity between the previous and next frames after the CLIP image encoder is high and remains stable. At this time, the result of Formula 3 after subtraction is close to 0; when the image in this area changes greatly, the feature similarity between the previous and next frames is small. At this time, the result of Formula 3 after subtraction is larger than the previous case.

[0081] Since direct subsequent processing of local image features will consume more computing resources, this application reduces the computational complexity by aggregating local features into one feature. For a total of 7×7 local blocks, according to the calculated degree of change M, this application selects the 12 regions with the highest degree of change for aggregation, and discards the rest. Using the softmax normalized degree of change Mo as the attention weight, the regional image features are weighted and aggregated to obtain the local aggregated features. The calculation process is shown in the following formula:

[0082] Attention t =Softmax(TOP(Mo t ))(4)

[0083] X as t =(Attention t ) T X Mo t

[0084] Where X Mo t is the patch image feature of the 12 regions with the highest scores in the t-th frame Mo. After aggregation, the final local aggregation feature X is obtained. as t , and the global image feature X clip t The final video image features are obtained by adding them together.

[0085] Since the image encoder of the pre-trained large model is trained at the image level, it lacks the capture of temporal relationships. This application designs a temporal modeling module to process image features that lack contextual temporal relationships and capture temporal relationships. Since the weakly supervised anomaly detection task lacks sufficient supervisory information, directly using Transformer as a temporal modeler does not work well, which has been verified in other methods. In order to improve this phenomenon, this application designs an attention matrix based on the relative distance between two frames for capturing temporal relationships.

[0086] Specifically, H dis The attention matrix is ​​obtained by calculating the distance between the two frames. The calculation method can be written as the following formula:

[0087]

[0088] The distance length relationship between the i-th frame and the j-th frame is determined only by their relative temporal positions, and σ is a hyperparameter that controls the range of influence of the distance relationship. According to this formula, the closer the relative distance between the two frames, the higher the score, the larger the value of the adjacency matrix, and the more information exchange.

[0089] The video image features are input into two distance attention Transformers, and finally the video frame level features X are obtained after temporal relationship modeling.

[0090] In step S104, the video frame level feature anomaly confidence is calculated

[0091] When calculating the frame-level anomaly confidence, it is divided into two modules, one is the auxiliary detection head module, and the other is the video-text label alignment module.

[0092] The auxiliary detection head module consists of a fully connected layer, which inputs the video frame-level feature X and outputs the frame-level anomaly confidence, ranging from 0 to 1. This output is not used as the final temporal anomaly detection result, but is only used to assist the neural network in separating normal and abnormal frames.

[0093] The video-text label alignment module uses the video frame level features and the global text label features to align and calculate the similarity to obtain the abnormal confidence result. The global text label contains multiple normal labels and abnormal labels. All normal label features are averaged to obtain a total normal category label feature and concatenated with other abnormal label features. The video frame level features are added to the global frame features extracted by the original CLIP image encoder, and then the cosine similarity matrix is ​​calculated with the text label features, as shown in the following formula:

[0094]

[0095] The similarity matrix M represents the similarity between the video frame and the text labels of all categories, where the vector S = {s1,...,s m} represents the similarity between a video frame and all category labels, and all vectors are normalized using the Softmax function, as shown in the following formula:

[0096]

[0097] Finally, the confidence probability p of the normal category is selected normal , calculate 1-p normal , and obtain the frame-level anomaly confidence p.

[0098] In step S105, the abnormal confidence is used to locate the frame that may have abnormal behavior, and the spatial positioning module is used to locate the spatial position of the abnormal behavior.

[0099] The frame-level anomaly confidence p is used to locate the location of the abnormal event in time series, and a threshold is set. If p is greater than the threshold, it is considered that an abnormal event exists in the frame, and further spatial abnormal event detection is performed.

[0100] The detection of spatial abnormal behavior is divided into two steps. The first step is to calculate the similarity using local image features and local text description features, and use the generalization performance of CLIP to detect suspicious abnormal areas, referring to the practice of industrial image anomaly detection. In order to improve the detection rate, in addition to the original 7×7 local image patch features, this application also uses 4×4 divided local image patch features. Calculate the cosine similarity of local image features and local text description features and normalize them using the Softmax function. Refer to formulas 6 and 7, and take the sum of all abnormal category probabilities as the abnormality confidence map of the current area.

[0101] Since the sizes of the 7×7 area division and the 4×4 area division are different, this application uses the resize function in the OpenCV library to expand the 4×4 spatial anomaly confidence map to 7×7 by bilinear interpolation, and then weightedly add it to the original 7×7 spatial anomaly confidence map to obtain the spatial anomaly confidence map.

[0102] Due to the clarity of the video itself, the semantic ambiguity of the text description label, etc., the obtained spatial anomaly confidence map may have a high false alarm rate. In order to reduce the false alarm rate, this application introduces the motion change prior proposed in the previous article. Specifically, take the change degree matrix Mo, set a threshold, set it to 1 when it exceeds the threshold, and set it to 0 when it is less than the threshold, and obtain the motion mask matrix Mask, as shown in the following formula:

[0103]

[0104] Among them Mo ij Represents the area of ​​the i-th row and j-th column of the degree of change matrix. The Mask matrix is ​​obtained by this formula and multiplied by the spatial confidence map above to obtain the final spatial confidence map S.

[0105] In step S106, the prediction result of the training video is obtained

[0106] For temporal anomaly detection, a multi-instance learning mechanism is used to select the average of K high anomaly confidences in abnormal and normal videos as the video-level prediction. The classification loss L is then calculated using the binary cross entropy between the video-level prediction and the true label. bce1 Similarly, the auxiliary detection head uses the same loss function to calculate the classification loss L bce2 , used to assist in separating normal and abnormal video features.

[0107] For spatial anomaly detection, the final spatial confidence map S is 7×7 in size. This application uses the OpenCV library function resize to enlarge it to the size of the original video, turning it into an abnormal heat map, and then uses the OpenCV library function findCounters to find the area with the largest area in the abnormal heat map as the final abnormal event bounding box. After enlarging to the original video size, the overlap (IoU) can be calculated with the abnormal event annotation box under the original video coordinates.

[0108] In order to increase the distance between normal text label features and abnormal text label features, this application designs an additional text separation loss function. For all global text label features, the average similarity between each text label feature and other text label features is calculated as the text separation loss L dis The higher the similarity between normal text features and abnormal text features, the greater the loss function result, which encourages the network to move towards. The final total loss function is L bce1 +L bce2 +L dis .

[0109] The effect of the present application is further described below in conjunction with simulation experiments.

[0110] 1. Simulation conditions:

[0111] The simulations for this application were performed using PyTorch software on a server containing an NVIDIA RTX3090 graphics card.

[0112] 2. Simulation content and result analysis:

[0113] The present application and eight prior art methods (including one semi-supervised method, one fully supervised method and six weakly supervised methods) were used for comparative simulation on the commonly used UCF-Crime dataset.

[0114] The simulation experiment data used in this application is UCF-Crime, which is the first proposed weakly supervised abnormal surveillance video dataset. It contains 1900 videos from 13 abnormal categories, of which the training set contains 1610 videos and the test set contains 290 videos.

[0115] Table 1 Comparison results between the proposed method and existing methods on the UCF-Crime dataset

[0116]

[0117] The present application and existing semi-supervised, fully supervised and weakly supervised video abnormal behavior detection methods were simulated under the same experimental settings and experimental environment, and the quantitative evaluation of the UCF-Crime dataset and the abundance value comparison are shown in Table 1. As can be seen from Table 1, the present application method is significantly better than the methods based on semi-supervision, full supervision and weak supervision. More precisely, the present application method achieved an average accuracy of 88.08% in UCF-Crime, which is 0.5% and 1.33% better than the best competitors CLIP-TSA and DMU. At the same time, in terms of the temporal overlap of the spatial anomaly positioning indicator (that is, the sum of the traditional positioning indicator overlap TIOU divided by the total number of all frames), the present application method is more than 7% better than the comparison method. Figure 4 As shown in, it is a qualitative schematic diagram of time series anomaly detection on the UCF-Crime dataset; Figure 5 The figure shows a qualitative diagram of spatial anomaly detection on the UCF-Crime dataset.

[0118] Through the above-mentioned method of video abnormal behavior detection, the attention aggregation mechanism of local image features can capture the characteristics of small-scale abnormal behaviors in the video; the distance attention weight improves the performance of the Transformer timing adapter in the absence of strong supervision signals; the text label features with learnable prompts can effectively complete the weakly supervised abnormal behavior timing detection task, and the auxiliary detection head can improve the performance of the model; the local video features and local text label features utilize the powerful generalization ability of the CLIP model to locate the abnormal areas in space, and the motion change prior improves the accuracy of spatial abnormal behavior detection by introducing artificial priors; the cross-modal alignment mechanism based on multi-instance learning realizes optimization under weak supervision, thereby retaining the pre-trained knowledge as much as possible.

[0119] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification.

[0120] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.

Claims

1. A spatiotemporal detection method for abnormal behavior in weakly supervised videos based on a pre-trained large model, characterized in that: include: Constructing an ST-VadCLIP model, wherein the ST-VadCLIP model includes a CLIP image encoder, a CLIP text encoder, a local attention focusing module, a temporal modeling module, a temporal positioning module, and a spatial positioning module; The CLIP image encoder and the CLIP text encoder are respectively the frozen CLIP image encoder and the frozen CLIP text encoder, the temporal modeling module includes a temporal Transformer encoder with fixed distance relationship attention weights, the local attention focusing module generates a module for focusing on local image features with weighted attention by measuring the degree of motion change in the local area, the temporal positioning module includes a binary classification auxiliary detection head and a text label feature similarity detection head, and the spatial positioning module uses local text description labels and motion change priors to jointly locate abnormal behavior areas; Input the training video into the ST-VadCLIP model for training, use the frozen CLIP image encoder to extract global and local image features of the training video, and use the frozen CLIP text encoder to extract label features of global text labels and local positioning text labels corresponding to the training video; Processing the image features using the local attention aggregation and the temporal modeling to obtain video frame level features; The cosine similarity is calculated using video frame-level features and global text labels with trainable hint parameters to obtain anomaly confidence. At the same time, a binary classification auxiliary detection head is set to assist the network in distinguishing normal and abnormal video frame-level features. Use the abnormal confidence to locate frames that may have abnormal behavior, and use the spatial positioning module to locate the spatial position of the abnormal behavior, including using local image features and local text label features to calculate cosine similarity, and combining motion change priors to jointly locate the abnormal behavior position; A prediction result of the training video is obtained according to the video frame level features and the text label features.

2. According to claim 1, the method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model is characterized in that: The step of extracting the image features of the training video using the frozen CLIP image encoder also includes: Every preset value frame, sampling a frame and sending it to the CLIP image encoder to obtain the image features; When each complete frame of the image passes through the CLIP image encoder, according to the principle of Vision Transformer, the image will be divided into multiple non-overlapping blocks to represent each area of ​​the image; when extracting global image features, all blocks are input into the CLIP image encoder, and when extracting local image features, the blocks representing the specified area are input into the CLIP image encoder to obtain image features representing the local area.

3. According to claim 2, the method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model is characterized in that: The step of extracting label features of text labels corresponding to the training video using the frozen CLIP text encoder includes: Convert the text label into a category vector through Tokenizer; concatenating the category vector with a learnable cue to obtain a vector sequence; The CLIP text encoder extracts the vector sequence to obtain the label feature.

4. According to claim 3, the method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model is characterized in that: The step of processing the local image features by using the local attention aggregation to obtain video frame level features includes: Compressing and aggregating the local image features using the local attention aggregation; The local aggregated image features and the global image features are added to obtain the video frame level features.

5. According to claim 4, the method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model is characterized in that: The temporal Transformer encoder obtains the attention weight by calculating the distance length between two frames, rather than the dot product attention of the traditional Transformer.

6. According to claim 5, the method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model is characterized in that: The timing positioning module comprises: The aggregated video frame-level features are used to calculate the cosine similarity with the global text label, and then the anomaly confidence is obtained through the Softmax normalization function. The binary classification auxiliary detection head includes a fully connected layer, and the number of neurons in the fully connected layer is 1.

7. The method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model according to claim 6 is characterized in that: The spatial positioning module comprises: According to the abnormal confidence, a threshold is set. If the threshold is exceeded, it means that the frame has abnormal behavior and is extracted to the spatial positioning module; The cosine similarity is calculated between the local image features of possible abnormal frames and the local text description features obtained through the large language model to obtain the spatial abnormality confidence. The local image features contain two scales, and the local text description features contain the part describing abnormal behavior and the part describing things that may appear in normal scenes; Motion change prior: calculate the change degree of each local block compared with the blocks at the same position in the previous and next two frames, set a threshold to filter out blocks with small changes, and set the abnormal confidence of these blocks to 0; The bounding box of the abnormal behavior is located according to the results of spatial anomaly confidence.

8. The method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model according to claim 7, characterized in that: The method for calculating the degree of change of each block includes: Select a local block position, calculate the feature of the block, subtract the feature of the block from the previous frame and the next frame, and then find the result of the L2 norm; The result is used to measure the degree of change of the current area. If it is less than the threshold, it means that the current area has not changed much in these three frames.

9. The method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model according to claim 8, characterized in that: The method further includes: The test video is input into the trained ST-VadCLIP model to obtain the prediction result of the test video.

10. The method for spatiotemporal detection of abnormal behavior in weakly supervised videos based on a pre-trained large model according to claim 1, characterized in that: The step of inputting the training video into the ST-VadCLIP model for training further includes: For the temporal localization module, for both the anomaly confidence and the auxiliary detection head, the multi-instance learning mechanism is used to select the average of K high anomaly confidences in the abnormal and normal videos as the video-level prediction of the test video, and then the classification loss is calculated using the binary cross entropy between the video-level prediction and the true label; For all global text label features, calculate the average similarity between each text label feature and other text label features as the text separation loss; A total loss function is calculated according to the classification loss and the text separation loss.

Citation Information

Patent Citations

  • Key frame detection method and device, equipment, storage medium and program product

    CN114359775A

  • Multi-granularity video retrieval method and device

    CN117194710A

  • Image feature matching unmanned aerial vehicle geographic positioning method for near-field security and protection

    CN117853952A

  • System and Method for AI-Prompt-Triggering of End Devices for Immersive Effects

    US20240001228A1

  • Neural network prompt tuning

    US20240095534A1

Cited By

  • Audio and video event positioning method based on fine tuning pre-training large model

    CN119475244A

  • Dynamic map modal semantic segmentation method and system for vehicle-mounted mining video monitoring

    CN119625323A

  • Abnormal event video instruction data generation method and device

    CN120580626A

  • Abnormal behavior analysis and prediction system and method based on unmanned aerial vehicle monitoring system

    CN121121575A

  • Abnormity detection method based on multi-modal and multi-level features, electronic equipment, storage medium and program product

    CN121191097A