Smoke and fire detection method and system
Through the improved YOLO model combined with the contrastive language-image pre-training model and multi-layer perceptron, the problem of high false alarm rate of fireworks detection in high-altitude observation scenes is solved, achieving high-precision fireworks identification and reducing false alarms, and improving the efficiency of supervisors. work efficiency, providing more effective fire safety guarantee.
Patent Information
- Application Number
- CN202410689776.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-03
AI Technical Summary
Existing fireworks detection technology is prone to false alarms in high-altitude observation scenarios, and the false alarm rate is high, resulting in supervisor fatigue and low work efficiency. Moreover, traditional visual algorithms have poor detection effects and are difficult to accurately identify smoke and fire.
Using the improved YOLO model, combined with the contrastive language-image pre-training model and multi-layer perceptron, a training sample set is constructed by matching preset fireworks detection prompt phrases with image data. The trained model can more accurately identify fireworks and automatically Adaptation mechanisms and filtering mechanisms reduce false positives.
It significantly improves the accuracy of fire and fire identification, reduces the false alarm rate, improves the work efficiency of supervisors, and provides more effective fire safety protection.
Smart Images

Figure CN118587650A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a smoke and fire detection method and system. Background Art
[0002] In order to prevent and resolve fire safety risks and improve the ability to respond to and deal with disasters and accidents, we are currently increasing investment in the supervision of high-altitude lookout cameras to prevent problems before they occur. We use monitoring to view the situation in each area in real time and analyze possible smoke or fire warnings. This will provide real-time warnings and timely dispatch of police, which can reduce the difficulty of firefighting work to a certain extent.
[0003] Most existing technical solutions involve manually checking surveillance or video data, which has a slow response speed and is only pursued after the fact, making it extremely inefficient. Alternatively, traditional visual algorithm models are used for detection. Although this can improve monitoring efficiency to a certain extent, the detection effect of traditional models is poor, and many false alarms will occur, which invisibly increases the workload of handling. In addition, too many false alarms will cause the handling staff to gradually become lazy and may miss the real alarms that appear in the false alarms.
[0004] Therefore, there is an urgent need for a smoke and fire detection method and system to solve the above problems. Summary of the invention
[0005] In view of the problems existing in the prior art, the present invention provides a smoke and fire detection method and system.
[0006] The present invention provides a method for detecting smoke and fire, comprising:
[0007] Acquire business image data of the scene to be detected;
[0008] The business image data is input into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, wherein the fireworks detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by a contrastive language-image pre-training model and a multi-layer perceptron.
[0009] According to a method for detecting fireworks provided by the present invention, the fireworks detection model is trained by the following steps:
[0010] Obtain sample image data corresponding to each scene;
[0011] Constructing a preset fire and smoke detection prompt phrase, wherein the preset fire and smoke detection prompt phrase includes a smoke detection prompt phrase and a fire detection prompt phrase;
[0012] According to the fireworks history information in the sample image data, the sample image data is matched with the corresponding smoke detection prompt phrase and the fire detection prompt phrase to obtain a text prompt phrase and image data pair;
[0013] A training sample set is constructed according to the text prompt phrase and the image data pair, and the improved YOLO model is trained by using the training sample set to obtain the fireworks detection model.
[0014] According to a method for detecting fireworks provided by the present invention, the output layer of the improved YOLO model includes the contrastive language-image pre-training model and the multi-layer perceptron, wherein the input end of the contrastive language-image pre-training model is connected to the front layer of the improved YOLO model, and the front layer is used to output the corresponding center point to be detected according to the business image data; and the output end of the contrastive language-image pre-training model is connected to the multi-layer perceptron.
[0015] According to a method for detecting fireworks provided by the present invention, an adaptive mechanism is provided between the input end of the contrastive language-image pre-training model and the front layer, and the adaptive mechanism is used to enlarge the detection frame corresponding to the center point to be detected according to the size information of the preset fireworks detection frame, obtain the enlarged detection frame, and input the enlarged detection frame to the input end of the contrastive language-image pre-training model, wherein the formula of the adaptive mechanism is:
[0016] p=-0.00019(h*w)+5.3, if 1600<h*w<20000;
[0017] p=1.5,if h*w>20000;
[0018] Among them, p represents the magnification coefficient of the detection frame, h represents the length information of the preset fireworks detection frame, and w represents the width information of the preset fireworks detection frame.
[0019] According to a method for detecting fireworks provided by the present invention, after inputting the service image data into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, the method further includes:
[0020] Obtaining a plurality of fireworks detection results within a preset time period;
[0021] A smoke and fire detection frame between adjacent frames in the plurality of smoke and fire detection results is judged, and a target smoke and fire detection result is determined from the plurality of smoke and fire detection results according to the judgment result.
[0022] According to a method for detecting fireworks provided by the present invention, judging the fireworks detection frames between adjacent frames in a plurality of fireworks detection results, and determining a target fireworks detection result from the plurality of fireworks detection results according to the judgment result, comprises:
[0023] Determine whether the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result; if not, use the current frame fireworks detection result as the target fireworks detection result;
[0024] If the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result, when it is determined that the number of fireworks detection frames corresponding to the current frame fireworks detection result and the previous frame fireworks detection result are both 1, the overlap of the fireworks detection frames between the current frame fireworks detection result and the previous frame fireworks detection result is calculated; if the overlap is greater than or equal to a preset overlap threshold, the current frame fireworks detection result is filtered; if the overlap is less than the preset overlap threshold, the current frame fireworks detection result is used as the target fireworks detection result;
[0025] If the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result, when it is determined that the number of fireworks detection frames corresponding to the current frame fireworks detection result and the previous frame fireworks detection result is greater than one, calculate the overlap of the fireworks detection frames between the current frame fireworks detection result and the previous frame fireworks detection result; if the overlap of any fireworks detection frame in the current frame fireworks detection result with any fireworks detection frame in the previous frame fireworks detection result is greater than or equal to the preset overlap threshold, filter the current frame fireworks detection result; if the overlap of any fireworks detection frame in the current frame fireworks detection result with any fireworks detection frame in the previous frame fireworks detection result is less than the preset overlap threshold, use the current frame fireworks detection result as the target fireworks detection result.
[0026] The present invention also provides a smoke and fire detection system, comprising:
[0027] A business scene image acquisition module is used to obtain business image data of the scene to be detected;
[0028] The smoke and fire detection module is used to input the business image data into the smoke and fire detection model to obtain the smoke and fire detection result corresponding to the scene to be detected output by the smoke and fire detection model, wherein the smoke and fire detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by a contrastive language-image pre-training model and a multi-layer perceptron.
[0029] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned smoke and fire detection methods is implemented.
[0030] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the smoke and fire detection method described above is implemented.
[0031] The present invention further provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned smoke and fire detection methods.
[0032] The fireworks detection method and system provided by the present invention can greatly improve the accuracy of fireworks recognition, reduce the false alarm rate, reduce labor costs and improve the work efficiency of supervisors by training the improved YOLO model constructed by the contrast language-image pre-training model and the multi-layer perception mechanism, so as to use the obtained fireworks detection model to perform fireworks detection on the business image data of the scene to be detected. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 A schematic diagram of the flow of the smoke and fire detection method provided by the present invention;
[0035] Figure 2 A schematic diagram of the structure of the improved YOLOv5 model provided by the present invention;
[0036] Figure 3 A schematic diagram of an enlarged detection frame provided by the present invention;
[0037] Figure 4 A schematic diagram of the filtering mechanism provided by the present invention;
[0038] Figure 5 A schematic diagram of the structure of the smoke and fire detection system provided by the present invention;
[0039] Figure 6 This is a schematic structural diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The existing smoke detection technology for high-altitude observation scenes can make up for the limitations of traditional fire detection methods in outdoor, field or places where smoke detectors are not suitable for installation, and can effectively prevent the occurrence of fire or reduce the harm of fire. The existing smoke detection technology for high-altitude observation scenes mainly has the following problems:
[0042] 1. For existing smoke and fire detection technology, it is easy to identify white clouds in the mountains or in the sky as smoke, and it is easy to identify water flows in the forest or white-gray cement ground as smoke; for fire detection, it is easy to identify high-exposure areas or night lights as fires, resulting in a large number of typical false alarms of smoke and fire in high-altitude observation scenes;
[0043] 2. For the existing fire and smoke detection business, too many alarms are issued in the same camera scenario, resulting in data redundancy.
[0044] In view of the problems existing in the existing fireworks detection technology, the present invention performs real-time intelligent recognition on the images taken by the high-altitude observation camera to determine whether there is smoke or fire in the image. If so, an alarm message is immediately issued in the associated platform, including precise positioning information such as monitoring points, time and area, and the recognition results are displayed in the platform to notify the supervisors to quickly handle it, thereby achieving real-time supervision, pre-prevention and rapid response. The present invention can greatly improve the accuracy of fireworks recognition, reduce the false alarm rate, reduce labor costs, and improve the work efficiency of supervisors while ensuring the recall rate, providing a strong fire safety guarantee.
[0045] Figure 1 A flow chart of the smoke and fire detection method provided by the present invention is shown in FIG. Figure 1 As shown, the present invention provides a method for detecting smoke and fire, comprising:
[0046] Step 101: Acquire business image data of a scene to be detected.
[0047] In the present invention, image acquisition can be performed through a high-altitude observation camera, which is generally set in a high-rise building near the scene to be detected, to achieve real-time image acquisition of the surrounding environment of the scene. Since the collected business image data contains false alarms such as white clouds, water flow and exposure, it is necessary to further perform smoke and fire detection and recognition on these collected business image data.
[0048] Step 102: input the business image data into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, wherein the fireworks detection model is constructed by an improved YOLO (You Only Look Once) model, and the improved YOLO model is constructed by a contrastive language-image pre-training (CLIP) model and a multilayer perceptron (MLP).
[0049] In the present invention, the output end of the existing YOLOv5 model is optimized to improve its performance on specific tasks (such as fireworks detection), including integrating the CLIP large model into the YOLOv5 model, and then adding MLP to the output end for fine-tuning for business scenarios, so as to remove various typical fireworks false alarms. It should be noted that in the present invention, other target detection models can also be used for improvement, such as the YOLOv8 model. In the present invention, for the fireworks detection task, the CLIP model may be used to provide additional contextual information or help the model better understand the complex scenes in the image. By combining the CLIP model with the YOLO model, the fireworks detection model can not only detect fireworks targets in the image, but also understand the relationship between these targets and the surrounding environment. The MLP can be used to fine-tune the output of the CLIP model and the YOLO model to generate the final fireworks detection result. It should be noted that in the present invention, the pre-training model can also use other wires, for example, the BLIP (Bidirectional Long-Range Identity-Preserving Pretraining) model. During the training process, these models can be trained together or in stages. First, a large amount of image and text data can be used to pre-train the CLIP model; then, the image data with fireworks labels is used to train the improved YOLO model; finally, the outputs of the YOLO model and the CLIP model are passed to the MLP for fine-tuning to improve the accuracy of fireworks detection.
[0050] The fireworks detection method provided by the present invention trains an improved YOLO model constructed by a contrastive language-image pre-training model and a multi-layer perceptron, and then uses the obtained fireworks detection model to perform fireworks detection on business image data of the scene to be detected, which can greatly improve the accuracy of fireworks recognition, reduce the false alarm rate, reduce labor costs, and improve the work efficiency of supervisors.
[0051] Based on the above embodiment, the smoke and fire detection model is trained by the following steps:
[0052] Get sample image data corresponding to each scene.
[0053] In the present invention, the sample image data should cover different scenes, such as outdoors, forests, villages and cities, and need to include fireworks images in different states (such as different sizes, different brightness and different angles, etc.). These data will become the basis for model learning and identifying fireworks.
[0054] A preset smoke and fire detection prompt phrase is constructed, wherein the preset smoke and fire detection prompt phrase includes a smoke detection prompt phrase and a fire detection prompt phrase.
[0055] In the present invention, some prompt phrases related to smoke and fire detection need to be predefined. These prompt phrases are divided into two categories: smoke detection prompt phrases and fire detection prompt phrases. These prompt phrases will be used in subsequent steps to match with sample image data to form text prompt phrases and image data pairs.
[0056] Specifically, in the current high-altitude observation scene, false alarms often occur due to the following situations: clouds, mountain fog, water drops on the lens, forest rivers, lakes partially blocked by trees, roads with lighter colors, obstructed leaves, sunlight reflections, exposure points, and night exposure lights, etc. Therefore, the present invention combines the characteristics of CLIP itself and selects a set of input text arrays text as the basis for similarity calculation. The smoke detection prompt words "text" selected by the present invention include: ["smog", "cloud", "whiteclouds", "water", "water surface", "lake", "road surface", "road", "lighting", "shine"], and the fire detection prompt words "text" include: ["fire", "lighting", "leaf", "cars", "trucks", "road", "road surface", "shine"].
[0057] According to the fireworks history information in the sample image data, the sample image data is matched with the corresponding smoke detection prompt phrase and the fire detection prompt phrase to obtain a text prompt phrase and image data pair.
[0058] In the present invention, it is necessary to analyze the fireworks history information in the sample image data, that is, whether there is smoke or flame in the image, and their characteristics (such as color, shape, size, etc.). Then, these sample image data are matched with the previously constructed smoke detection prompt phrases and fire detection prompt phrases. The matching process involves some image processing and computer vision technologies, such as target detection and image segmentation, to ensure that the fireworks targets in the image can be accurately identified and associated with the corresponding prompt phrases.
[0059] A training sample set is constructed according to the text prompt phrase and the image data pair, and the improved YOLO model is trained by using the training sample set to obtain the fireworks detection model.
[0060] In the present invention, after completing the matching of the sample image data and the prompt phrases in the above embodiment, a training sample set is constructed, which will contain a large number of text prompt phrases and image data pairs, wherein each image data corresponds to some prompt phrases related to fireworks. Further, the improved YOLO model is trained using the previously constructed training sample set, and the training process involves multiple iterations and optimizations, so that the model can gradually learn how to accurately identify fireworks targets from images.
[0061] In the present invention, a training sample set is constructed based on the above embodiment, and the sample image data and the corresponding text prompt phrases therein are simultaneously input into the MLP, so as to train the MLP parameters to increase the similarity value between "smog" and "fire" and reduce the similarity value of other interference items, and then the confidence is screened to obtain the final output. After the model training is completed, in the actual fireworks detection task, taking the detection result as smoke as an example, after a certain business image data is input into the fireworks detection model, the final output vector of the MLP is [0.9, 0.01, 0.01, ...], indicating that the image content contained in the center point (points) in the business image data has a smog phenomenon, and a result of a smoke alarm in the scene will be output.
[0062] On the basis of the above embodiment, the output layer of the improved YOLO model includes the contrastive language-image pre-training model and the multi-layer perceptron, wherein the input end of the contrastive language-image pre-training model is connected to the front layer of the improved YOLO model, and the front layer is used to output the corresponding center point to be detected according to the business image data; the output end of the contrastive language-image pre-training model is connected to the multi-layer perceptron.
[0063] In the present invention, the YOLOv5 model is used for illustration. Figure 2 The structural diagram of the improved YOLOv5 model provided by the present invention can be referred to Figure 2 As shown in the figure, in the YOLOv5 model, the front layer is the conventional processing flow of YOLOv5. After the image data is input into the model, it is sent to the Backbone based on Resnet50, and then the shallow graphic features are combined with the deep semantic features through the Feature Pyramid Network (FPN). Then, all possible target box anchors are output through the Head module, and finally all anchors with high overlap are filtered out through non-maximum suppression (NMS). Finally, the detection result coordinates of the front layer are output, that is, the coordinates of the corresponding center point to be detected are obtained.
[0064] Furthermore, the output layer is connected to the points output by the front layer. Preferably, in the present invention, an adaptive mechanism (Self-Adaptive Mechanism, SAM for short) is set in the output layer, so that the points output by the front layer are sent to the adaptive mechanism to obtain new points to be detected, and then the CLIP is fine-tuned according to the false alarm situation of the actual business scenario to obtain the final output detection frame.
[0065] Specifically, an adaptive mechanism is provided between the input end of the contrastive language-image pre-training model and the front layer, and the adaptive mechanism is used to enlarge the detection frame corresponding to the center point to be detected according to the size information of the preset fireworks detection frame, obtain the enlarged detection frame, and input the enlarged detection frame to the input end of the contrastive language-image pre-training model, wherein the formula of the adaptive mechanism is:
[0066] p=-0.00019(h*w)+5.3, if 1600<h*w<20000;
[0067] p=1.5,if h*w>20000;
[0068] Among them, p represents the magnification coefficient of the detection frame, h represents the length information of the preset fireworks detection frame, and w represents the width information of the preset fireworks detection frame.
[0069] The image size input by the existing actual business high-altitude camera is about 1500*850. The size of the fireworks frame detected by the existing technology is at least 40*40 and at most 200*100. Very few are larger than 200*100. The present invention adopts an area comparison method to realize an adaptive mechanism, wherein the smaller the detection frame area, the less information the points carry, and the greater the required expansion multiple; conversely, the larger the detection frame area, the more information the points carry, and the smaller the required expansion multiple.
[0070] Therefore, in the present invention, the magnification range is first limited to [1.5, 5], the minimum detection frame area is 1600, and the maximum is 20000. For each preset detection frame [x, y, h, w], where (x, y) is the coordinate of the center point of the preset detection frame, h represents the length information of the preset fireworks detection frame, w represents the width information of the preset fireworks detection frame, and h*w is the product of length and width, then based on the adaptive mechanism formula, the magnified detection frame is obtained: [x, y, p*h, p*w], at this time, the center point of the magnified detection frame remains unchanged, and the length and width are expanded outward p times respectively. Figure 3 This is a schematic diagram of the enlarged detection frame provided by the present invention. When p=2, the enlarged detection frame can refer to Figure 3 shown.
[0071] Further, please refer to Figure 2 As shown, after the new points are output through the model adaptive mechanism, the model continues to input them into the CLIP fine-tuning module, at which time the CLIP pre-training model will be loaded, and the trained parameters of all layers before the MLP layer will be frozen. In the present invention, the output of the CLIP pre-training model is a set of similarity values. For some targets that are very close to fireworks that may appear in the existing picture, their similarity values will be very close. The present invention adds a multi-layer perceptron MLP to the output end of the CLIP pre-training model, and selects cross entropy as the loss function to train and fine-tune the similarity, so as to better adapt to the text corresponding to the fireworks detection application scenario.
[0072] On the basis of the above embodiment, after inputting the service image data into the smoke and fire detection model to obtain the smoke and fire detection result corresponding to the scene to be detected output by the smoke and fire detection model, the method further includes:
[0073] Obtaining a plurality of fireworks detection results within a preset time period;
[0074] A smoke and fire detection frame between adjacent frames in the plurality of smoke and fire detection results is judged, and a target smoke and fire detection result is determined from the plurality of smoke and fire detection results according to the judgment result.
[0075] In the existing fire and smoke detection scenario, for real-time video streams, if AI analysis is to be performed on them, the first step is to perform frame capture processing. Assuming the frame capture frequency is 30 seconds / time, once smoke occurs, 20 alarms will be generated within 10 minutes, and the detection frames of each alarm image will be very similar. The front-end display will be repeated a lot, causing business-related processing personnel to frequently deal with redundant alarm information, which invisibly increases the workload. When the number of cameras increases significantly, the workload will increase exponentially.
[0076] In response to the redundant alarm problem existing in existing fire and smoke detection scenarios, in the present invention, for the repeated alarm images output by the fire and smoke detection model, the logic of the alarm images output based on the online video stream can be modified by setting a corresponding filtering mechanism (Filtering Mechanism, FM for short), thereby reducing the redundancy displayed on the front-end user platform.
[0077] In the present invention, a time range (such as 10 minutes) is preset as the alarm period, and judgment and analysis are performed through the fireworks detection frames between adjacent frames. Since fireworks are dynamically changing, they may move or change in consecutive frames. Therefore, if the detection frames in two adjacent frames have a high degree of overlap and the position changes slightly, then they can be considered to belong to the same fireworks; conversely, if the two detection frames have almost no overlap, or the position changes greatly, then they may belong to different fireworks or false detections, so that within an alarm period, only the fireworks detection results whose judgment results meet the preset conditions are pushed to filter out a large amount of repeated and redundant alarm information.
[0078] On the basis of the above embodiment, judging the fireworks detection frames between adjacent frames in the plurality of fireworks detection results, and determining the target fireworks detection result from the plurality of fireworks detection results according to the judgment result, comprises:
[0079] Determine whether the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result; if not, use the current frame fireworks detection result as the target fireworks detection result;
[0080] If the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result, when it is determined that the number of fireworks detection frames corresponding to the current frame fireworks detection result and the previous frame fireworks detection result are both 1, the overlap of the fireworks detection frames between the current frame fireworks detection result and the previous frame fireworks detection result is calculated; if the overlap is greater than or equal to a preset overlap threshold, the current frame fireworks detection result is filtered; if the overlap is less than the preset overlap threshold, the current frame fireworks detection result is used as the target fireworks detection result;
[0081] If the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result, when it is determined that the number of fireworks detection frames corresponding to the current frame fireworks detection result and the previous frame fireworks detection result is greater than one, calculate the overlap of the fireworks detection frames between the current frame fireworks detection result and the previous frame fireworks detection result; if the overlap of any fireworks detection frame in the current frame fireworks detection result with any fireworks detection frame in the previous frame fireworks detection result is greater than or equal to the preset overlap threshold, filter the current frame fireworks detection result; if the overlap of any fireworks detection frame in the current frame fireworks detection result with any fireworks detection frame in the previous frame fireworks detection result is less than the preset overlap threshold, use the current frame fireworks detection result as the target fireworks detection result.
[0082] Figure 4 The flowchart of the filtering mechanism provided by the present invention can be referred to Figure 4 As shown, in the present invention, after obtaining the real-time video stream of the business scene, the frame capture service is called to capture the video stream at a predetermined frequency, and the captured frame images are sequentially sent to the AI algorithm analysis service (i.e., the fireworks detection model) for detection and recognition. After the recognition is completed, the detection frame points obtained by the detection are compared with the previous and next frames. The specific steps are as follows;
[0083] First, when there is only one fireworks detection frame in the picture, if the current frame is the initial first frame, the alarm is directly output and pushed to the front-end platform for display, and the process continues; if the current frame is the nth frame, the overlap value (Intersection over Union, abbreviated as IOU) with the detection frame in the n-1th frame is calculated. If IOU ≥ 0.85 (in the present invention, 0.85 is the best threshold obtained by counting the actual business detection frame points and calculating the IOU), it means that the results of the nth frame and the n-1th frame are very similar, and the alarm output of the nth frame is suppressed; if IOU < 0.85, it means that the detection results of the nth frame and the n-1th frame are different, then the alarm of the frame is output and pushed.
[0084] If the number of detection frames of the nth frame is inconsistent with that of the n-1th frame, the alarm of the nth frame is directly output and pushed without performing IOU comparison.
[0085] If the number of detection frames in the nth frame and the n-1th frame is the same and greater than one, the IOU between each frame in the nth frame and all frames in the n-1 frame is calculated respectively. If all detection frames in the nth frame can find a detection frame with IOU≥0.85 in the n-1th frame, it means that the detection results of the two frames are similar, and the alarm output of the nth frame is suppressed; conversely, if at least one detection frame in the nth frame cannot find a detection frame with IOU≥0.85 in the n-1th frame, it means that a new event has occurred in the nth frame, and the alarm is directly output and pushed. The present invention can reduce redundant information by continuously filtering the fireworks recognition results of the received video stream frame captures in the above process.
[0086] The present invention adds an adaptive mechanism and a CLIP pre-training model to the output end of the YOLO model, and fine-tunes the output of CLIP through the MLP module, so as to obtain a fireworks detection model based on the improved YOLO model training. Finally, in the online fireworks detection test, a recall rate of 0.98 and an accuracy of 0.95 can be achieved, and the F1 score is 0.96, and the indicators are comprehensively superior to the existing methods. In addition, for real-time video streams, the filtering mechanism is used to further optimize the user experience before pushing alarms to the front end, and a large amount of repeated redundant alarm information is filtered out. In this way, about 40% of redundant information can be reduced in the end, which not only beautifies the front-end display interface, but also saves storage resources and reduces the workload of business personnel.
[0087] The smoke and fire detection system provided by the present invention is described below. The smoke and fire detection system described below and the smoke and fire detection method described above can be referred to each other.
[0088] Figure 5 The structural diagram of the smoke and fire detection system provided by the present invention is as follows: Figure 5 As shown, the present invention provides a smoke and fire detection system, including a business scene image acquisition module 501 and a smoke and fire detection module 502, wherein the business scene image acquisition module 501 is used to obtain business image data of a scene to be detected; the smoke and fire detection module 502 is used to input the business image data into a smoke and fire detection model to obtain a smoke and fire detection result corresponding to the scene to be detected output by the smoke and fire detection model, wherein the smoke and fire detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by a contrastive language-image pre-training model and a multi-layer perceptron.
[0089] The fireworks detection system provided by the present invention can greatly improve the accuracy of fireworks recognition, reduce the false alarm rate, reduce labor costs and improve the work efficiency of supervisors by training the improved YOLO model constructed by the contrast language-image pre-training model and the multi-layer perception machine, so as to use the obtained fireworks detection model to perform fireworks detection on the business image data of the scene to be detected.
[0090] The system provided by the present invention is used to execute the above-mentioned method embodiments. Please refer to the above-mentioned embodiments for the specific processes and detailed contents, which will not be repeated here.
[0091] Figure 6 A schematic diagram of the structure of an electronic device provided by the present invention, such as Figure 6 As shown, the electronic device may include: a processor (Processor) 601, a communication interface (Communications Interface) 602, a memory (Memory) 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604. The processor 601 may call the logic instructions in the memory 603 to execute the fireworks detection method, which includes: obtaining business image data of a scene to be detected; inputting the business image data into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, wherein the fireworks detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by contrasting a language-image pre-training model and a multi-layer perceptron.
[0092] In addition, the logic instructions in the above-mentioned memory 603 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 such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable 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 invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0093] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the fireworks detection method provided by the above methods, and the method includes: obtaining business image data of a scene to be detected; inputting the business image data into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, wherein the fireworks detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by contrasting language-image pre-training model and a multi-layer perceptron.
[0094] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the fireworks detection method provided by the above-mentioned embodiments, the method comprising: obtaining business image data of a scene to be detected; inputting the business image data into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, wherein the fireworks detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by contrasting language-image pre-training model and a multi-layer perceptron.
[0095] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.
[0096] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting fireworks, characterized in that: include: Obtaining business image data of the scene to be detected; The business image data is input into a fireworks detection model to obtain a fireworks detection result corresponding to the scene to be detected output by the fireworks detection model, wherein the fireworks detection model is constructed by an improved YOLO model, and the improved YOLO model is constructed by a contrastive language-image pre-training model and a multi-layer perceptron.
2. The method for detecting smoke and fire according to claim 1, wherein: The fire detection model is trained by the following steps: Obtain sample image data corresponding to each scene; Constructing a preset fire and smoke detection prompt phrase, wherein the preset fire and smoke detection prompt phrase includes a smoke detection prompt phrase and a fire detection prompt phrase; According to the fireworks history information in the sample image data, the sample image data is matched with the corresponding smoke detection prompt phrase and the fire detection prompt phrase to obtain a text prompt phrase and image data pair; A training sample set is constructed based on the text prompt phrase and image data pairs, and the improved YOLO model is trained using the training sample set to obtain the fireworks detection model.
3. The method for detecting smoke and fire according to claim 2, wherein: The output layer of the improved YOLO model includes the contrastive language-image pre-training model and the multi-layer perceptron, wherein the input end of the contrastive language-image pre-training model is connected to the front layer of the improved YOLO model, and the front layer is used to output the corresponding center point to be detected according to the business image data; the output end of the contrastive language-image pre-training model is connected to the multi-layer perceptron.
4. The method for detecting smoke and fire according to claim 3, wherein: An adaptive mechanism is provided between the input end of the contrastive language-image pre-training model and the front layer. The adaptive mechanism is used to enlarge the detection frame corresponding to the center point to be detected according to the size information of the preset fireworks detection frame, obtain the enlarged detection frame, and input the enlarged detection frame into the input end of the contrastive language-image pre-training model. The formula of the adaptive mechanism is: p=-0.00019(h*w)+5.3, if 1600<h*w<20000; p=1.5,if h*w>20000; Wherein, p represents the magnification coefficient of the detection frame, h represents the length information of the preset fireworks detection frame, and w represents the width information of the preset fireworks detection frame.
5. The method for detecting smoke and fire according to any one of claims 1 to 4, characterized in that: After inputting the service image data into the fire and smoke detection model to obtain the fire and smoke detection result corresponding to the scene to be detected output by the fire and smoke detection model, the method further includes: Obtaining a plurality of fireworks detection results within a preset time period; The smoke and fire detection frames between adjacent frames in the plurality of the smoke and fire detection results are judged, and a target smoke and fire detection result is determined from the plurality of the smoke and fire detection results according to the judgment result.
6. The method for detecting smoke and fire according to claim 5, wherein: The step of judging the smoke and fire detection frames between adjacent frames in the plurality of smoke and fire detection results, and determining a target smoke and fire detection result from the plurality of smoke and fire detection results according to the judgment result, includes: Determine whether the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result; if not, use the current frame fireworks detection result as the target fireworks detection result; If the number of fireworks detection frames in the current frame fireworks detection result and the number of fireworks detection frames in the previous frame fireworks detection result are the same, and if it is determined that the number of fireworks detection frames corresponding to the current frame fireworks detection result and the previous frame fireworks detection result is both one, calculating the overlap of the fireworks detection frames between the current frame fireworks detection result and the previous frame fireworks detection result; if the overlap is greater than or equal to a preset overlap threshold, filtering the current frame fireworks detection result; if the overlap is less than the preset overlap threshold, using the current frame fireworks detection result as the target fireworks detection result; If the number of fireworks detection frames in the current frame fireworks detection result is the same as that in the previous frame fireworks detection result, when it is determined that the number of fireworks detection frames corresponding to the current frame fireworks detection result and the previous frame fireworks detection result is greater than one, the overlap of the fireworks detection frames between the current frame fireworks detection result and the previous frame fireworks detection result is calculated; if the overlap of any fireworks detection frame in the current frame fireworks detection result with any fireworks detection frame in the previous frame fireworks detection result is greater than or equal to the preset overlap threshold, the current frame fireworks detection result is filtered; if the overlap of any fireworks detection frame in the current frame fireworks detection result with any fireworks detection frame in the previous frame fireworks detection result is less than the preset overlap threshold, the current frame fireworks detection result is used as the target fireworks detection result.
7. A smoke and fire detection system, characterized in that: include: Business scene image acquisition module, used to obtain business image data of the scene to be detected; The smoke and fire detection module is used to input the business image data into the smoke and fire detection model to obtain the smoke and fire detection result corresponding to the scene to be detected output by the smoke and fire detection model, wherein the smoke and fire detection model is constructed using an improved YOLO model, and the improved YOLO model is constructed using a contrastive language-image pre-training model and a multi-layer perceptron.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the smoke and fire detection method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the smoke and fire detection method according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the smoke and fire detection method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Factory firework detection method and device, electronic equipment and storage medium
CN120748116A
Post-processing optimization method for improving smoke and fire detection effect of kitchen
CN121861841A
