Construction method of model with petrochemical fire picture detection function and petrochemical fire detection system

By improving the backbone network layer, neck layer and head layer of the YOLOv5s model, combined with petrochemical fire data sets and prior knowledge, the problem of insufficient petrochemical fire detection accuracy and speed is solved, and efficient fire detection in complex scenarios is achieved.

CN118675280APending Publication Date: 2024-09-20HAINAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410937726.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

Existing fire detection methods have insufficient detection accuracy and speed in complex petrochemical fire scenarios and cannot meet the detection needs of petrochemical fires. Moreover, the training data set has a small scene scale and a single scene, and cannot adapt to complex fire situations.

Method used

Improve the backbone network layer, neck layer and head layer of the YOLOv5s model, use GAM Attention, Contextual Transformer and custom Anchor, combined with petrochemical fire data set and prior knowledge, to build a model with petrochemical fire picture detection function.

Benefits of technology

It improves the feature extraction and feature aggregation capabilities of the target detection model, improves the detection accuracy and speed in petrochemical fire scenarios, and meets the dual needs of high accuracy and high detection speed in petrochemical fire detection scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118675280A
    Figure CN118675280A
Patent Text Reader

Abstract

The invention provides a construction method of a model with a petrochemical fire picture detection function and a petrochemical fire detection system. The method is based on a YOLOv5s model and comprises a process of improving a backbone network layer, a process of improving a neck layer and a process of improving a head layer. The system comprises a server and a client which are in communication connection. The client is provided with an information collection module and an early warning module which are used for collecting and arranging locally collected data; and the server is provided with a petrochemical fire picture database set, an information detection module and a display module, and is used for carrying out fire detection on the pictures sent by the client and sending a detection result to the client. According to the invention, the detection accuracy in a petrochemical fire scene 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 fire detection, and in particular to a method for constructing a model with a petrochemical fire image detection function and a petrochemical fire detection system. Background Art

[0002] Fire has many impacts on human society and the natural environment. Severe fires may even lead to the loss of the self-regulation ability of the ecological environment, posing a serious threat to human survival and development. Traditional artificial and physical sensor equipment has low detection reliability and a small detection range. The sensitivity will decrease over time, and the efficiency of detecting fires in the first place is low. With the development of computer vision, fire detection technology based on deep learning has the characteristics of high detection accuracy, fast detection speed and wide detection direction. It can issue an alarm in the early stage of a fire to prevent the fire from further expanding and reduce the losses caused by the fire. However, compared with ordinary fire scenes, petrochemical fires often occur in outdoor scenes, with characteristics such as fast burning speed, high explosion risk, and difficulty in extinguishing. They are also easily disturbed by environmental factors such as light, rain, snow, and wind speed. It is necessary to obtain as much effective information about the fire as possible, such as locating the specific location of the fire or calculating the size of the flame, while maintaining higher detection speed and high accuracy. In addition, the environment of the petrochemical park is complex and there are many interference conditions. Directly using existing detection algorithms cannot meet the detection requirements of petrochemical fires. It is now necessary to design a detection method for petrochemical fires. The model constructed by this method can achieve the best performance in fire detection accuracy and real-time performance in complex and changeable petrochemical fire scenes.

[0003] The patent closest to the present invention is: Fire Detection Method Based on Machine Learning (Publication No. CN112396023A), which discloses a fire detection method based on machine learning. This method uses a preset neural network model to determine whether there are flame and smoke features in the suspicious fire image in the video, and then issues a fire warning. This solves most of the problems of incomplete fire detection, lack of timeliness, and low detection accuracy.

[0004] The specific implementation process of the fire detection method proposed in this patent is as follows:

[0005] 1. Obtain a forest video image, identify the forest video image frame by frame, and determine whether there is a suspicious fire image in the forest video image according to the identification result;

[0006] 2. When there is a suspicious fire image in the forest video image, the suspicious fire image is acquired, and image features of the suspicious fire image are extracted using a preset neural network model to obtain an image feature set;

[0007] 3. Detect whether there is a flame and smoke feature in the image feature set, and if so, generate fire warning information based on the suspicious fire image.

[0008] The main defects of the above patent are as follows:

[0009] 1. The neural network model preset by this method is trained on multiple frames of forest images obtained from the video, but forest images are relatively simple compared to actual fire scenes. Therefore, the fire detection performance of the preset model of this method in actual complex scenes cannot meet actual needs, especially in petrochemical fire fighting scenes, which have complex environments and many interference conditions.

