Accident detection and data set construction method and equipment based on multimodal large model

By combining the use of small models and multi-modal large models in traffic accident detection, the problems of poor detection accuracy and long time consumption in the existing technology are solved, efficient traffic accident detection in diverse scenarios is achieved, and detection accuracy and efficiency.

CN118334604BActive Publication Date: 2024-10-01HISENSE GRP HLDG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410749810.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-10-01
Estimated Expiration
2044-06-12

AI Technical Summary

Technical Problem

Existing traffic accident detection methods have poor detection accuracy, are time-consuming, and cannot meet the needs of a wide range of scenarios. They cannot effectively detect vehicle, bicycle, and vehicle-occupant accidents on highways and urban roads.

Method used

Using a detection method based on a multi-modal large model, the target image and adjacent images to be detected are input into the small accident detection model to obtain the target confidence. If the confidence is within the preset range, the multi-modal large model is further input. The model is detected, and the visual encoder, position-aware visual language adapter and language large model are combined to identify traffic accidents.

Benefits of technology

It improves the accuracy and efficiency of traffic accident detection, can accurately detect accident-like events in different scenarios, and is reliable and controllable. Users can adjust the importance of detection results by setting the confidence range.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334604B_ABST
    Figure CN118334604B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and in particular to accident detection and data set construction methods and devices based on multimodal large models. In an embodiment of the present application, an electronic device uses a small accident detection model to determine the target confidence that a traffic accident exists in a target image to be detected; if the target confidence belongs to a preset confidence range, it is determined that the small accident detection model cannot accurately determine whether there is a traffic accident in the target image, and the electronic device uses a multimodal large model to further detect and identify the target image. In an embodiment of the present application, through the combination of large and small models, the detection of traffic accidents is achieved, and the accuracy of accident detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to accident detection and data set construction methods and equipment based on multimodal large models. Background Art

[0002] With the development of transportation and the continuous increase in the number of motor vehicles, people's travel methods are also undergoing earth-shaking changes. Traffic safety has become a major issue of concern to people. How to quickly detect vehicle accidents, bicycle accidents, and vehicle-to-person accidents on highways and urban roads has become a problem to be solved.

[0003] At present, the main method of detecting traffic accidents is to capture accident vehicles through traffic cameras on the road, and the algorithms adopted are mainly based on detection + tracking + post-processing. However, due to the diversity of accident scenarios and different types of accidents, if we only rely on manual definition of various accidents, there will be poor detection accuracy, time-consuming and labor-intensive, and it will not be able to meet the needs of a wide range of scenarios. Summary of the invention

[0004] The present application provides an accident detection method and device based on a multimodal large model to solve the problems in the prior art of poor accident detection accuracy, long time consumption and inability to meet the needs of a wide range of scenarios.

[0005] In a first aspect, an embodiment of the present application provides an accident detection method based on a multimodal large model, the method comprising:

[0006] Inputting a target image to be detected and a preset number of other images that are adjacent to the target image in acquisition time into a small accident detection model, and obtaining a target confidence level of a traffic accident in the target image output by the small accident detection model;

[0007] If the target confidence falls within a preset confidence range, the target image is input into a multimodal large model for detecting traffic accidents to obtain a detection result of whether a traffic accident exists in the target image output by the multimodal large model.

[0008] In a second aspect, an embodiment of the present application further provides a data set construction method for fine-tuning and training any of the multimodal large models described above, the method comprising:

[0009] Inputting the sample image into the first multimodal large model, and obtaining an overall description corresponding to the sample image output by the first multimodal large model;

[0010] Inputting the sample image into the second multimodal large model, obtaining the sample image output by the second multimodal large model and marked with a detection frame corresponding to each region and a region description corresponding to each region;

[0011] Determine a target description of the sample image according to the overall description and the region description corresponding to each region;

[0012] The input accident question and answer information determined based on the target description is obtained, and the sample image and the accident question and answer information are correspondingly saved.

[0013] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor, wherein the processor is used to implement the above-mentioned accident detection method based on a multimodal large model or the steps of the above-mentioned data set construction method when executing a computer program stored in a memory.

[0014] In an embodiment of the present application, the electronic device inputs the target image to be detected and a preset number of other images adjacent to the target image acquisition time into the small accident detection model, and obtains the target confidence of the existence of a traffic accident in the target image output by the small accident detection model; if the target confidence belongs to the preset confidence range, the target image is input into the multimodal large model for detecting traffic accidents, and obtains the detection result of whether there is a traffic accident in the target image output by the multimodal large model. In an embodiment of the present application, the detection of traffic accidents is achieved through the combination of large and small models, and the accuracy of accident detection is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0016] Figure 1 A schematic diagram of an accident detection process based on a multimodal large model provided in an embodiment of the present application;

[0017] Figure 2 A schematic diagram comparing traditional convolution and dilated convolution provided in an embodiment of the present application;

[0018] Figure 3 An application flow chart of the visual encoder provided in the embodiment of the present application;

[0019] Figure 4 A schematic diagram of the data set construction process provided in the embodiment of the present application;

[0020] Figure 5 A schematic diagram of a sample image provided in an embodiment of the present application;

[0021] Figure 6 A schematic diagram of a sample image provided in an embodiment of the present application and an output through a second multimodal large model;

[0022] Figure 7 A schematic diagram of a data set construction process provided in an embodiment of the present application;

