Video anomaly detection and model training method with analysis capability
By training the video anomaly detection network and the multi-modal decoding network, combined with the image frames and frame labels of the video clips, and the instruction text, the abnormal video clips and analysis text are generated, which solves the problem of being unable to explain the analysis in the existing technology and realizes video anomalies. Efficient detection and interpretation analysis of events improve detection accuracy.
Patent Information
- Application Number
- CN202410776255.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-17
AI Technical Summary
Existing video anomaly detection methods cannot interpret and analyze the detected abnormal videos, which limits human understanding of the detection system.
By training the video anomaly detection network and the multi-modal decoding network, combined with the image frames, frame labels, and instruction text of the video clips, abnormal video clips and corresponding analysis texts are generated to realize the detection, interpretation and analysis of abnormal events.
It achieves efficient detection and interpretation analysis of video abnormal events, improves detection accuracy, and converts weakly supervised training data into fully supervised training data, improving the accuracy of the anomaly detection model.
Smart Images

Figure 00000000_0000
Abstract
Description
Technical Field
[0001] The present application belongs to the field of video detection technology, and more specifically, relates to a video anomaly detection with analysis capability and a model training method thereof. Background Art
[0002] Video anomaly detection aims to identify abnormal events in videos. In recent years, it has been widely studied due to its great application value in public safety and video content understanding. Current video anomaly detection methods based on learning can be roughly divided into three categories according to the annotation type of training data: unsupervised, weakly supervised, and fully supervised: unsupervised methods are trained only on single-category normal videos or unlabeled normal / abnormal videos, while weakly supervised methods are trained on normal / abnormal videos with video-level labels. Since there is little video data with frame-level labels, there are relatively few monitoring methods based on full supervision.
[0003] Since the video anomaly detection method based on machine learning extracts and distinguishes video features through machine learning algorithms, it does not understand the meaning of "abnormal" in human language. When abnormal videos are detected, it is unable to provide managers with an explanation of the detected anomaly, that is, "what is abnormal" and "why it is considered abnormal". This opacity limits human understanding of the detection system. Summary of the invention
[0004] In response to the above defects or improvement needs of the prior art, the present application provides a video anomaly detection method with analytical capabilities and a model training method thereof, which aims to solve the technical problem that the existing video anomaly detection method lacks explanatory analysis for video anomaly determination.
[0005] To achieve the above objectives, in a first aspect, the present application provides a video anomaly detection model training method with analysis capability, comprising:
[0006] Taking the image frames and frame labels of the video clips in the training set as input and the anomaly scores of the image frames as output, training the initial video anomaly detection network to obtain the video anomaly detection network; evaluating the anomaly score of each frame in the video clip through the video anomaly detection network, and finding the abnormal image frames whose anomaly scores are higher than a threshold;
[0007] Taking the image features of the abnormal image frame and the text features of the instruction text corresponding to the video segment where the abnormal image frame is located as input, and the analysis text corresponding to the video segment where the abnormal image frame is located as output, training an initial multimodal decoding network to obtain a multimodal decoding network;
[0008] The video detection network and the multimodal decoding network constitute a video anomaly detection model. The video anomaly detection model detects the video to be detected in combination with the input instruction text, and outputs abnormal video clips and corresponding analysis texts.
[0009] Preferably, the instruction text is a prompt text corresponding to the analysis text.
[0010] Preferably, the training set is obtained by the following method:
[0011] Select videos with video-level tags;
[0012] Randomly select a frame of image from the abnormal event of the abnormal video as a labeled frame; use a pre-trained video anomaly detection network to evaluate the anomaly scores of all image frames in the abnormal video, and divide the normal or abnormal video segments with frame-level labels based on the anomaly scores and the positions of the labeled frames;
[0013] Generate description text based on the normal or abnormal video clip using a pre-trained video description generation network;
[0014] Generate analysis text using a large language model based on whether the segment is abnormal and the corresponding description text;
[0015] A set of training data in the training set is composed of preset instruction text, analysis text and corresponding normal or abnormal video clips.
[0016] Preferably, the normal or abnormal video segments with frame-level labels are divided based on the anomaly scores and the positions of the annotated frames, specifically:
[0017] Continuous adjacent frames whose anomaly scores are greater than or equal to a threshold are grouped into an abnormal segment, which includes a marked frame, and the frame labels of the continuous adjacent frames are all abnormal; continuous adjacent frames whose anomaly scores are less than a threshold are grouped into a normal segment, which includes a marked frame, and the frame labels of the continuous adjacent frames are all normal.
[0018] Preferably, the video description generation network is specifically a multimodal visual language large model Video-LLaVA.
[0019] Preferably, the large language model is specifically the large language model Llama3.
[0020] Preferably, the image features of the abnormal image frame are extracted by a video feature extraction network, and the video feature extraction network is specifically a video encoder of a multimodal alignment framework LanguageBind.
[0021] Preferably, the text features of the instruction text are extracted by a text feature extraction network, and the text feature extraction network is specifically a text encoder of a large language model Vicuna.
[0022] Preferably, the video anomaly detection network is specifically a video anomaly detection model UR-DMU.
[0023] Preferably, the multimodal decoding network is specifically a large language model Vicuna.
[0024] In a second aspect, the present application provides a video anomaly detection method with analysis capability, comprising:
[0025] Receive a video to be detected and an instruction text, and use a pre-trained video anomaly detection model combined with the instruction text to detect the video to be detected; output abnormal video clips and corresponding analysis text; wherein the video anomaly detection model is trained according to any one of the methods described in the first aspect.
[0026] In a third aspect, the present application provides an electronic device, comprising: a memory for storing programs; a processor for executing the programs stored in the memory, and when the programs stored in the memory are executed, the processor is used to execute the method described in the first aspect or the second aspect.
[0027] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method described in the first aspect or the second aspect.
[0028] In a fifth aspect, the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method described in the first aspect or the second aspect.
[0029] In general, the above technical solutions conceived by this application have the following beneficial effects compared with the prior art:
[0030] (1) The video anomaly detection model of the present application uses a multimodal decoding network to learn the feature relationship between frame features, instruction text features and analysis text features in abnormal video clips, thereby realizing the detection and analysis of abnormal video clips. The video anomaly detection model of the present application can not only efficiently detect abnormal events in the video, but also interpret and analyze the detected abnormal events.
[0031] (2) In the training set acquisition stage of the video anomaly detection model, the present application mines frame labels in the random time series annotation points of the video anomaly events, converts the video with video-level labels into video clips with frame-level labels, thereby converting the weakly supervised training data into fully supervised training data. The anomaly detection model obtained by subsequent training also has higher detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1is a flow chart of a video anomaly detection model training method provided in an embodiment of the present application;
[0033] Figure 2 is a schematic diagram of performing video anomaly detection using a video anomaly detection model provided in an embodiment of the present application;
[0034] Figure 3 It is a schematic diagram of the training set acquisition process provided in an embodiment of the present application;
[0035] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0037] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0038] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple groups" refers to two or more groups, for example, multiple groups of training data refers to two or more groups of training data, etc.;
[0039] like Figure 1 As shown, a video anomaly detection model training method according to an embodiment of the present application includes the following steps:
[0040] First, a training set is obtained, wherein the training set includes multiple groups of training data, each group of training data includes a video clip with a frame-level label, an instruction text corresponding to the video clip, and an analysis text;
[0041] Taking the image frames and frame labels of the video clips in the training set as input and the anomaly scores of the image frames as output, training the initial video anomaly detection network to obtain the video anomaly detection network; evaluating the anomaly score of each frame in the video clip through the video anomaly detection network, and finding the abnormal image frames whose anomaly scores are higher than a threshold;
[0042] Taking the image features of the abnormal image frame and the text features of the instruction text corresponding to the video segment where the abnormal image frame is located as input, and the analysis text corresponding to the video segment where the abnormal image frame is located as output, training an initial multimodal decoding network to obtain a multimodal decoding network;
[0043] The video detection network and the multimodal decoding network constitute a video anomaly detection model. The video anomaly detection model detects the video to be detected in combination with the instruction text, and outputs abnormal video clips and corresponding analysis texts.
[0044] like Figure 2 FIG. 1 is a schematic diagram of using a video anomaly detection model to perform video anomaly detection according to an embodiment of the present application. The model implements anomaly detection and anomaly analysis through the following steps:
[0045] (1) Use a pre-trained video feature extraction network to extract the spatiotemporal characteristics of the video frame sequence from the video to be detected:
[0046]
[0047] The video feature extraction network is specifically a video encoder of the multimodal alignment framework LanguageBind, V i represents the input i-th frame image in the video to be detected, φ v Represents the video feature extraction network, the features of each frame image Including category features f i cls and block feature f i patch ,patch=1,2,…,N p , N p represents the number of image blocks, d represents the feature dimension, and N represents the number of video frames.
[0048] (2) Use the pre-trained text feature extraction network to extract the text features of the input instruction text:
[0049] f text =φ t (T)
[0050] Among them, the text feature extraction network is specifically the text encoder of the large language model Vicuna, T represents the text, φ t represents the text feature extraction network, f text Represents the text features of the output.
[0051] (3) Use the pre-trained video anomaly detection network to predict the anomaly score of each frame in the video to be detected, find the abnormal image frames with anomaly scores higher than the threshold, and retain the features corresponding to the abnormal image frames, specifically:
[0052] The category feature f of each frame image i cls Input video anomaly detection network, the network outputs the corresponding anomaly score s i ;
[0053] Based on a given threshold θ, image frames are sampled and the anomaly scores are higher than the threshold (s i >θ), retain the features corresponding to the abnormal image frames
[0054] Among them, the video anomaly detection network is specifically the video anomaly detection model UR-DMU.
[0055] (4) The multimodal decoding network decodes the text features of the instruction text and the features of the abnormal image frame, and outputs the abnormal analysis text (interpretable text), which specifically includes the following steps:
[0056] The features corresponding to the image frame The text features of the command text are concatenated and input into the multimodal text decoding network for autoregressive analysis text (interpretable text) generation:
[0057]
[0058] Among them, the multimodal decoding network is specifically the large language model Vicuna, φ proj Used to transform the visual feature F s Mapped to the text feature space, Decoder() is a multimodal decoding network, T 0:i is the text in the autoregressive process, including the input text and the generated text, T i+1 The output analysis text.
[0059] like Figure 3 FIG. 1 is a flow chart of a training set acquisition process provided in an embodiment of the present application, which specifically includes the following steps:
[0060] (1) Collecting videos, including normal videos and abnormal videos containing abnormal events, specifically including the following steps:
[0061] First, select videos with video-level labels from the existing dataset. Optionally, filter out videos that are too long or too short.
[0062] The definition of abnormal events here is defined according to the events to be detected. For example, in this embodiment, it is defined as a dangerous event. However, this application does not limit abnormal events to dangerous events. They can also be defined as flames, animals, moving objects, specific colors or fixed objects, etc.
[0063] (2) Further annotating the video, including single-frame annotation in time sequence and text description annotation at the video segment level, specifically including the following steps:
[0064] For each abnormal event in the uncropped abnormal video, a frame is randomly labeled in time sequence; and a frame of the image frame of the dangerous event appearing in the video is randomly selected and labeled as "abnormal".
[0065] Use the pre-trained video anomaly detection network UR-DMU to evaluate the anomaly scores of all image frames in the video. Crop out abnormal or normal segments in the video based on single frame annotations and anomaly scores;
[0066] Optionally, continuous adjacent frames whose anomaly scores are greater than or equal to a threshold are grouped into an abnormal segment, which includes a marked frame; continuous adjacent frames whose anomaly scores are less than the threshold are grouped into a normal segment, which includes a marked frame.
[0067] Optionally, continuous adjacent frames whose average anomaly scores are greater than or equal to a threshold are grouped into an abnormal segment, which includes annotated frames; continuous adjacent frames whose average anomaly scores are less than the threshold are grouped into a normal segment, which includes annotated frames.
[0068] A pre-trained video description generation network is used to generate a detailed text description for the cropped abnormal or normal video clips. In this embodiment, the text description is: "A person in the video is holding a gun."
[0069] Among them, the video description generation network is specifically the multimodal visual language large model Video-LLaVA.
[0070] (3) Constructing a text pair of "instruction text-analysis text" in the form of a dialogue. Specifically, the following steps are included:
[0071] A large language model is used to generate analysis text based on the judgment (text) of whether the video clip is abnormal and the description text; in this embodiment, based on the labels "abnormal" and "a person holding a gun in the video", an analysis text is generated: "a person holding a gun in the video is abnormal because it shows a violent and potentially dangerous behavior that can cause injury to others."
[0072] Among them, the large language model is specifically the large language model Llama3.
[0073] The instruction data set construction module randomly selects a single preset question and the analysis text to form a text pair of "instruction text-analysis text"; in the text pair, the instruction text is the prompt text of the analysis text.
[0074] In this embodiment, the preset question can be selected as: "Is there any abnormal event?" or "Is there any abnormality in the video?", etc. The preset question is not limited here.
[0075] In the composed text pair, the instruction text is: "Is there any abnormal event?"
[0076] The analysis concluded: "The video shows a person holding a gun, which is abnormal because it shows a violent and potentially dangerous behavior that could result in injury to others."
[0077] Optionally, filter out erroneous and low-quality text pairs.
[0078] A set of training data in the training set is composed of instruction text, analysis text and corresponding normal or abnormal video clips.
[0079] Based on the method in the above embodiment, the embodiment of the present application provides an electronic device, such as Figure 4 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the method in the above embodiment.
[0080] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0081] Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method in the above embodiment.
[0082] Based on the method in the above embodiment, an embodiment of the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method in the above embodiment.
[0083] It is understood that the processor in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0084] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0085] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a storage medium or transmitted through the storage medium. The computer instructions may be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0086] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.
[0087] The above content is easily understood by those skilled in the art. The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A video anomaly detection model training method with analytical capabilities, It is characterized in that include: Taking the image frames and frame labels of the video clips in the training set as input and the anomaly scores of the image frames as output, training an initial video anomaly detection network to obtain a video anomaly detection network; Evaluate the anomaly score of each frame of the video clip through a video anomaly detection network, and find out the abnormal image frames whose anomaly scores are higher than a threshold; Taking the image features of the abnormal image frame and the text features of the instruction text corresponding to the video segment where the abnormal image frame is located as input, and the analysis text corresponding to the video segment where the abnormal image frame is located as output, training an initial multimodal decoding network to obtain a multimodal decoding network; The video detection network and the multimodal decoding network constitute a video anomaly detection model. The video anomaly detection model detects the video to be detected in combination with the input instruction text, and outputs abnormal video clips and corresponding analysis texts.
2. The video anomaly detection model training method according to claim 1, It is characterized in that The training set is obtained by the following method: Select videos with video-level tags; Randomly select a frame of image from the abnormal event of the abnormal video as a labeled frame; use a pre-trained video anomaly detection network to evaluate the anomaly scores of all image frames in the abnormal video, and divide the normal or abnormal video segments with frame-level labels based on the anomaly scores and the positions of the labeled frames; Generate description text based on the normal or abnormal video clip using a pre-trained video description generation network; Generate analysis text using a large language model based on whether the segment is abnormal and the corresponding description text; A set of training data in the training set is composed of preset instruction text, analysis text and corresponding normal or abnormal video clips.
3. The video anomaly detection model training method according to claim 2, It is characterized in that Based on the anomaly score and the position of the annotated frame, normal or abnormal video segments with frame-level labels are divided, specifically: Continuous adjacent frames whose anomaly scores are greater than or equal to a threshold are grouped into an abnormal segment, which includes a marked frame, and the frame labels of the continuous adjacent frames are all abnormal; continuous adjacent frames whose anomaly scores are less than a threshold are grouped into a normal segment, which includes a marked frame, and the frame labels of the continuous adjacent frames are all normal.
4. The video anomaly detection model training method according to claim 2, It is characterized in that The video description generation network is specifically a multimodal visual language large model Video-LLaVA.
5. The video anomaly detection model training method according to claim 2, It is characterized in that The large language model is specifically the large language model Llama3.
6. The video anomaly detection model training method according to claim 1, It is characterized in that The image features of the abnormal image frame are extracted through a video feature extraction network, and the video feature extraction network is specifically a video encoder of a multimodal alignment framework LanguageBind.
7. The video anomaly detection model training method according to claim 1, It is characterized in that The text features of the instruction text are extracted through a text feature extraction network, and the text feature extraction network is specifically a text encoder of the large language model Vicuna.
8. The video anomaly detection model training method according to claim 1 or 2, It is characterized in that The video anomaly detection network is specifically a video anomaly detection model UR-DMU.
9. The video anomaly detection model training method according to claim 1, It is characterized in that The multimodal decoding network is specifically a large language model Vicuna.
10. A video anomaly detection method with analytical capabilities, It is characterized in that include: Receive a video to be detected and an instruction text, and use a pre-trained video anomaly detection model combined with the instruction text to detect the video to be detected; output abnormal video clips and corresponding analysis text; wherein the video anomaly detection model is trained according to the method described in any one of claims 1-9.
Citation Information
Patent Citations
Video anomaly detection method and device, electronic equipment and storage medium
CN115802028A
Abnormal video identification method, device and equipment and computer readable storage medium
CN115909116A
Monitoring video anomaly detection method and system based on dynamic self-supervised network
CN116883896A
Real-time detection method and system for abnormal event in monitoring scene
CN118133198A
Method and apparatus for generating anomaly detection model, and anomaly event detection method and apparatus
WO2022116322A1
Cited By
Intelligent campus management system based on artificial intelligence algorithm
CN119296012A
Abnormal event video instruction data generation method and device
CN120580626A