[0010] 2. This method mainly relies on image processing and uses a preset neural network model to extract characteristic features and detect whether there are flame and smoke features in the feature set. This method that relies on feature judgment has low generalization ability, and fire scenes are ever-changing. In complex scenes, this method will have problems such as low accuracy and high false alarm rate. In addition, the neural network model used in this method is easily affected by the shape, size, and different perspectives of the image. It cannot meet the dual requirements of detection speed and detection accuracy in petrochemical fire detection scenes.

[0011] The current issues that need to be addressed are:

[0012] 1. The existing model training dataset has a small scale and a single scenario, and cannot adapt to more complex fire situations such as petrochemical fire scenarios. It is necessary to build a petrochemical fire dataset that is more complex and more practical than other ordinary scenarios and contains non-fire negative samples similar to fires.

[0013] 2. In view of the problem that existing fire detection methods have insufficient detection accuracy and speed in complex scenarios such as petrochemical fires, it is necessary to combine attention mechanism and self-attention mechanism to optimize the target detection model, improve the model's feature extraction and feature aggregation capabilities, and use prior knowledge to improve the model's adaptability to the scene, thereby improving the model's detection performance in petrochemical fire scenarios. Summary of the invention

[0014] In order to solve the above problems, the present invention proposes a method for constructing a model with petrochemical fire image detection function and a petrochemical fire detection system.

[0015] A method for constructing a model with a petrochemical fire image detection function, the method is based on a YOLOv5s model, which includes an input layer, a backbone network layer, a neck layer, and a head layer connected in sequence according to a signal transmission order, and the method includes improving a process of the backbone network layer, improving a process of the neck layer, and improving a process of the head layer;

[0016] In the process of improving the backbone network layer, the backbone network layer is improved based on the YOLOv5s model based on GAM Attention;

[0017] In the process of improving the neck layer process, the neck layer of the YOLOv5s model is improved based on Contextual Transformer;

[0018] In the process of improving the head layer, a custom pre-selected box is used to improve the head layer of the YOLOv5s model to control the shape and size of the model prediction bounding box.

[0019] Furthermore, the GAM Attention unit includes a channel attention subunit and a spatial attention subunit. The GAM Attention unit combines the spatial features and channel features of the image and converts the input feature map into a new output feature map after calculation: Assume that the feature map of the input GAM Attention unit is , then the middle feature map And the feature map of the output GAM Attention unit It can be obtained by the following formula:

[0020]

[0021]

[0022] in , They represent the channel attention and spatial attention in the GAM Attention unit respectively, and U means the elements are multiplied in sequence.

[0023] Furthermore, Two 7x7 convolutional layers are used to integrate spatial information, and the pooling layer is removed.

[0024] Furthermore, the reduction rate of the channel attention subunit is 16.

[0025] Furthermore, the custom pre-selection box improves the head layer of the YOLOv5s model as follows: the pre-selection box sizes corresponding to the small-size feature layer are (12, 17), (23, 27), (32, 57), and / or the pre-selection box sizes corresponding to the medium-size feature layer are (61, 41), (67, 105), (121, 73), and / or the pre-selection box sizes corresponding to the large-size feature layer are (159, 151), (330, 266), (808, 641).

[0026] A petrochemical fire detection system includes a server and a client connected in communication; the client is provided with an information collection module and an early warning module for collecting and arranging data collected locally; the server is provided with a petrochemical fire picture database set, an information detection module, and a display module for performing fire detection on pictures sent by the client and sending the detection results to the client;

[0027] The information collection module is connected to the camera arranged in the petrochemical scene. The camera transmits the video stream in real time, processes the video collected by the camera, forms the on-site image of the petrochemical scene, and sends it to the information detection module on the server side;

[0028] The information detection module is used to perform fire detection on the received image and output the detection result; the fire detection model constructed by the above method is adopted in the information detection module, and the fire detection model comprises an input layer, a backbone network layer, a neck layer, and a head layer connected in sequence; the fire detection model is trained using a petrochemical fire data set, and prior knowledge of petrochemical fire scenes is added;

[0029] The early warning module is used to determine whether to initiate an alarm based on the detection results and send an alarm signal;

[0030] The display module is used to visually display the fire situation;

[0031] The petrochemical fire image dataset contains both fire images and non-fire images.

[0032] Furthermore, the workflow of the information detection module is:

[0033] Step 2.1: Load the pre-trained fire detection model;

[0034] Step 2.2: Input the processed petrochemical fire image frame into the fire detection model for fire detection;

[0035] Step 2.3: The fire detection model outputs the detected fire information.

[0036] Furthermore, in step 2.2, the specific steps of the fire detection model for fire detection are:

[0037] Step 1: The petrochemical fire image is fed into the input layer of the fire detection model;

[0038] Step 2: The backbone network layer extracts useful features from the input data to form a feature map;

[0039] Step 3: The neck layer further aggregates the feature maps extracted by the backbone network;

[0040] Step 4: The head layer performs classification and positioning, and uses the pre-selected box to generate the location and category information of the target from the feature map.

[0041] Furthermore, the petrochemical fire image dataset contains fire images and non-fire images, and is divided into training set, validation set and test set.

[0042] Furthermore, the images in the petrochemical fire image dataset were annotated using the Labelimg tool, and the annotated content was automatically saved in txt format, and the txt annotation file was converted into the COCO dataset format through a Python script.

[0043] The technical effects of the present invention are:

[0044] 1. In response to the problem that the current public fire datasets are small in size and single in scene, a large dataset specifically for petrochemical fire detection was constructed. This dataset will provide important data support for subsequent petrochemical fire monitoring research and promote technological progress in related fields.

[0045] 2. Based on GAM Attention, the backbone network layer of YOLOv5s is improved to improve the feature extraction capability of the target detection model, thereby improving the detection performance of the model in petrochemical fire scenarios.

[0046] 3. Based on Contextual Transformer, the neck layer of YOLOv5s is improved to improve the feature aggregation capability of the target detection model, thereby improving the detection accuracy of the model in petrochemical fire scenarios.

[0047] 4. Improve YOLOv5s based on custom Anchors and add prior knowledge of petrochemical fire scenes to help model training, thereby helping the model adapt to the complex targets and scenes of petrochemical fires. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a structural diagram of the YOLOv5s_Fire fire detection model of the present invention.

[0049] Figure 2 This is the detection result of petrochemical fire by YOLOv5s_Fire fire detection model.

[0050] Figure 3 Schematic diagram of the GAM Attention unit function

[0051] Figure 4 Examples of positive and negative samples in the petrochemical fire dataset.

[0052] Figure 5 An example of data labeling results.

[0053] Figure 6 This is a correlation analysis chart between the horizontal and vertical coordinates and the height and width of the center point of the annotation box. DETAILED DESCRIPTION

[0054] The invention concept of this application is to provide a method for constructing a YOLOv5s_fire fire detection model with a petrochemical fire image detection function, and based on the model, to construct a petrochemical fire detection system specifically for petrochemical fire scenes. The system is divided into a server side and a client side, the client side is provided with an information collection module and an early warning module, and the server side is provided with a petrochemical fire image database set, an information detection module, and a display module.

[0055] In order to facilitate the system to directly access camera resources and ensure the continuous iteration and update of the system, the client is mainly responsible for collecting and organizing the data of the local camera, while the server performs fire detection on the pictures sent by the client and sends the detection results to the client. The client then determines whether to send an alarm signal based on the received detection results. In this way, when the model is updated, only the server needs to be updated, and the client does not need to make any changes, thereby improving the scalability of the system.

[0056] In petrochemical scenarios, in order to ensure the safety of on-site personnel, all-round cameras with no blind spots are usually installed around petrochemical facilities. The system only needs to import camera data into the model to complete real-time fire detection. By identifying flames, the system can also achieve rapid early warning of fires.

[0057] The following describes each module in the system and explains how to build the model.

[0058] 1. Information Collection Module

[0059] The information collection module is located on the client side. The information collection module is connected to the camera arranged in the petrochemical scene. The camera transmits the video stream in real time, processes the video collected by the camera, forms the on-site image of the petrochemical scene, and sends it to the information detection module on the server side.

[0060] The specific workflow of the information collection module is as follows:

[0061] Step 1.1: Get the video stream from the camera. The camera deployed in the petrochemical park acquires the video stream in real time to ensure full coverage of the key areas of the petrochemical park. The camera should have high resolution and wide dynamic range to meet the image acquisition requirements under different lighting conditions.

[0062] Step 1.2: Adjust the color, brightness and contrast of the video stream, and normalize the resolution and frame rate of the video stream to meet the requirements of subsequent processing steps.

[0063] Step 1.3: Extract the video stream into static image frames at a predetermined frame rate. This embodiment uses a fixed frame rate of 30 frames per second, which can be adjusted as needed in practical work. Extracting image frames at a fixed frame rate can ensure processing consistency and simplify the processing flow, ensuring that the processing conditions of all frames are consistent. The rate of 30 frames per second (FPS) is high enough to capture most action details and ensure real-time performance, which is very important for detecting emergencies (such as fires).