[0023] Figure 8 A flow chart of a traffic accident detection method based on size model decision-making provided in an embodiment of the present application;

[0024] Fig. 9 A schematic diagram of the structure of an accident detection device based on a multi-modal large model provided in an embodiment of the present application;

[0025] Fig.10 A schematic diagram of the structure of a data set construction device provided in an embodiment of the present application;

[0026] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0028] In order to improve the accuracy of accident detection, the embodiments of the present application provide an accident detection method and device based on a multimodal large model.

[0029] In an embodiment of the present application, a target image to be detected and a preset number of other images adjacent to the target image acquisition time are input into a small accident detection model, and the target confidence of the presence of a traffic accident in the target image output by the small accident detection model is obtained; if the target confidence belongs to a preset confidence range, the target image is input into a multimodal large model for detecting traffic accidents, and the detection result of whether a traffic accident exists in the target image output by the multimodal large model is obtained.

[0030] Figure 1 A schematic diagram of a recognition process based on a multimodal large model provided in an embodiment of the present application, the process includes:

[0031] S101: Input a target image to be detected and a preset number of other images whose acquisition time is adjacent to that of the target image into a small accident detection model, and obtain a target confidence level of a traffic accident existing in the target image output by the small accident detection model.

[0032] An embodiment of the present application provides an accident detection based on a multimodal large model applied to an electronic device, which may be a PC or a server.

[0033] In the traffic accident detection method based on the small model, the vehicle in the image is first detected, and then the position of the vehicle in the next frame of the image is predicted based on the Kalman filter algorithm. The optimal match of the target vehicle is obtained through the Hungarian matching algorithm, so as to track the vehicle. When a traffic accident occurs, the accident vehicle will stop, and then the position and status of the vehicle and whether there are people getting off the vehicle to check are combined to determine whether a traffic accident has occurred. However, due to the variety of traffic accidents and different situations, the method of target detection + tracking + business logic leads to poor accident judgment accuracy and is time-consuming and labor-intensive.

[0034] Since the multimodal large model has a strong ability to understand images, it can directly obtain whether a traffic accident has occurred in the image through command questions and answers, and the detection accuracy is relatively high. However, the multimodal large model has a large number of parameters, high resource consumption, and a long detection time, and it cannot process each frame of the image in real time.

[0035] Based on this, the embodiment of the present application proposes a method for detecting traffic accidents based on large and small models. The electronic device first uses a small model to determine the target confidence that there is a traffic accident in the target image to be detected, and then further determines whether a multimodal large model is needed for accident detection based on the target confidence.

[0036] Specifically, in an embodiment of the present application, the electronic device captures a video stream, decodes the video stream, extracts frames according to a set algorithm running frame rate, and obtains multiple images. The electronic device can determine the target image to be detected from the multiple video frames according to the input, and determine a preset number of other images adjacent to the acquisition time of the multiple video frames and the target image. The other images are used to track the target in the target image and determine the motion trajectory of the target in the target image.

[0037] The electronic device inputs the target image and a preset number of other images into a small accident detection model. The small accident detection model performs target detection on the target image, determines each target contained in the target image, determines the motion trajectory corresponding to each target based on the other images, and determines the target confidence that a traffic accident exists in the target image based on the motion estimate corresponding to each target.

[0038] In this embodiment of the present application, each target contained in the target image may be a person, a car, etc.

[0039] S102: If the target confidence falls within a preset confidence range, the target image is input into a multimodal large model for detecting traffic accidents, and a detection result of whether a traffic accident exists in the target image output by the multimodal large model is obtained.

[0040] In an embodiment of the present application, the electronic device can determine whether there is a traffic accident in the target image according to the target confidence output by the accident detection model. Specifically, the electronic device stores a confidence range, and if the electronic device determines that the target confidence is less than the minimum value of the confidence range, the electronic device determines that there is no traffic accident in the target image, and if the electronic device determines that the target confidence is greater than the maximum value of the confidence range, the electronic device determines that there is a traffic accident in the target image.

[0041] Furthermore, if the electronic device determines that the target confidence output by the accident detection small model falls within the preset confidence range, the electronic device determines that the accident detection small model cannot accurately identify whether there is a traffic accident in the target image. Based on this, the electronic device further detects the target image using the multimodal large model for detecting traffic accidents.

[0042] Specifically, in an embodiment of the present application, if the electronic device determines that the target confidence output by the accident detection small model belongs to a preset confidence range, the electronic device inputs the target image into a multimodal large model for detecting traffic accidents, and the multimodal large model recognizes the target image to determine whether there is a traffic accident in the target image, and the multimodal large model outputs a detection result of whether there is a traffic accident in the target image. The electronic device obtains the detection result output by the multimodal large model.

[0043] In an embodiment of the present application, the electronic device inputs the target image to be detected and a preset number of other images adjacent to the target image acquisition time into the small accident detection model, and obtains the target confidence of the existence of a traffic accident in the target image output by the small accident detection model; if the target confidence belongs to the preset confidence range, the target image is input into the multimodal large model for detecting traffic accidents, and the detection result of whether there is a traffic accident in the target image output by the multimodal large model is obtained. In an embodiment of the present application, the detection of traffic accidents is realized by combining large and small models, and the accuracy of traffic accident detection is improved.

[0044] In the embodiment of the present application, for pictures of the same traffic accident scene, accident-type events can still be detected even in different operating environments, which meets the characteristic of reproducibility in the trustworthy characteristic; and, the embodiment of the present application can determine the degree of accident detection by allowing the user to set hyperparameters (confidence range), and the degree of importance and adoption of the event detection results can be intervened by the user, which meets the characteristic of controllability in the trustworthy characteristic. In addition to having the above two trustworthy characteristics, the embodiment of the present application can greatly improve the detection efficiency and accuracy of traffic accident events.

[0045] In order to realize the detection of traffic accidents and improve the accuracy of traffic accident detection, based on the above embodiments, in the embodiments of the present application, the multimodal large model includes a visual encoder, a position-aware visual language adapter and a language large model;

[0046] Acquiring a detection result of whether a traffic accident exists in the target image output by the multimodal large model includes:

[0047] The visual encoder encodes the target image to determine a feature code corresponding to the target image;

[0048] The position-aware visual language adapter compresses the feature code to determine a compressed feature code;

[0049] The language large model determines and outputs a detection result of whether a traffic accident exists in the target image based on the compressed feature coding.

[0050] In the embodiment of the present application, the multimodal large model includes a visual encoder, a position-aware visual language adapter and a language large model. The visual encoder is used to crop the input target image and perform feature encoding, the position-aware visual language adapter is used to align features and compress the feature encoding output by the visual encoder, and the language large model is used to output the detection result of whether there is a traffic accident in the target image based on the compressed feature encoding.

[0051] For example, the multimodal large model can be the Qwen-VL model, which is a Transformer-based multimodal large model, and its network structure consists of three parts: the first part is the visual encoder, which uses VIT-bigG as the initialization of the pre-trained weights, and is used to crop the input image and perform feature encoding; the second part is the feature alignment module called the position-aware visual language adapter, which includes a single-layer cross-attention module, and is mainly used to encode compressed image features; the third part is the language large model, which uses Qwen-7b as the initialization of the model with pre-trained weights to provide language generation capabilities for the multimodal large model.

[0052] In order to realize the detection of traffic accidents and improve the accuracy of traffic accident detection, on the basis of the above embodiments, in the embodiment of the present application, the visual encoder includes a convolution layer, a linear projection layer and a Transformer layer;

[0053] The encoding of the target image and determining the feature code corresponding to the target image comprises:

[0054] The convolution layer uses a dilated convolution to extract features from the target image, determine a feature map corresponding to the target image, and segment the feature map to obtain each sub-feature map; wherein the parameters of the dilated convolution are the parameters learned during the model training process;

[0055] The linear projection layer sorts each of the sub-feature maps according to the segmentation order of the feature map, and linearly encodes each of the sorted sub-feature maps to determine the image features corresponding to the feature map;

[0056] The Transformer layer extracts features from the image and determines the feature encoding.

[0057] In the embodiment of the present application, the visual encoder includes a convolution layer, a linear projection layer and a Transformer layer. The traditional convolution layer uses the traditional convolution method to extract features from the input image, and then divides the image into local small images. This method only performs simple segmentation at a single image level, and the image is rich in features and the details of targets at different locations are also different. Therefore, this simple segmentation method will split the location information in the image.

[0058] Based on this, in an embodiment of the present application, a dilated convolution is used to extract features of a target image. Since the dilated convolution can increase the receptive field of an image, more image features can be input into the linear projection layer.

[0059] Figure 2 A comparison diagram of the traditional convolution and the dilated convolution provided in the embodiment of the present application is shown in the figure. Figure 2 As shown, the gray part in a is a normal convolution kernel, and b and c are hole convolutions. It can be seen that different holes obtain different image features, among which a obtains the least image features, b obtains the second most image features, and c obtains the most image features.

[0060] In the embodiment of the present application, the parameter of the dilated convolution is the dilated value of the dilated convolution. The traditional method of determining the dilated value is to manually set the dilated value d to different probabilities, such as the probability of d equal to 1 is 0.24, and the probability of d equal to 2 is 0.17. As d increases, the probability gradually decreases, but the manual method of determining the size of d contains certain subjective factors and often cannot optimize the model well. Based on this, in the embodiment of the present application, it is proposed to set the dilated value of the dilated convolution to a learnable parameter, so that the network model can automatically correct the size of the dilated value based on the error loss function and the optimizer.

[0061] Among them, the cross entropy loss function is as follows:

[0062]

[0063] Among them, y is the real detection result of the sample image, and p is the predicted detection result.

[0064] The Adam optimizer is as follows:

[0065]

[0066] in, is the first-order momentum, is the second-order momentum, and Optimized for average value, is the weight update.

[0067] Based on this, in the embodiment of the present application, after the visual encoder training is completed, in the actual application process, the convolution layer of the visual encoder uses a hole convolution to extract features from the target image, determine the feature map corresponding to the target image, and divide the feature map to obtain each sub-feature map; wherein the parameter of the hole convolution is the hole value, which is learned during the model training process. The linear projection layer of the visual encoder sorts each sub-feature map according to the segmentation order of the feature map, and linearly encodes each sorted sub-feature map to determine the image features corresponding to the feature map; the Transformer layer of the visual encoder extracts features from the image features and determines feature coding.

[0068] Figure 3 The application flow chart of the visual encoder provided in the embodiment of the present application is as follows: Figure 3 As shown, the process includes:

[0069] Step 1: Input the target image, which is a 1920×1080, 3-channel color image, and initialize the hole value d of the hole convolution.

[0070] Step 2: Perform a dilated convolution operation on the target image to obtain a feature map of size 224×224. Divide the length and width of the feature image by 16 respectively to form 196 image blocks of size 16×16. The dimension of each image block is 768. Arrange the image blocks into a sequence and input them into the linear projection layer to obtain the features of a single image block.

[0071] Step 3: Take the * sign as the category symbol, which is a learnable tensor of size 1×68. At the same time, add a learnable position code of size 1×768. Add the position code and linearly encoded image features bit by bit, concatenate them with the category symbol, and input them into the Transformer layer.

[0072] Step 4: The Transformer layer is composed of multiple encoding layers, each of which is composed of a multi-head attention layer and a multi-layer perceptron, with a total of L encoding layers. The data of 197×768 dimensions obtained in step 3 is normalized and input into the multi-head attention layer for calculation, and the result is still a feature code of 197×768. The obtained 197×768 feature code is normalized and input into the multi-layer perceptron layer. First, the input feature code is enlarged by 4 times to 197×3072, and then it is passed through the linear projection layer to obtain a feature code of 197×768 dimensions and output.

[0073] In order to realize the detection of traffic accidents and improve the accuracy of traffic accident detection, on the basis of the above embodiments, in the embodiment of the present application, the accident detection sub-model includes a target detection sub-model, a target tracking sub-model and an accident detection sub-model;

[0074] Obtaining the target confidence that a traffic accident exists in the target image output by the accident detection mini-model includes:

[0075] The target detection sub-model performs target detection on the target image and the other images respectively, determines each target contained in the target image and the other images, and marks each target in the target image and the other images; wherein the target is a vehicle or a pedestrian;

[0076] The target tracking sub-model determines the motion trajectory of each target according to the labeled target image and other images;

[0077] The accident detection sub-model performs accident detection according to the motion trajectory of each target, and determines and outputs the target confidence level of the traffic accident in the target image.

[0078] In the embodiment of the present application, the accident detection model is obtained by integrating multiple sub-models, and the accident detection model includes at least a target detection sub-model, a target tracking sub-model and an accident detection sub-model. Among them, the target detection sub-model is used to identify each target contained in the target image and other images, the target tracking sub-model is used to determine the motion trajectory of each target, and the accident detection sub-model is used to determine the target confidence of the traffic accident in the target image based on the motion trajectory.

[0079] Specifically, in the embodiment of the present application, the target detection submodel performs target detection on the target image and other images respectively, determines each target contained in the target image and other images, and marks each target in the target image and other images. The target tracking submodel determines the motion trajectory of each target based on the marked target image and other images. The accident detection submodel performs accident detection based on the motion trajectory of each target, determines and outputs the target confidence level of the traffic accident in the target image.

[0080] Among them, the target detection sub-model can be a model using the Yolov5s algorithm, and the target tracking sub-model can be a model using the DeepSort tracking algorithm.

[0081] In an embodiment of the present application, the accident detection sub-model can determine the target confidence level of a traffic accident in a target image according to the following conditions:

[0082] Condition 1: There is an occlusion relationship between the vehicles in parallel, and the occlusion duration exceeds the time threshold of 3 minutes;

[0083] Condition 2: The following vehicle is blocked and does not move for more than 120 seconds;

[0084] Condition 3: The following vehicle goes around from the rear and goes around slowly;

[0085] Condition 4: The doors of the two accident vehicles are opened and people get out;

[0086] Condition 5: Personnel stand around the vehicle for more than 60 seconds.

[0087] The confidence level corresponding to each of the above conditions is 0.2. The accident detection sub-model determines the number of conditions satisfied by the target image according to the motion trajectory of each target, and determines the target confidence level of the existence of a traffic accident in the target image according to the number of conditions and the confidence level corresponding to each condition.

[0088] In order to realize the detection of traffic accidents and improve the accuracy of traffic accident detection, on the basis of the above embodiments, in the embodiment of the present application, the method further includes:

[0089] If the target confidence exceeds the maximum value of the confidence range, it is determined that a traffic accident exists in the target image, and an accident alarm is issued;

[0090] If the target confidence is less than the minimum value of the confidence range, it is determined that there is no traffic accident in the target image and no accident alarm is issued.

[0091] In an embodiment of the present application, a confidence range is pre-saved in the electronic device. If the confidence output by the accident detection small model falls within the confidence range, the electronic device determines that the small model cannot accurately identify whether a traffic accident exists in the target image. The electronic device inputs the target image into the multimodal large model for further prediction.

[0092] On this basis, if the target confidence output by the accident detection small model exceeds the maximum value of the confidence range, the electronic device determines that there is a traffic accident in the target image, and the electronic device issues an accident alarm; if the target confidence output by the accident detection small model is less than the minimum value of the confidence range, the electronic device determines that there is no traffic accident in the target image, and the electronic device does not issue an accident alarm.

[0093] Generally, the confidence range can be 0.3-0.7. If the confidence is greater than 0.7, it can be directly judged that a traffic accident has occurred. If the confidence is greater than 0.3 and less than 0.7, the target image is input into the multimodal large model for decision-making. If the confidence is less than 0.3, it is considered that no traffic accident has occurred.