[0064] Step 1.4: Use the existing image enhancement algorithm to enhance the contrast of the image and reduce the noise, thereby improving the image quality and eliminating the image quality degradation caused by environmental factors (such as dust, rain, etc.) of the camera.

[0065] Step 1.5: The extracted image frames are resized to 640x480 pixels and converted from RGB to YCbCr color space to enhance the flame features. The pixel values ​​are normalized to the range of [0, 1] to meet the input requirements of the fire detection model in the detection layer.

[0066] 2. Information Detection Module

[0067] At present, the target detection models widely used in the field of fire detection mainly include two-stage, single-stage and Transformer-based methods. In order to further explore the applicability of these models in the field of petrochemical fire detection, this paper conducts a detailed experimental analysis based on a self-built petrochemical fire dataset. The model evaluation indicators include:

[0068] Average precision (AP) is used to evaluate the detection accuracy of the model in different target categories.

[0069] Floating-point operations (FLOPs) are used to evaluate the model inference speed and computational complexity.

[0070] Parameters are used to evaluate the model's ability to extract features from input data and make predictions.

[0071] The number of image frames processed per second (FPS) by the model is used to measure the number of image frames processed by the model per second. It directly reflects the speed and real-time performance of the model in processing images.

[0072] The experimental results of each target detection model are shown in Table 1. Overall, YOLOv5s has achieved the best results in detection accuracy and reasoning speed, and it is more feasible to apply it to petrochemical fire detection. Therefore, the present invention takes the YOLOv5s structure as a benchmark and makes various improvements to it to improve its detection effect in petrochemical fire fighting.

[0073] Table 1 Experimental verification results of popular object detection models on the petrochemical fire dataset

[0074] Serial number Model Name AP@0.5 GFLOPs Parameter size (M) FPS 1 Faster R-CNN 0.613 194 41.35 23.9 2 Cascade R-CNN 0.589 222 69.15 18.2 3 Dynamic R-CNN 0.620 201 41.35 13.6 4 SSD 0.600 30.43 23.75 81.3 5 YOLOv3 0.647 154.6 61.5 108.7 6 YOLOv4 0.648 20.6 9.11 227.3 7 YOLOv5s 0.653 15.8 7.01 285.7 8 DETR 0.585 88.85 41.56 21.1 9 Deformable DETR 0.628 182 40.1 18.8 10 Conditional DETR 0.638 95.95 43.45 6.9

[0075] The YOLOv5s_Fire fire detection model is described below.