[0094] In order to achieve traffic accident detection and improve the accuracy of traffic accident detection, based on the above embodiments, the embodiments of the present application also provide a data set construction method for training the multimodal large model in the above embodiments. Figure 4 A schematic diagram of a data set construction process provided in an embodiment of the present application, the process comprising:

[0095] S401: Input a sample image into a first multimodal large model, and obtain an overall description corresponding to the sample image output by the first multimodal large model.

[0096] A data set construction method provided in an embodiment of the present application is applied to an electronic device, which may be a PC or a server.

[0097] In the related art, the construction of data sets mainly adopts two methods: manual labeling and large model labeling. Among them, manual labeling is to give answers manually, but since the types of traffic accidents are diverse and cannot be exhaustive, and when multiple workers perform labeling, due to different understandings of accidents in images, the given descriptions are less consistent. Therefore, manual labeling has the disadvantages of being time-consuming and labor-intensive, and poor labeling consistency; data labeling based on large models directly relies on large models such as GPT4 to give answers. When using data produced in this way for fine-tuning training, the model to be fine-tuned cannot understand why a traffic accident occurred.

[0098] Based on this, in order to better annotate images, obtain a more accurately annotated data set, and fine-tune the multimodal large model used for accident detection based on the data set, in an embodiment of the present application, the multimodal large model's ability to understand images is combined with the detection of the small model to annotate multiple images from multiple levels, generate descriptions with a consistent expression style, and introduce the thinking chain into data annotation. Through step-by-step prompts and answers, the large model understands human intentions, and finally performs manual verification or sampling detection.

[0099] Specifically, in an embodiment of the present application, the electronic device inputs the sample image into the first multimodal large model, so that the first multimodal large model recognizes the sample image as a whole and outputs an overall description. The electronic device obtains the overall description corresponding to the sample image output by the first multimodal large model.

[0100] Figure 5 A sample image schematic diagram provided in an embodiment of the present application, such as the Figure 5 As shown, the electronic device inputs the sample image into the first multimodal large model, and the overall description output by the first multimodal large model is "many vehicle forms on the roads in the city."

[0101] S402: Input the sample image into the second multimodal large model, and obtain the sample image output by the second multimodal large model, which is marked with a detection box corresponding to each region and a region description corresponding to each region.

[0102] In an embodiment of the present application, the electronic device inputs a sample image into a second multimodal large model, and the second multimodal large model detects each region in the sample image and generates a corresponding region description for each region.

[0103] Among them, in an embodiment of the present application, the second multimodal large model can automatically identify the areas in the sample image, and each area in the sample image can be identified and marked by the small model, and then the marked sample image is input into the second multimodal large model, and the second multimodal large model outputs the area description corresponding to each area.

[0104] Figure 6 A schematic diagram of a sample image provided in an embodiment of the present application and an output of the second multimodal large model, such as the Figure 6 As shown, after the sample image is input into the second multimodal large model, the second multimodal large model determines each region contained in the sample image and the region description corresponding to each region and marks it in the sample image. The region description includes: "the car is white", "a man is walking on the road", "a silver car is parked on the road" and "a person is standing on the road", and the positions of the region boxes are: [806,599,961,796], [759,644,828,848], [872,762,1242,1032] and [1089,867,1182,1121].

[0105] S403: Determine the target description of the sample image according to the overall description and the area description corresponding to each area; obtain input accident question and answer information determined based on the target description, and save the sample image and the accident question and answer information in correspondence.

[0106] In an embodiment of the present application, the electronic device determines a target description of the sample image based on an overall description of the sample image, a sample image of a detection box corresponding to each region marked in the sample image, and a region description corresponding to each region.

[0107] In the embodiment of the present application, the electronic device can determine the target description corresponding to the sample image through the language model. Specifically, the electronic device inputs the overall description, the regional description corresponding to each region, and the prompt words used to prompt the large model to generate a detailed description based on the overall description and the regional description into the language model. The language model comprehensively considers the overall description and the regional description corresponding to each region, and generates and outputs the target description for the sample image.

[0108] In an embodiment of the present application, after the electronic device determines the target description of the sample image, the electronic device displays the target description, and the technician determines the accident question and answer information based on the target description in the form of a thought chain according to the target description, and saves the sample image and the accident question and answer information correspondingly.

[0109] In the above Figure 6 Based on the information provided by the electronic device, the accident question and answer information obtained is:

[0110] 1. Is there any damage to the vehicle?

[0111] Answer: The silver-white sedan and the gray van in the picture are close to each other, but no obvious damage is seen.

[0112] 2. Is there anyone lying on the ground?

[0113] Answer: No one was seen falling to the ground.

[0114] 3. Are there any drivers or passengers getting off the bus?

[0115] Answer: In the picture, there are two people looking around the vehicle, apparently observing the damage to the vehicle.

[0116] 4. Analyze whether there is a traffic accident in the image based on the description.

[0117] Answer: Because there were two vehicles close to each other on the snow-covered road, and there were people checking around the vehicles, and other vehicles on the road tended to avoid the vehicle, it is considered that there was a traffic accident.

[0118] In addition, in an embodiment of the present application, for a data set containing labeled sample images, some sample images and corresponding target descriptions are checked by manual verification or random sampling to determine the accuracy of the verification. If the accuracy meets the preset requirements, the data set is used to perform fine-tuning training on the multimodal large model. If the accuracy does not meet the preset requirements, the sample images are re-annotated.

[0119] On this basis, the electronic device can also check some sample images and corresponding descriptions through manual verification or random sampling. If the sampled target description is inconsistent with the content in the corresponding sample image, the sample image will be re-annotated.

[0120] In an embodiment of the present application, multiple images are annotated from multiple levels based on multi-scale feature fusion, thought chain and instruction labeling to generate a description with a consistent expression style, and the thought chain is introduced into the data labeling. Through step-by-step prompts and answers, the multimodal large model can understand human intentions.

[0121] In order to improve the accuracy of the annotation of the data set, on the basis of the above embodiments, in the embodiment of the present application, before determining the target description of the sample image according to the overall description and the region description corresponding to each region, the method further includes:

[0122] Inputting the sample image marked with the detection frame corresponding to each region and the region description corresponding to each region into the first multimodal large model, and obtaining a similarity score between each region output by the first multimodal large model and the corresponding region description;

[0123] Delete regions and their corresponding region descriptions whose similarity scores are lower than a preset threshold.

[0124] In an embodiment of the present application, the electronic device may also filter the region description corresponding to each determined region through the first multimodal large model, and eliminate region descriptions with low matching degrees.

[0125] Specifically, the electronic device inputs the sample image marked with a detection box corresponding to each area and the area description corresponding to each area into the first multimodal large model, obtains the similarity score between each area output by the first multimodal large model and the corresponding area description, and deletes the areas and corresponding area descriptions whose similarity scores are lower than a preset threshold.

[0126] exist Figure 6 Based on the first multimodal large model, the similarity score of the regional description "the car is white" is 0.95, the similarity score of the regional description "a man walking on the road" is 0.7, the similarity score of the regional description "a silver car parked on the road" is 0.8, and the similarity score of the regional description "a person standing on the road" is 0.4. The preset threshold saved in the electronic device is 0.6, so the electronic device deletes the regional description "a person standing on the road".

[0127] In order to improve the accuracy of the annotation of the data set, on the basis of the above embodiments, in the embodiment of the present application, the determining of the target description of the sample image according to the overall description and the region description corresponding to each region includes:

[0128] The overall description and the region description corresponding to each region are input into a large language model to obtain a target description of the sample image output by the large language model.

[0129] In an embodiment of the present application, the electronic device can determine the target description corresponding to the sample image through the language model. Specifically, the electronic device inputs the overall description, the regional description corresponding to each region, and the prompt words used to prompt the large model to generate a detailed description based on the overall description and the regional description into the language model, and the language model comprehensively considers the overall description and the regional description corresponding to each region, and generates and outputs the target description for the sample image.

[0130] In order to improve the accuracy of data set annotation, on the basis of the above embodiments, in an embodiment of the present application, the first multimodal large model is a BLIP2 model, the second multimodal large model is a GRIP model, and the language large model is a GPT-3.5 model.

[0131] In an embodiment of the present application, the first multimodal large model is a BLIP2 model, the second multimodal large model is a GRIP model, and the language large model is a GPT-3.5 model.

[0132] Based on the above embodiments, Figure 7 A schematic diagram of a data set construction process provided in an embodiment of the present application, such as the Figure 7 As shown, the process includes:

[0133] Step 1: For a traffic accident image, use the multimodal large model BLIP2 to perform a global image description on the entire image to obtain an overall description. For example: many vehicles are driving on the roads in the city.

[0134] Step 2: Use the multimodal large model GRIP to detect each region in the image, and perform a regional image description on each region to obtain a regional description. For example, the regional description includes: "the car is white", "a man is walking on the road", "a silver car is parked on the road" and "a person is standing on the road", and the positions of the regional boxes are: [806,599,961,796], [759,644,828,848], [872,762,1242,1032] and [1089,867,1182,1121].

[0135] Step 3: Use BLIP2 to calculate the matching degree of the region box and region description in step 2 to obtain the similarity score. By manually setting the score threshold, remove the detection boxes and region descriptions with low confidence.

[0136] For example, the retained area descriptions are “the car is white” and “a man is walking on the road”.

[0137] Step 4: Use GPT-3.5 to comprehensively consider the overall description in step 1, the filtered detection box images in steps 2 and 3, and the corresponding descriptions to generate a detailed image description (target description) and a thought chain image question and answer (accident question and answer information) for the entire image.

[0138] For example, the target description is "a two-way urban road covered with snow. On one lane, two vehicles had a rear-end collision and someone was observing around the accident vehicles."

[0139] Step 5: After step 4, the GPT-3.5 model has understood the meaning of the scene in the image, and then constructs an instruction dataset in the form of a thought chain, including the detailed description of the image in steps 1-4, and the accident question and answer information, such as the surrounding environment, the location of the vehicle, the condition between vehicles, the damage to the vehicle, the road congestion, the driver's condition and everything you see, based on these contents, answer the following questions:

[0140] 1. Is there any damage to the vehicle?

[0141] Answer: The silver-white sedan and the gray van in the picture are close to each other, but no obvious damage is seen.

[0142] 2. Is anyone down?

[0143] Answer: No one was seen falling to the ground.

[0144] 3. Are there any drivers or passengers getting off the bus?

[0145] Answer: In the picture, there are two people looking around the vehicle, apparently observing the damage to the vehicle.