[0076] The present invention improves YOLOv5s in many aspects by adding GAMAttention ( Figure 1 GAM module in ), Contextual Transformer ( Figure 1 The COT module in the YOLOv5s_fire module is used to improve the model's feature extraction and aggregation capabilities. The model is also modified to add prior knowledge of petrochemical fires. The improved model is named YOLOv5s_fire. Its module structure is as follows: Figure 1 The CONT experiment shows that YOLOv5s_fire is more suitable for fire detection in petrochemical fire scenes, and can help achieve rapid fire warning by detecting flames. The model's detection results for petrochemical fires are as follows: Figure 2 Compared with other common fire detection models, YOLOv5s_Fire is more suitable for petrochemical fire scenes and has higher detection performance and detection accuracy.

[0077] The YOLOv5s_fire model includes the input layer, backbone network layer, neck layer, and head layer connected sequentially.

[0078] 1. Input layer

[0079] The input layer is used to input petrochemical fire pictures, which have been pre-labeled and their coordinate values ​​have been included.

[0080] 2. Backbone network layer

[0081] The attention mechanism can help the neural network focus on the most important parts when processing data, thereby improving the performance and generalization ability of the model. This application improves the backbone network layer of the YOLOv5s model based on GAM Attention. In YOLOv5, the backbone network layer is mainly responsible for extracting useful features from the input data, while GAM Attention can combine the spatial features and channel features of the image to have a stronger feature extraction capability. As the number of network layers increases, the quality requirements for features become higher. This application adds the GAM Attention unit before the SPPF unit. The main function of the SPPF unit is to aggregate the features extracted by the shallow network. Before the GAM Attention unit is added to the SPPF module, more high-quality features are provided to the SPPF layer for aggregation.

[0082] The functional diagram of GAM Attention unit is as follows Figure 3 , which includes a channel attention subunit and a spatial attention subunit. This unit converts the input feature map into a new output feature map after operation: Assume that the input feature map is , then the middle feature map And the output feature map It can be obtained by formulas (1) and (2).

[0083] (1); (2);

[0084] in and They represent channel attention and spatial attention respectively.

[0085] Among them The channel attention subunit retains cross-dimensional information through three-dimensional arrangement, and then connects to the multi-layer perceptron (MLP) to enhance the dependency between channels and spaces in different dimensions. Finally, after dimension inversion and sigmoid function, the corresponding spatial features can be obtained. In this embodiment, when the channel attention subunit reduction rate r is set to 16, the accuracy is the highest, and while maintaining a high accuracy, overfitting is avoided. Two 7x7 convolutional layers are used to integrate spatial information. In addition, considering that the traditional maximum pooling operation will cause information loss and have adverse effects, the pooling layer is removed from the As structure to further protect the integrity of the feature map.

[0086] 3. Neck layer

[0087] The neck layer of YOLOv5 is located between the backbone network layer and the head layer. Its main purpose is to further process the feature map extracted by the backbone network in order to improve the accuracy of target detection. This application improves YOLOv5s neck layer based on ContextualTransformer. The self-attention mechanism can capture the interaction between features of different spatial positions. Based on the FPN structure, the present invention incorporates the self-attention mechanism to improve the ability of YOLOv5 neck layer to aggregate features.

[0088] like Figure 1 As shown, this application adds a Contextual Transformer module before the CONV module ( Figure 1Compared with the traditional self-attention mechanism, the COT module in YOLOv5 can mine and utilize the contextual information between neighboring keys, efficiently promote self-attention learning, and enhance the expression of feature maps. As the number of model layers increases, YOLOv5 will lose more information in the Head layer. Therefore, the input features of the C3 module of the last layer of the YOLOv5 model are convolution No. 10 from the bottom layer and convolution No. 21 from the top layer. The bottom features and top features are fused to reduce information loss. Since Contextual Transformer combines contextual information and is more suitable for feature fusion, the Contextual Transformer module can be used to replace the C3 module No. 23 of the YOLOv5 model to improve the feature fusion capability of the YOLOv5 model.

[0089] 4. Head layer

[0090] The head layer is responsible for the final detection task, including classification and positioning, and can generate the location and category information of the target from the feature map of the network. This application uses custom anchors to improve the YOLOv5s head layer. Anchor (pre-selected box) is a predefined set of rectangular boxes with a fixed aspect ratio and size. During target detection, these boxes are offset and scaled on each cell in the image to generate candidate boxes for the target. By adjusting these anchors, the shape and size of the model's predicted bounding box can be controlled, thereby helping the model adapt to different types of targets and scenes.

[0091] Prior knowledge plays a huge role in machine learning. The building structure of petrochemical sites is different from that of ordinary buildings. The flame shape produced when a fire occurs is very different from that of common indoor fires. If the prior knowledge of petrochemical fires can be incorporated into the YOLOv5 model, it will provide great help for model training. Commonly used prior knowledge includes domain knowledge, data distribution assumptions, model structure, regularization, heuristic methods, image enhancement and cross-validation, etc., and the custom anchors clustered by this application based on specific scenarios belong to domain knowledge, model structure and heuristic methods.

[0092] In object detection, domain knowledge can help determine the size and shape of common objects. By analyzing the distribution of objects in the training dataset, a more appropriate anchor size and aspect ratio can be designed, thereby improving detection accuracy and recall.

[0093] Customizing anchors involves modifying the model's anchor configuration, which directly affects the model's structure and output features. By defining anchors that are more in line with actual conditions, the model can more easily learn useful features during training and improve detection performance.

[0094] The process of selecting and designing anchors is usually based on experience and heuristic methods. For example, the K-means clustering algorithm is used to analyze the target box size in the dataset to determine the optimal anchor size and number.

[0095] The original YOLOv5 model clusters 9 anchors of different sizes from the COCO dataset, namely [10,13,16,30,33,23], [30,61,62,45,59,119], [116,90,156,198, 373,326]. The 3 anchor arrays represent 9 pre-selected boxes of different sizes, namely [10,13], [16,30], [33,23], [30,61], [62,45], [59,119], [116,90], [156,198], [373,326]. Each pair represents the width and height of an anchor box. For example, [10,13] represents a pre-selected box with a width of 10 and a height of 13.

[0096] However, this set of Anchors is not suitable for petrochemical fire scenes, so the present invention clusters Anchors for the self-built petrochemical fire data set. The original YOLOv5 uses the K-means algorithm to perform clustering tasks, but K-means is sensitive to the selection of the initial cluster center and is prone to fall into local optimality. K-means++ uses a weighted random selection method to more intelligently select the initial cluster center, making the initial center point more representative and more likely to cover the characteristics of the entire data set. The present invention uses K-means++ for clustering, and the specific steps are as follows:

[0097] Step a: Define each labeled sample in the petrochemical fire dataset as X, and randomly select one as the initialization sample as the first cluster center ;

[0098] Step b: Calculate each sample to the selected cluster center The Euclidean distance D(x) of the center point;

[0099] Step c: Calculate the probability that each sample point becomes a new cluster center The probability value is calculated as shown in Formula 3:

[0100] (3);

[0101] For the i-th sample to the selected cluster center Euclidean distance of the center point;

[0102] Step d: Repeat steps b and c until the cluster center no longer changes.

[0103] The anchor sequence obtained by clustering the petrochemical fire dataset of the present invention using the K-means++ algorithm is shown in Table 2.

[0104] Table 2 Anchors improved based on K-means++ algorithm

[0105] Feature layer types Small Anchor Medium Anchor Large Anchor Small-scale feature layer (12,17) (23,27) (32,57) Mesoscale feature layer (61,41) (67,105) (121,73) Large-scale feature layer (159,151) (330,266) (808,641)

[0106] Feature layers mainly refer to the level of feature representation extracted from input data through convolution operations in convolutional neural networks (CNNs). These feature layers can be low-level features close to the input layer or high-level features close to the output layer. Low-level feature layers usually capture local, detailed features, such as edges and textures; these feature layers have higher spatial resolutions but less semantic information. High-level feature layers capture global, abstract features, such as the shape and category of objects; these feature layers have lower spatial resolutions but rich semantic information. In object detection, feature layers of different scales are used to detect objects of different sizes: small-scale feature layers (high resolution) are used to detect smaller objects and are usually located near the input layer. Medium-scale feature layers are used to detect medium-sized objects and are usually located in the middle layer of the network. Large-scale feature layers (low resolution) are used to detect larger objects and are usually located near the output layer.

[0107] For the above three improvement strategies, the present invention summarizes these optimization strategies into seven groups based on the YOLOv5s model. Specifically, they include the GAM Attention structure, the Contextual Transformer structure, and the setting of the custom Anchor. In order to simplify the representation, the suffixes "_GAM", "_COT" and "_Anchor" are used to refer to the names of the combined models containing the above improvements. The experimental results of these improved models on the self-built petrochemical fire dataset are shown in Table 3, where "√" indicates that the method was used in the experiment, and "×" indicates that the method was not used in the experiment.

[0108] Table 3 Ablation experiments based on the improved YOLOv5s model

[0109] Model GAM Attention Contextual Transformer K-means++ Anchor AP@0.5 GFLOPs Parameter quantity FPS YOLOv5s × × × 0.653 15.8 7015519 285.7 YOLOv5s_GAM √ × × 0.674 17.2 8754783 200 YOLOv5s_COT × √ × 0.672 15.8 7003743 333.3 YOLOv5s_Anchor × × √ 0.67 15.8 7015519 285.7 YOLOv5s_GAM_COT √ √ × 0.68 17.1 8743007 256.4 YOLOv5s_GAM_Anchor √ × √ 0.685 17.2 8754783 200 YOLOv5s_COT_Anchor × √ √ 0.666 15.8 7003743 333.3 YOLOv5s_GAM_COT_Anchor √ √ √ 0.694 17.1 8743007 256.4

[0110] From the experimental results, we can see that the three improvements to the original model proposed above have achieved the improvement of the accuracy of the original YOLOv5s model through mutual combination. Indicators The number of parameters is 256.4, while the FPS is as high as 256.4. The excellent performance of YOLOv5s_GAM_COT_Anchor on the test set verifies the efficiency of the proposed improvement strategy. The present invention names this model YOLOv5s_fire. In general, YOLOv5s_fire improves the backbone network layer of YOLOv5s based on GAMAttention to improve the feature extraction capability; improves its neck layer based on ContextualTransformer to improve the feature aggregation capability of the model; and customizes the petrochemical fire dataset Anchor based on K-means++ to provide prior knowledge for the model, which ultimately improves the detection accuracy and applicability in complex environments in petrochemical fire detection scenarios, meeting the dual requirements of high accuracy and high detection speed in petrochemical fire detection scenarios.

[0111] The following is a description of the information detection module workflow:

[0112] Step 2.1: Load the pre-trained YOLOv5s_Fire fire detection model. This model is trained using a specialized petrochemical fire dataset and adds prior knowledge of petrochemical fire scenes, making it highly adaptable to petrochemical fires.

[0113] Step 2.2: Input the processed image frame into the fire detection model for fire detection. The YOLOv5s_Fire model improves the model's feature extraction and feature aggregation capabilities by combining the GAM Attention and Contextual Transformer structures, thereby enabling more accurate identification of flame features.

[0114] Step 2.3: The model outputs the detected fire information (such as flame location, size, and confidence) in JSON format.

[0115] 3. Early Warning Module

[0116] The early warning module is responsible for determining whether to initiate an alarm based on the detection results and sending an alarm signal. The specific steps are as follows:

[0117] Step 3.1: Compare the fire probability output by the information detection module with the preset threshold to determine whether a fire exists. This threshold can be dynamically adjusted according to the specific application scenario and risk level to balance the false alarm rate and missed alarm rate.

[0118] Step 3.2: If the detected fire probability exceeds the threshold, the system will generate an alarm signal. The alarm system will be activated, sound, light and other warning signals will be emitted, and notifications will be sent to the contact list personnel.

[0119] 4. Display Module

[0120] The display module provides an intuitive visual interface, enabling users to monitor in real time and quickly respond to fire events, improving the practicality and ease of use of the system. The specific steps are as follows:

[0121] Step 4.1: Receive the alarm signal sent by the early warning layer and the detection results in JSON format from the detection layer.

[0122] Step 4.2: Parse and process the received data to generate visualization content, including marking the flame position on the image and displaying key information such as flame area and detection time.

[0123] Step 4.3: Interface display: Display the fire detection results in a visual interface, including the location of the fire (displayed through a map or floor plan), the size of the flame (by marking the flame boundary), the detection time and other information, and highlight the alarm signal. The interface should have a friendly human-computer interaction function, support zooming in and out, historical record query and other operations, and facilitate users to conduct real-time monitoring and post-event analysis.

[0124] 5. Petrochemical Fire Image Dataset

[0125] Deep learning technology relies on a large amount of data support. In order to improve the detection accuracy of the model in petrochemical fire detection scenarios, a fire dataset that includes building scenes such as petrochemical parks, factories, and office buildings is required. The present invention constructs a petrochemical fire dataset that includes fire images and non-fire images. The non-fire images are used to reduce the false positive rate in practical applications and better simulate complex real-world scenes. These non-fire images are negative samples that are very similar to fire images. The background is usually bright colors, such as red and yellow, and has extremely high brightness. Examples of positive and negative samples in the petrochemical fire dataset constructed by the patent of this invention are as follows: Figure 4 shown.

[0126] The steps to construct the petrochemical fire image dataset are:

[0127] 1. Data collection: There are two main methods for collecting data for this invention patent:

[0128] 1. Obtained from public data sets. Currently, the public fire data sets are small in scale and single in scene. Most of them are indoor fires and are not suitable for petrochemical fire fighting scenes. Therefore, it is necessary to manually screen fire images that meet the petrochemical fire building scenes from these data sets.

[0129] 2. Obtain from the Internet, use "petrochemical fire" as the keyword to collect relevant fire pictures on the Internet, and select pictures that meet the scene conditions and save them locally to expand the scale and diversity of the data set.

[0130] (ii) Data cleaning: Considering that some images appear in multiple public datasets, the subtract() function in OpenCV is used to perform pairwise operations on samples in the dataset to remove duplicate images.

[0131] (III) Dataset division and annotation: The present invention randomly divides 5,000 fire images and 2,000 non-fire images in the dataset into training set, validation set and test set in a ratio of 8:1:1. The Labelimg tool in the Python library is used for data annotation. The annotation results are shown in the following example: Figure 5 As shown in the figure, the right side shows the annotation result, and the annotated content is automatically saved in .txt format. The .txt annotation file is converted into the COCO dataset format (xml) through a Python script to facilitate comparative experiments.

[0132] (IV) Dataset analysis: To further analyze the self-built fire dataset, a Python script was used to draw a correlation diagram between the horizontal and vertical coordinates (x, y) and the height and width of the center point, as shown in the figure. Figure 6 As shown, the darker the color in the matrix (1)-(6), the stronger the correlation between the corresponding labels, and the lighter the color, the weaker the correlation. The colors on the diagonal (a)-(d) represent the self-correlation of each label, which is usually the darkest. From (1)-(6), it can be found that the horizontal coordinate x and width width of the center point of the annotation box, and the vertical coordinate y and height height of the center point are highly correlated, where (1) is the position of the annotation center point relative to the entire image, and (6) is the height-to-width ratio of the annotation box relative to the entire image; from (a)-(d), it can be found that the width and height of most annotation boxes are less than half of the entire image, and the horizontal and vertical coordinates of the center point are concentrated in the center of the image, which is close to a normal distribution. Therefore, the petrochemical fire data set built by the patent of this invention has certain rationality.

Claims

1. A method for constructing a model with a petrochemical fire image detection function, the method is based on a YOLOv5s model, which includes an input layer, a backbone network layer, a neck layer, and a head layer connected in sequence according to a signal transmission order, characterized in that: The method includes improving the process of the backbone network layer, improving the process of the neck layer, and improving the process of the head layer; In the process of improving the backbone network layer, the backbone network layer of the YOLOv5s model is improved based on GAM Attention; In the process of improving the neck layer process, the neck layer of the YOLOv5s model is improved based on Contextual Transformer; In the process of improving the head layer, a custom pre-selected box is used to improve the head layer of the YOLOv5s model to control the shape and size of the model prediction bounding box.

2. The method for constructing a model with a petrochemical fire image detection function as claimed in claim 1, characterized in that: In the process of improving the backbone network layer, the GAM Attention unit is added to the backbone network layer of the YOLOv5s model. The unit includes a channel attention subunit and a spatial attention subunit. The GAM Attention unit combines the spatial features and channel features of the image and converts the input feature map into a new output feature map after calculation: Assume that the feature map of the input GAM Attention unit is , then the middle feature map And the feature map of the output GAM Attention unit It can be obtained by the following formula: ; in , They represent the channel attention and spatial attention in the GAM Attention unit respectively.

3. The method for constructing a model with a petrochemical fire image detection function as claimed in claim 2, characterized in that: Two 7x7 convolutional layers are used to integrate spatial information, and the pooling layer is removed.

4. The method for constructing a model with a petrochemical fire image detection function as claimed in claim 2, characterized in that: The reduction rate of the channel attention subunit is 16.

5. The method for constructing a model with a petrochemical fire image detection function as claimed in any one of claims 1 to 4, characterized in that: The custom pre-selection box improves the YOLOv5s head layer as follows: the pre-selection box sizes corresponding to the small-size feature layer are (12, 17), (23, 27), (32, 57), and / or the pre-selection box sizes corresponding to the medium-size feature layer are (61, 41), (67, 105), (121, 73), and / or the pre-selection box sizes corresponding to the large-size feature layer are (159, 151), (330, 266), (808, 641).

6. A petrochemical fire detection system, characterized in that: Including the server and client of the communication connection; The client sets up information collection module and early warning module to collect and organize the locally collected data; The server side is equipped with a petrochemical fire picture database set, an information detection module, and a display module, which are used to perform fire detection on the pictures sent by the client and send the detection results to the client; The information collection module is connected to the camera arranged in the petrochemical scene. The camera transmits the video stream in real time, processes the video collected by the camera, forms the on-site image of the petrochemical scene, and sends it to the information detection module on the server side; The information detection module is used to perform fire detection on the received images and output the detection results; The information detection module adopts a fire detection model constructed by the model construction method with petrochemical fire image detection function as described in any one of claims 1 to 5, wherein the fire detection model comprises an input layer, a backbone network layer, a neck layer, and a head layer connected in sequence; the fire detection model is trained using a petrochemical fire data set, and prior knowledge of petrochemical fire scenes is added; The early warning module is used to determine whether to initiate an alarm based on the detection results and send an alarm signal; The display module is used to visually display the fire situation; The petrochemical fire image dataset contains both fire images and non-fire images.

7. The petrochemical fire detection system according to claim 6, characterized in that: The workflow of the information detection module is: Step 2.1: Load the pre-trained fire detection model; Step 2.2: Input the processed petrochemical fire image frame into the fire detection model for fire detection; Step 2.3: The fire detection model outputs the detected fire information.

8. The petrochemical fire detection system according to claim 7, characterized in that: In step 2.2, the specific steps of the fire detection model for fire detection are: Step 1: The petrochemical fire image is fed into the input layer of the fire detection model; Step 2: The backbone network layer extracts useful features from the input data to form a feature map; Step 3: The neck layer further aggregates the feature maps extracted by the backbone network; Step 4: The head layer performs classification and positioning, and uses the pre-selected box to generate the location and category information of the target from the feature map.

9. The petrochemical fire detection system according to claim 6, characterized in that: The petrochemical fire image dataset contains fire images and non-fire images, and is divided into training set, validation set and test set.

10. The petrochemical fire detection system according to claim 6 or 9, characterized in that: The images in the petrochemical fire image dataset are annotated using the Labelimg tool. The annotated content is automatically saved in txt format, and the txt annotation file is converted into the COCO dataset format through a Python script.