[0146] 4: Analyze whether there is a traffic accident in the image based on the description?

[0147] Answer: Since there were two vehicles close to each other on the snow-covered road, and there were people checking around the vehicles, and other vehicles on the road tended to avoid the vehicle, it is considered that there was a traffic accident.

[0148] Step 6: For the labeled data set, check some sample images and corresponding target descriptions in the data set through manual verification or random sampling. If the labeled target description matches the content in the sample image, the sample image will be used for subsequent multimodal large model fine-tuning training. If it does not meet the requirements, return to step 5 for re-annotation.

[0149] Based on the above embodiments, Figure 8 A flow chart of a traffic accident detection method for size model decision-making provided in an embodiment of the present application, the process includes:

[0150] Step 1: Get the video stream, decode the video stream, extract frames according to the set algorithm frame rate, and determine the target image and other images.

[0151] Step 2: Input the target image and other images into the small model of traffic accident detection, where Yolov5s performs target detection and DeepSort performs target tracking. Based on the traffic accident judgment basis, the target confidence of the traffic accident in the target image is determined.

[0152] If the target confidence exceeds the maximum value of the confidence range, it is determined that there is a traffic accident in the target image and a traffic accident alarm is issued; if the target confidence is less than the minimum value of the confidence range, it is determined that there is no accident in the target image and no accident alarm is issued.

[0153] Step 3: If the target confidence falls within the preset confidence range, it is uncertain whether there is traffic data in the target image. The electronic device inputs the target image into the fine-tuned multimodal large model, and prompts with pre-made questions, such as: whether a traffic accident has occurred in the image, and answers with "yes" or "no". The large model reasoned based on the image and prompts, and finally gave an answer, such as: yes, a traffic accident has occurred in the image or no, no traffic accident has occurred in the image.

[0154] Step 4: If the multimodal large model detects a traffic accident, an alarm event is output; if the multimodal large model does not detect a traffic accident, step 2 is repeated to continue traffic accident monitoring.

[0155] Step 5: Use multi-instruction datasets to optimize the model structure and obtain a fine-tuned multimodal large model.

[0156] Based on the above embodiments, Fig. 9 A schematic diagram of the structure of an accident detection device based on a multimodal large model provided in an embodiment of the present application, the device comprises:

[0157] A small model detection module 901 is used to input a target image to be detected and a preset number of other images that are adjacent to the target image in acquisition time into an accident detection small model, and obtain a target confidence level of a traffic accident in the target image output by the accident detection small model;

[0158] The large model detection module 902 is used to input the target image into the multimodal large model for detecting traffic accidents if the target confidence falls within a preset confidence range, and obtain a detection result of whether a traffic accident exists in the target image output by the multimodal large model.

[0159] In one possible implementation, the multimodal large model includes a visual encoder, a position-aware visual-language adapter, and a language large model;

[0160] The large model detection module 902 is specifically used for the visual encoder to encode the target image and determine the feature code corresponding to the target image; the position-aware visual language adapter compresses the feature code and determines the compressed feature code; the language large model determines and outputs the detection result of whether there is a traffic accident in the target image based on the compressed feature code.

[0161] In a possible implementation, the visual encoder includes a convolutional layer, a linear projection layer, and a Transformer layer;

[0162] The large model detection module 902 is specifically used for the convolution layer to use hole convolution to extract features from the target image, determine the feature map corresponding to the target image, and segment the feature map to obtain each sub-feature map; wherein the parameters of the hole convolution are the parameters learned during the model training process; the linear projection layer sorts each sub-feature map according to the segmentation order of the feature map, and linearly encodes each sorted sub-feature map to determine the image features corresponding to the feature map; the Transformer layer extracts features from the image features and determines the feature encoding.

[0163] In a possible implementation, the accident detection sub-model includes a target detection sub-model, a target tracking sub-model and an accident detection sub-model;

[0164] The small model detection module 901 is specifically used for the target detection submodel to perform target detection on the target image and the other images respectively, determine each target contained in the target image and the other images, and mark each target in the target image and the other images; wherein the target is a vehicle or a pedestrian; the target tracking submodel determines the motion trajectory of each target based on the marked target image and other images; the accident detection submodel performs accident detection based on the motion trajectory of each target, determines and outputs the target confidence of the presence of a traffic accident in the target image.

[0165] In a possible implementation, the small model detection module 901 is also used to determine that there is a traffic accident in the target image and issue an accident alarm if the target confidence exceeds the maximum value of the confidence range; if the target confidence is less than the minimum value of the confidence range, determine that there is no traffic accident in the target image and do not issue an accident alarm.

[0166] Based on the above embodiments, Fig.10 A schematic diagram of a data set construction device provided in an embodiment of the present application, the device comprising:

[0167] The processing module 1001 is used to input the sample image into the first multimodal large model, and obtain the overall description corresponding to the sample image output by the first multimodal large model; input the sample image into the second multimodal large model, and obtain the sample image output by the second multimodal large model with the detection frame corresponding to each region and the region description corresponding to each region; determine the target description of the sample image according to the overall description and the region description corresponding to each region;

[0168] The construction module 1002 is used to obtain the input accident question and answer information determined based on the target description, and store the sample image and the accident question and answer information in correspondence.

[0169] In a possible implementation, the processing module 1001 is further used to input the sample image marked with a detection box corresponding to each region and the region description corresponding to each region into the first multimodal large model, obtain a similarity score between each region output by the first multimodal large model and the corresponding region description; and delete regions and corresponding region descriptions whose similarity scores are lower than a preset threshold.

[0170] In a possible implementation, the processing module 1001 is specifically used to input the sample image marked with a detection box corresponding to each area, the overall description and the area description corresponding to each area into a large language model, and obtain the target description of the sample image output by the large language model.

[0171] In a possible implementation, the first multimodal large model is a BLIP2 model, the second multimodal large model is a GRIP model, and the language large model is a GPT-3.5 model.

[0172] Based on the above embodiments, the present application also provides an electronic device, Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig.11 As shown, it includes: a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, wherein the processor 1101, the communication interface 1102, and the memory 1103 communicate with each other through the communication bus 1104;

[0173] The memory 1103 stores a computer program. When the program is executed by the processor 1101, the processor 1101 executes the steps of the interface generation method provided in the above embodiments.

[0174] Since the principle of solving the problem by the above electronic device is similar to the accident detection method or data set construction method based on a multimodal large model, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.

Claims

1. An accident detection method based on a multimodal large model, characterized in that: The method comprises: The target image to be detected and a preset number of other images adjacent to the target image acquisition time are input into the accident detection sub-model, the accident detection sub-model determines the motion trajectory corresponding to each target, and according to the motion trajectory, determines and outputs the target confidence that a traffic accident exists in the target image, and obtains the target confidence that a traffic accident exists in the target image output by the accident detection sub-model; wherein the accident detection sub-model includes at least a target detection sub-model, a target tracking sub-model and an accident detection sub-model; If the target confidence falls within a preset confidence range, the target image is input into a multimodal large model for detecting traffic accidents, and a detection result of whether a traffic accident exists in the target image output by the multimodal large model is obtained; The multimodal large model is fine-tuned based on a pre-configured data set, and the data set construction process includes: Inputting the sample image into the first multimodal large model, and obtaining an overall description corresponding to the sample image output by the first multimodal large model; Inputting the sample image into the second multimodal large model, obtaining the sample image output by the second multimodal large model and marked with a detection frame corresponding to each region and a region description corresponding to each region; Determine a target description of the sample image according to the overall description and the region description corresponding to each region; Obtaining input accident question and answer information determined based on the target description, and saving the sample image and the accident question and answer information in correspondence; Wherein, determining the target description of the sample image according to the overall description and the region description corresponding to each region includes: A sample image marked with a detection box corresponding to each area, the overall description and the area description corresponding to each area are input into the language model to obtain the target description of the sample image output by the language model.

2. The method according to claim 1, characterized in that: The multimodal large model includes a visual encoder, a position-aware visual-language adapter, and a language large model; Acquiring a detection result of whether a traffic accident exists in the target image output by the multimodal large model includes: The visual encoder encodes the target image to determine a feature code corresponding to the target image; The position-aware visual language adapter compresses the feature code to determine a compressed feature code; The language large model determines and outputs a detection result of whether a traffic accident exists in the target image based on the compressed feature coding.

3. The method according to claim 2, characterized in that The visual encoder includes a convolutional layer, a linear projection layer and a Transformer layer; The encoding of the target image and determining the feature code corresponding to the target image comprises: The convolution layer uses a dilated convolution to extract features from the target image, determine a feature map corresponding to the target image, and segment the feature map to obtain each sub-feature map; wherein the parameters of the dilated convolution are the parameters learned during the model training process; The linear projection layer sorts each of the sub-feature maps according to the segmentation order of the feature map, and linearly encodes each of the sorted sub-feature maps to determine the image features corresponding to the feature map; The Transformer layer extracts features from the image and determines the feature encoding.

4. The method according to claim 1, characterized in that: The accident detection sub-model includes a target detection sub-model, a target tracking sub-model and an accident detection sub-model; Obtaining the target confidence that a traffic accident exists in the target image output by the accident detection mini-model includes: The target detection sub-model performs target detection on the target image and the other images respectively, determines each target contained in the target image and the other images, and marks each target in the target image and the other images; wherein each target is a vehicle or a pedestrian; The target tracking sub-model determines the motion trajectory of each target according to the labeled target image and other images; The accident detection sub-model performs accident detection according to the motion trajectory of each target, and determines and outputs the target confidence level of the traffic accident in the target image.

5. The method according to claim 1, characterized in that: The method further comprises: If the target confidence exceeds the maximum value of the confidence range, it is determined that a traffic accident exists in the target image, and an accident alarm is issued; If the target confidence is less than the minimum value of the confidence range, it is determined that there is no traffic accident in the target image and no accident alarm is issued.

6. The method according to claim 1, characterized in that Before determining the target description of the sample image according to the overall description and the region description corresponding to each region, the method further includes: Inputting the sample image marked with the detection frame corresponding to each region and the region description corresponding to each region into the first multimodal large model, and obtaining a similarity score between each region output by the first multimodal large model and the corresponding region description; Delete regions and their corresponding region descriptions whose similarity scores are lower than a preset threshold.

7. The method according to claim 1, characterized in that The first multimodal large model is a BLIP2 model, the second multimodal large model is a GRIP model, and the language large model is a GPT-3.5 model.

8. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to implement the steps of the accident detection method based on the multimodal large model as claimed in any one of claims 1 to 7 when executing the computer program stored in the memory.