A fire detection method based on dynamic multi-scale attention network
By improving YOLOv7's backbone network and introducing a variety of innovative technologies, the dynamic multi-scale attention network DMANet is built, which solves the problem of insufficient fire feature extraction capability in complex fire scenarios, and improves the accuracy and efficiency of fire detection.
Patent Information
- Application Number
- CN202311439450.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2043-10-31
AI Technical Summary
In complex fire scenes such as factory fires, tunnel fires and other scenarios, the YOLOv7 algorithm lacks the ability to extract fire feature features under smoke interference, resulting in the inability to accurately extract the characteristics of real fire scenes, affecting the speed and accuracy of fire detection.
The fire detection method of dynamic multi-scale attention network is proposed. The backbone network of YOLOv7 is improved through the ODMBRBlock module, the EMA attention mechanism is added, the spatial pyramid pooled FSPPF structure is used, the GELU activation function and dynamic tag allocation strategy are introduced, and the ODConv dynamic convolution is combined with ODConv and α-EIOU loss function, construct a dynamic multi-scale attention network DMANet.
It significantly improves the feature extraction capability of fire scenes, improves detection performance, and reduces casualties and property losses. Compared with the YOLOv7-tiny model, the number of network layers and higher accuracy is obtained when the number of partial parameters increases.
Smart Images

Figure CN117409359B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of fire detection, and in particular to a fire detection method of a dynamic multi-scale attention network. Background Art
[0002] Fire threatens human life and property safety, and in serious cases can cause huge economic losses and casualties. With the rapid economic development, the scale of urban buildings is getting larger and larger, the fire situation is becoming more complicated, and the difficulty of fire fighting is also increasing. The current fire fighting method is still mainly manual fire fighting, and firefighters are often injured or even sacrificed in the process of fire fighting.
[0003] Developing safe and efficient firefighting methods, such as using cameras and other equipment to monitor fires before a fire occurs, and using firefighting robots instead of manual firefighting after a fire occurs, can effectively reduce casualties and property losses. Firefighting robots mainly explore fire conditions through cameras and other equipment. Accurately identifying fire targets based on images is the key to efficient firefighting by firefighting robots. Firefighting robots have high real-time and accuracy requirements for fire target detection. Therefore, research on image-based fire detection methods is of great value.
[0004] ODConv utilizes a novel multi-dimensional attention mechanism and a parallel strategy to learn the complementary attentions of convolutional kernels over four dimensions in the kernel space of any convolutional layer.
[0005] EMA is a novel and efficient multi-scale attention module that preserves the dimensional information on each channel by reshaping some channels into batch dimensions and grouping them into multiple sub-features, so that the spatial semantics are evenly distributed within each sub-feature group.
[0006] FReLU is a simple and effective funnel activation method proposed for image recognition tasks, which extends ReLU and PReLU into a two-dimensional activation method by adding negligible spatial conditioning overhead. In addition, the spatial conditioning captures complex visual layouts through regular convolutions, achieving pixel-level modeling capabilities.
[0007] GELU, or Gaussian Error Linear Unit, is a high-performance neural network activation function. Compared with activation functions such as ReLU, GELU is smoother, which helps to improve the convergence speed and detection accuracy of the training process and can alleviate the problem of neuron death to a certain extent.
[0008] DynamicATSS is a simple and effective label assignment method based on predictable training states. By introducing predictions in label assignment and selecting more high-quality samples with a greater impact on the true value IOU as positive samples, the difference between the classification score and the IOU score can be reduced, and more high-quality bounding boxes can be generated.
[0009] EIOU is an efficient cross-joint loss that explicitly measures the differences between three geometric factors in bounding box regression, namely, overlapping area, center point, and side length. α-IOU, or Alpha-IOU, is used for accurate bounding box regression and object detection. It can provide greater flexibility for the detection head through modulation to achieve bounding box regression accuracy at different scales. In the experiment, better detection performance can be obtained when α is 3.
[0010] AlignMix or AlignMixup is a powerful data augmentation method that can interpolate the target labels of input features. By geometrically aligning two images in feature space, it is possible to interpolate between two sets of features and maintain the position of one set of features while preserving the geometry or pose of one image and the texture of another.
[0011] The YOLOv7 algorithm is a real-time object detector framework and a corresponding model scaling method. YOLOv7 introduces model reparameterization into the network architecture, increasing the training structure in exchange for a smaller reasoning structure while retaining reasoning performance. The backbone network uses the efficient aggregation network ELAN, which uses group convolution to increase the cardinality of the newly added features without changing the original gradient transmission path, combining features from different groups to improve parameter utilization and computational efficiency.
[0012] Although the YOLOv7 algorithm has excellent detection performance, its ability to extract fire features is still insufficient when faced with complex fire scenes such as factory fires, tunnel fires and other scenes with smoke interference, resulting in the inability to accurately extract real fire scene features, affecting the speed and accuracy of fire detection. Summary of the invention
[0013] Purpose of the invention: In response to the problem that the features of fire scenes are easily lost as pointed out in the background technology, the present invention discloses a fire detection method of a dynamic multi-scale attention network, which effectively improves the feature extraction capability of fire scenes, obtains better detection performance, and effectively reduces casualties and property losses.
[0014] Technical solution: The present invention proposes a fire detection method of a dynamic multi-scale attention network, comprising the following steps:
[0015] Step 1: Collect fire data from the Internet, perform data cleaning and data preprocessing to obtain the fire detection dataset F, and perform data enhancement through AlignMix when inputting the model training;
[0016] Step 2: Propose an ODMBRBlock module, which adds a multi-branch residual connection and replaces a conventional convolution with an ODConv full-dimensional dynamic convolution. The ODMBRBlock module is used to improve the ELAN module in YOLOv7-tiny. The EMA attention mechanism is added after the ODMBRBlock module, combined with the MP module, and the ODEMANet backbone network is established to extract features.
[0017] Step 3: Use the spatial pyramid pooling FSPPF structure to replace the original SP structure of YOLOv7-tiny and establish the neck network layer;
[0018] Step 4: Use the GELU activation function to replace the original Leaky ReLU activation function of YOLOv7-tiny;
[0019] Step 5: Introduce the EIOU loss function, combine the α-IOU loss function with the EIOU loss function to obtain the α-EIOU loss function;
[0020] Step 6: Add a dynamic label assignment strategy, namely Dynamic ATSS, to optimize the distribution of positive and negative samples and improve model performance;
[0021] Step 7: Use the auxiliary detection head ODConv to establish a dynamic multi-scale attention network, namely Dynamic Multi-Scale Attention Networks, to obtain the DMANet fire detection model, and use the DMANet fire detection model to detect the fire data images to be detected.
[0022] Furthermore, the specific method of step 1 is:
[0023] Step 1.1: Collect fire scene pictures and videos through the Internet to obtain the original fire picture dataset P1 and the original fire video dataset V1;
[0024] Step 1.2: Clean the original fire image dataset to obtain a cleaned fire image dataset P2, and crop and clean the fire video dataset V1 frame by frame to obtain a cleaned fire video dataset V2;
[0025] Step 1.3: merging the cleaned fire image dataset P2 and the cleaned fire video dataset V2, and then performing data preprocessing to obtain a fire detection dataset F that can be used for training;
[0026] Step 1.4: Use the AlignMix method to perform data enhancement on the fire detection dataset F;
[0027] Step 1.5: Input the fire detection dataset F after data enhancement into the fire detection network for training.
[0028] Furthermore, the specific method of establishing the ODEMANet backbone network to extract features in step 2 is:
[0029] Step 2.1: Define a CBG convolution block, which is a combination of convolution, batch normalization, and GELU activation function;
[0030] Step 2.2: Improve the ELAN module in YOLOv7-tiny by adding ODConv dynamic convolution and defining an ODMBRBlock module, wherein the ODMBRBlock module includes a first branch and a second branch;
[0031] Step 2.3: The first branch is halved in number of channels by a 1×1 CBG convolution block and directly output to Concat splicing. The second branch is divided into the third branch and the fourth branch after passing through the 1×1 CBG convolution block;
[0032] Step 2.4: After the third branch passes through a 3×3 CBG convolution block and two 1×1 CBG convolution blocks, the number of channels remains unchanged and is output to Concat splicing. The fourth branch passes through an ODConv dynamic convolution and then a 3×3 CBG convolution block before being divided into the fifth branch and the sixth branch.
[0033] Step 2.5: After the fifth branch passes through two 1×1 CBG convolution blocks, it is output to Concat splicing, and the sixth branch is directly output to Concat splicing;
[0034] Step 2.6: After the first branch, the third branch, the fifth branch and the sixth branch are concatenated through Concat, they are output after passing through a 1×1 CBG convolution block to obtain the ODMBRBlock module;
[0035] Step 2.7: Add the EMA attention mechanism after the ODMBRBlock module and combine it with the MP module to establish the ODEMANet backbone network for feature extraction.
[0036] Furthermore, the specific method of establishing the neck network layer in step 3 is:
[0037] Step 3.1: Define a CBF convolution block, which is a combination of convolution, batch normalization and FReLU activation function;
[0038] Step 3.2: The feature input first passes through a 1×1 CBF convolution block, and the feature output is concatenated to Concat;
[0039] Step 3.3: The feature output of step 3.2 is simultaneously and continuously passed through three 5×5 maximum pooling layers, and the features are output to Concat splicing respectively;
[0040] Step 3.4: After all feature outputs are concatenated through Concat, they are passed through a 1×1 CBF convolution block, and the number of channels is doubled to obtain a spatial pyramid pooling FSPPF structure;
[0041] Step 3.5: Replace the original SP structure of YOLOv7-tiny with the spatial pyramid pooling FSPPF structure and establish the neck network layer for feature fusion.
[0042] Furthermore, the specific method of step 4 is:
[0043] The calculation method of the GELU is:
[0044] GELU(x)=x*P(X≤x)=x*Φ(x)
[0045] Among them, Φ(x) represents the cumulative distribution function of the normal distribution, and its expression is:
[0046]
[0047] Where erf() represents the Gaussian error function.
[0048] Furthermore, the specific method of step 5 is:
[0049] Step 5.1: First, introduce the EIOU loss function, whose formula is:
[0050]
[0051] Among them, L IOU is the overlap loss between the predicted box and the true value box, L dis is the center distance loss between the center point of the predicted box and the true value box, L asp is the width and height loss of the bounding box, b and b gt Represent the center points of the predicted box and the true value box, w, h and w respectively gt ,h gt Represents the width and height of the prediction box and the true value box respectively, w c and h c is the width and height of the minimum enclosing rectangle of the prediction box and the true value box, and ρ(x, y) is the Euclidean distance between the two points;
[0052] Step 5.2: Then in L IOU = Using Box-Cox variation on 1-IOU, we get α-IOU loss:
[0053]
[0054] Combining α-IOU with EIOU, the formula for the α-EIOU loss function is:
[0055]
[0056] Furthermore, the specific method of adding the dynamic label allocation strategy in step 6 is:
[0057] Step 6.1: Introduce the prediction to the anchor point of the label assignment, combine the predicted IOU of the predicted box with the true value box and the anchor point IOU of the anchor point box with the true value box to select the positive sample. The combination formula is as follows:
[0058] CIOUs=PIOUs+AIOUs
[0059] mean(CIOUs)=mean(PIOUs)+mean(AIOUs)
[0060] std(CIOUs)=std(PIOUs)+std(AIOUs)
[0061] threshold(CIOUs)=mean(CIOUs)+std(CIOUs)
[0062] Among them, PIOUs is the predicted IOU between the predicted box and the true value box, AIOUs is the anchor IOU between the predefined anchor box and the true value box, CIOUs represents the combined IOUs, that is, the sum of the predicted IOU and the anchor IOU, mean() represents the mean, std() represents the standard deviation, and threshold() represents the threshold;
[0063] Step 6.2: When calculating the mean and standard deviation of CIOUs, calculate the mean and standard deviation of PIOUs and AIOUs respectively and add them together;
[0064] Step 6.3: Finally, the threshold of CIOUs is calculated by the sum of the mean and standard deviation of CIOUs.
[0065] Furthermore, the specific method of step 7 is:
[0066] Step 7.1: Add auxiliary head to the detection head part to assist training;
[0067] Step 7.2: The auxiliary head uses ODConv dynamic convolution to replace the ordinary convolution layer;
[0068] Step 7.3: Establish a dynamic multi-scale attention network, put the fire detection dataset F in step 1 into the DMANet fire detection network for training, and obtain the DMANet fire detection model;
[0069] Step 7.4: Put the fire data to be detected into the DMANet fire detection model to obtain the detection results.
[0070] Beneficial effects:
[0071] 1. The present invention first improves the backbone network of YOLOv7 and uses ODMBRBlock to optimize the ELAN module. The ELAN module controls the length of the gradient path to make the deep network learn and converge more effectively; the ODMBRBlock module increases the feature learning depth by adding multi-branch residual connections, and replaces a conventional convolution with an ODConv full-dimensional dynamic convolution, which enables the ODMBRBlock module to significantly improve the feature extraction capability and improve the model performance without increasing the number of model parameters; the EMA attention mechanism is introduced, and by grouping the channel dimensions, the established ODEMANet backbone network can reduce the feature loss problem caused by channel dimensionality reduction, while reducing the number of model parameters and computational costs.
[0072] 2. Secondly, a spatial pyramid pooling FSPPF structure is proposed in the bottleneck network Neck part to effectively avoid image distortion caused by cropping and scaling of image areas. Pooling operations are performed through multiple sliding windows to extract features from feature maps at different sizes, ignoring the influence of different input image sizes and generating a fixed-length output size, thereby increasing the richness of the extracted features.
[0073] 3. Then, the EIOU loss function and the α-IOU loss function are combined in the IOU loss function to obtain the α-EIOU loss function. By adjusting α, the detection head can more flexibly achieve bounding box regression accuracy of different scales. At the same time, EIOU provides faster convergence speed and better positioning results, so that α-EIOU can obtain higher detection accuracy.
[0074] 4. Finally, an ODConv auxiliary head is added to the detection head to improve the detection accuracy while only increasing the training cost. At the same time, a dynamic label allocation strategy is added to optimize the positive and negative sample allocation strategy to obtain higher model performance.
[0075] 5. Experiments have shown that the method of the present invention effectively increases the feature extraction capability of fire scenes. Compared with the YOLOv7-tiny model, a deeper network layer is obtained with only a partial increase in the number of parameters, and the accuracy is also effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 It is an overall flow chart of a fire detection method of a dynamic multi-scale attention network in the present invention;
[0077] Figure 2 This is a structural diagram of the dynamic multi-scale attention network fire detection model in the present invention;
[0078] Figure 3 Schematic diagram of ODConv full-dimensional dynamic convolution in the present invention;
[0079] Figure 4 It is the structural diagram of the ODMBRlock module in the present invention;
[0080] Figure 5 Schematic diagram of the EMA attention module in the present invention;
[0081] Figure 6 It is a schematic diagram of the ODEMANet backbone network in the present invention;
[0082] Figure 7 Schematic diagram of the spatial pyramid pooling FSPPF structure in the present invention;
[0083] Figure 8 The test results of the fire detection dataset F in the YOLOv7-tiny model;
[0084] Fig. 9 It is the test result of the fire detection data set F in the DMANet fire detection model of the present invention. DETAILED DESCRIPTION
[0085] The present invention is further explained below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.
[0086] The present invention proposes a fire detection method based on a dynamic multi-scale attention network, comprising:
[0087] Step 1: Collect fire data from the Internet, perform data cleaning and data preprocessing, and obtain the fire detection data set F. When inputting the model training, data enhancement is performed through AlignMix. The specific method is as follows:
[0088] Step 1.1: Collect fire scene pictures and videos through the Internet to obtain the original fire picture dataset P1 and the original fire video dataset V1.
[0089] Step 1.2: Perform data cleaning on the original fire image dataset, including deduplication and irrelevant removal, to obtain a cleaned fire image dataset P2. Meanwhile, perform frame-by-frame cropping and data cleaning on the fire video dataset V1 to obtain a cleaned fire video dataset V2.
[0090] Step 1.3: Perform data preprocessing on the cleaned fire image dataset P2 and the cleaned fire video dataset V2, and merge the datasets P2 and V2 to obtain a preprocessed fire dataset P3.
[0091] Step 1.4: Perform preprocessing operations such as data labeling on the preprocessed fire data set P3 to obtain a fire detection data set F that can be used for training.
[0092] Step 1.5: Use the AlignMix method to perform data enhancement on the fire detection dataset F. AlignMix takes into account the quality of the fused image and proposes to align the positions of the two images in the feature space and then make a difference at the corresponding positions to achieve higher quality image fusion.
[0093] Step 1.6: Input the data augmented dataset F into the fire detection network for training.
[0094] Step 2: Propose the ODMBRBlock module, add the EMA attention mechanism, combine it with the MP structure, and establish the ODEMANet backbone network to extract features. The specific method is as follows:
[0095] Step 2.1: Define a CBG convolution block, which is a combination of convolution, batch normalization, and GELU activation function.
[0096] Step 2.2: Improve the ELAN module in YOLOv7-tiny and add ODConv dynamic convolution. For the structure diagram of ODConv dynamic convolution, see Figure 3 . Define the ODMBRlock module, see Figure 4 , whose structure includes a first branch and a second branch.
[0097] Step 2.3: The first branch is halved in number of channels by a 1×1 CBG convolution block and directly output to Concat concatenation. The second branch is divided into the third branch and the fourth branch after passing through the 1×1 CBG convolution block.
[0098] Step 2.4: After the third branch passes through a 3×3 CBG convolution block and two 1×1 CBG convolution blocks, the number of channels remains unchanged and is output to Concat splicing. The fourth branch passes through an ODConv dynamic convolution and then a 3×3 CBG convolution block before being divided into the fifth branch and the sixth branch.
[0099] Step 2.5: After the fifth branch passes through two 1×1 CBG convolution blocks, it is output to Concat splicing, and the sixth branch is directly output to Concat splicing.
[0100] Step 2.6: Concatenate the first branch, the third branch, the fifth branch and the sixth branch through Concat, and then output them after passing through a 1×1 CBG convolution block to obtain the ODMBRBlock module.
[0101] Step 2.7: Add the EMA attention mechanism after the ODMBRBlock module, combine it with the MP module, and build the ODEMANet backbone network for feature extraction. For details, see Figure 5 and Figure 6 , Figure 5 This is the structure diagram of the EMA attention mechanism. Figure 6 Schematic diagram of ODEMANet backbone network.
[0102] Step 3: Use the spatial pyramid pooling FSPPF structure to build the neck network layer, see Figure 7 , the specific method is:
[0103] Step 3.1: Define a CBF convolution block, which is a combination of convolution, batch normalization, and FReLU activation function.
[0104] Step 3.2: Take the features extracted by the ODEMANet backbone network as input, first pass through a 1×1 CBF convolution block, and then output the features to Concat concatenation.
[0105] Step 3.3: The feature output of step 3.2 passes through three 5×5 maximum pooling layers simultaneously and continuously, and the features are output to Concat concatenation respectively.
[0106] Step 3.4: After all the feature outputs are concatenated through Concat, they are passed through a 1×1 CBF convolution block, and the number of channels is doubled to obtain a spatial pyramid pooling FSPPF structure.
[0107] Step 3.5: Replace the original SP structure of YOLOv7-tiny with the spatial pyramid pooling FSPPF structure and establish the neck network layer for feature fusion.
[0108] Step 4: Use the GELU activation function to replace the original Leaky ReLU activation function. The specific method is:
[0109] Replace the original Leaky ReLU activation function of YOLOv7-tiny with the GELU activation function. The calculation method of GELU is:
[0110] GELU(x)=x*P(X≤x)=x*Φ(x)
[0111] Among them, Φ(x) represents the cumulative distribution function of the normal distribution, and its expression is:
[0112]
[0113] erf() represents the Gaussian error function, which can be calculated by approximation:
[0114]
[0115] Among them, tanh() is the hyperbolic tangent function. To simplify the calculation process, the following formula can be used:
[0116] xσ(1.702x)
[0117] For approximate calculations, σ is taken as 1.
[0118] Step 5: Introduce the EIOU loss function, combine the α-IOU loss function with the EIOU loss function to obtain the α-EIOU loss function. The specific method is:
[0119] Step 5.1: First, introduce the EIOU loss function, whose formula is:
[0120]
[0121] Among them, L IOU is the overlap loss between the predicted box and the true value box, L dis is the center distance loss between the center point of the predicted box and the true value box, L asp is the width and height loss of the bounding box, b and b gt Represent the center points of the predicted box and the true value box, w, h and w respectively gt ,h gt Represents the width and height of the prediction box and the true value box respectively, w c and h c is the width and height of the minimum enclosing rectangle of the prediction box and the true value box, and ρ(x, y) is the Euclidean distance between the two points;
[0122] Step 5.2: Then introduce the α-IOU loss function, in L IOU =1-IOU using Box-Cox change to get the α-IOU loss function formula:
[0123]
[0124] Combine the α-IOU loss function with EIOU, that is, in L EIOU =L IOU +Ldis +L asp Using the Box-Cox variation, the formula for the α-EIOU loss function is:
[0125]
[0126] In practical applications, the performance is better when the α value is 3.
[0127] Step 6: Add a dynamic label assignment strategy, namely Dynamic ATSS, to optimize the distribution of positive and negative samples and improve model performance. The specific method is as follows:
[0128] Step 6.1: Add a dynamic label assignment strategy, introduce the prediction into the anchor point of label assignment, combine the predicted IOU of the predicted box with the true value box and the anchor point IOU of the anchor point box with the true value box to select positive samples. The combination formula is as follows:
[0129] CIOUs=PIOUs+AIOUs
[0130] mean(CIOUs)=mean(PIOUs)+mean(AIOUs)
[0131] std(CIOUs)=std(PIOUs)+std(AIOUs)
[0132] threshold(CIOUs)=mean(CIOUs)+std(CIOUs)
[0133] Where PIOUs is the predicted IOU between the predicted box and the true value box, AIOUs is the anchor IOU between the predefined anchor box and the true value box, CIOUs represents the combined IOUs, that is, the sum of the predicted IOU and the anchor IOU, mean() represents the mean, std() represents the standard deviation, and threshold() represents the threshold.
[0134] Step 6.2: When calculating the mean and standard deviation of CIOUs, calculate the mean and standard deviation of PIOUs and AIOUs separately and add them together.
[0135] Step 6.3: Finally, the threshold of CIOUs is calculated by the sum of the mean and standard deviation of CIOUs.
[0136] Step 7: Use the auxiliary detection head ODConv to establish a dynamic multi-scale attention network, namely Dynamic Multiscale Attention Networks, and obtain the DMANet fire detection model. The specific method is as follows:
[0137] Step 7.1: Add auxiliary head to assist training in the detection head part.
[0138] Step 7.2: The auxiliary head uses ODConv dynamic convolution to replace the ordinary convolution layer, which only increases the training cost and improves the feature extraction ability of the network.
[0139] Step 7.3: Based on the above method, a dynamic multi-scale attention network is established, and the fire detection dataset F is put into the above DMANet fire detection network for training to obtain the DMANet fire detection model. The specific process is as follows:
[0140] First, the fire detection dataset F is divided into training set and test set in a ratio of 7:3, and then the training set is divided into training set and validation set in a ratio of 9:1. The size of the input image is set to 640×640, the batch size is set to 8 and the training generation is set to 300. The dataset is loaded into the DMANet fire detection network for training to obtain the DMAnet fire detection model. Secondly, in the network training stage, the detailed steps of each module are as follows:
[0141] (1) The backbone network ODEMANet mainly extracts features from the input image. The first two convolutional layers are used to downsample the input image and increase the number of channels, increasing the RGB three-dimensional channels of the input image to 32-dimensional channels and 64-dimensional channels. Then there are three groups of ODMBRBlock modules and EMA attention and MP combination modules. Each module group halves the size of the feature map and doubles the number of channels. Finally, there is an ODMBRBlock module to obtain a 20×20×512 feature output map.
[0142] (2) The bottleneck network layer Neck is mainly used to construct a feature pyramid, which helps the model obtain multi-scale fire scene features. The feature map output by the backbone network enters the spatial pyramid pooling FSPPF structure and performs spatial pyramid pooling operations, which can effectively avoid image distortion problems caused by image region cropping and scaling operations, improve the speed of generating candidate frames, and save computing costs. FSPPF uses FReLU as the activation function and four parallel maximum pooling operations of 1, 5, 9, and 13. It can perform Pooling operations on sliding windows of different scales and extract features on feature maps of different sizes, increasing the richness of feature extraction; using the feature pyramid network structure, the feature branches output by the ODMBRlock module in the backbone network are feature fused to obtain multi-scale fire scene features, and upsampling is added to increase the resolution of the image.
[0143] (3) The detection head is responsible for the final detection step. The ODConv auxiliary head is added to increase the training cost so that the real-time detector can improve the detection accuracy without increasing the inference cost. The fire scene features output by the bottleneck network are classified and identified, the fire prediction box is extracted, the final feature output vector is obtained, the prediction result is generated, and the fire location and occurrence probability are determined.
[0144] Step 7.4: Put the fire data to be detected into the DMANet fire detection model to obtain the detection results.
[0145] It can be seen from Table 1 that the fire detection method of the present invention has shown excellent performance on fire datasets where complex fire scene features are difficult to identify. This method can effectively extract complex fire scene features by improving the ODMRBlock module and adding the ODEMANet feature extraction network constructed by the EMA attention mechanism. At the same time, the FSPPF spatial pyramid pooling module and the GELU activation function are added to solve the problem of feature loss and increase feature richness. Finally, the ODConv dynamic auxiliary head is added to improve detection accuracy. Finally, compared with the YOLOv7-tiny model, the obtained DMANet fire detection model has a deeper network layer and a greatly improved accuracy rate while only partially increasing the number of parameters. For details, see Figure 8 and Fig. 9 comparison.
[0146] Table 1
[0147]
[0148] Related vocabulary or variable description:
[0149]
[0150]
[0151]
Claims
1. A fire detection method based on a dynamic multi-scale attention network, characterized in that: The steps include: Step 1: Collect fire data from the Internet, perform data cleaning and data preprocessing to obtain the fire detection data set F, and perform data enhancement through AlignMix when inputting the model training; Step 2: Propose an ODMBRBlock module, which adds a multi-branch residual connection and replaces a conventional convolution with an ODConv full-dimensional dynamic convolution. The ODMBRBlock module is used to improve the ELAN module in YOLOv7-tiny. The EMA attention mechanism is added after the ODMBRBlock module, combined with the MP module, and the ODEMANet backbone network is established to extract features. Step 2.1: Define a CBG convolution block, which is a combination of convolution, batch normalization, and GELU activation function; Step 2.2: Improve the ELAN module in YOLOv7-tiny by adding ODConv dynamic convolution and defining an ODMBRBlock module, wherein the ODMBRBlock module includes a first branch and a second branch; Step 2.3: The first branch is halved in number of channels by a 1×1 CBG convolution block and directly output to Concat splicing. The second branch is divided into the third branch and the fourth branch after passing through the 1×1 CBG convolution block; Step 2.4: After the third branch passes through a 3×3 CBG convolution block and two 1×1 CBG convolution blocks, the number of channels remains unchanged and is output to Concat splicing. The fourth branch passes through an ODConv dynamic convolution and then a 3×3 CBG convolution block before being divided into the fifth branch and the sixth branch. Step 2.5: After the fifth branch passes through two 1×1 CBG convolution blocks, it is output to Concat splicing, and the sixth branch is directly output to Concat splicing; Step 2.6: After the first branch, the third branch, the fifth branch and the sixth branch are concatenated through Concat, they are output after passing through a 1×1 CBG convolution block to obtain the ODMBRBlock module; Step 2.7: Add the EMA attention mechanism after the ODMBRBlock module and combine it with the MP module to establish the ODEMANet backbone network for feature extraction; Step 3: Use the spatial pyramid pooling FSPPF structure to replace the original SP structure of YOLOv7-tiny and establish the neck network layer; Step 3.1: Define a CBF convolution block, which is a combination of convolution, batch normalization and FReLU activation function; Step 3.2: The feature input first passes through a 1×1 CBF convolution block, and the feature output is concatenated to Concat; Step 3.3: The feature output of step 3.2 is simultaneously and continuously passed through three 5×5 maximum pooling layers, and the features are output to Concat splicing respectively; Step 3.4: After all feature outputs are concatenated through Concat, they are passed through a 1×1 CBF convolution block, and the number of channels is doubled to obtain a spatial pyramid pooling FSPPF structure; Step 3.5: Replace the original SP structure of YOLOv7-tiny with the spatial pyramid pooling FSPPF structure, and establish the neck network layer for feature fusion; Step 4: Use the GELU activation function to replace the original Leaky ReLU activation function of YOLOv7-tiny; Step 5: Introduce the EIOU loss function, combine the α-IOU loss function with the EIOU loss function to obtain the α-EIOU loss function; Step 6: Add a dynamic label assignment strategy, namely Dynamic ATSS, to optimize the distribution of positive and negative samples and improve model performance; Step 7: Use the auxiliary detection head ODConv to establish a dynamic multi-scale attention network, namely Dynamic Multi-Scale Attention Networks, to obtain the DMANet fire detection model, and use the DMANet fire detection model to detect the fire data images to be detected.
2. The fire detection method of a dynamic multi-scale attention network according to claim 1 is characterized in that: The specific method of step 1 is: Step 1.1: Collect fire scene pictures and videos through the Internet to obtain the original fire picture dataset P1 and the original fire video dataset V1; Step 1.2: Clean the original fire image dataset to obtain a cleaned fire image dataset P2, and crop and clean the fire video dataset V1 frame by frame to obtain a cleaned fire video dataset V2; Step 1.3: merging the cleaned fire image dataset P2 and the cleaned fire video dataset V2, and then performing data preprocessing to obtain a fire detection dataset F that can be used for training; Step 1.4: Use the AlignMix method to perform data enhancement on the fire detection dataset F; Step 1.5: Input the fire detection dataset F after data enhancement into the fire detection network for training.
3. The fire detection method of a dynamic multi-scale attention network according to claim 1 is characterized in that: The specific method of step 4 is: The calculation method of the GELU is: Among them, Φ(x) represents the cumulative distribution function of the normal distribution, and its expression is: Where erf() represents the Gaussian error function.
4. The fire detection method of a dynamic multi-scale attention network according to claim 1 is characterized in that: The specific method of step 5 is: Step 5.1: First, introduce the EIOU loss function, whose formula is: Among them, L IOU is the overlap loss between the predicted box and the true value box, L dis is the center distance loss between the center point of the predicted box and the true value box, L asp is the width and height loss of the bounding box, b and b gt Represent the center points of the predicted box and the true value box, w, h and w respectively gt ,h gt Represents the width and height of the prediction box and the true value box respectively, w c and h c is the width and height of the minimum enclosing rectangle of the prediction box and the true value box, and ρ(x,y) is the Euclidean distance between the two points; Step 5.2: Then in L IOU = Using Box-Cox variation on 1-IOU, we get α-IOU loss: Combining α-IOU with EIOU, the formula for the α-EIOU loss function is:
5. The fire detection method of a dynamic multi-scale attention network according to claim 1 is characterized in that: The specific method of adding the dynamic label allocation strategy in step 6 is: Step 6.1: Introduce the prediction to the anchor point of the label assignment, combine the predicted IOU of the predicted box with the true value box and the anchor point IOU of the anchor point box with the true value box to select the positive sample. The combination formula is as follows: CIOUs=PIOUs+AIOUs mean(CIOUs)=mean(PIOUs)+mean(AIOUs) std(CIOUs)=std(PIOUs)+std(AIOUs) threshold(CIOUs)=mean(CIOUs)+std(CIOUs) Among them, PIOUs is the predicted IOU between the predicted box and the true value box, AIOUs is the anchor IOU between the predefined anchor box and the true value box, CIOUs represents the combined IOUs, that is, the sum of the predicted IOU and the anchor IOU, mean() represents the mean, std() represents the standard deviation, and threshold() represents the threshold; Step 6.2: When calculating the mean and standard deviation of CIOUs, calculate the mean and standard deviation of PIOUs and AIOUs respectively and add them together; Step 6.3: Finally, the threshold of CIOUs is calculated by the sum of the mean and standard deviation of CIOUs.
6. The fire detection method of a dynamic multi-scale attention network according to claim 1 is characterized in that: The specific method of step 7 is: Step 7.1: Add auxiliary head to the detection head part to assist training; Step 7.2: The auxiliary head uses ODConv dynamic convolution to replace the ordinary convolution layer; Step 7.3: Establish a dynamic multi-scale attention network DMANet, put the fire detection dataset F in step 1 into the dynamic multi-scale attention network DMANet for training, and obtain a DMANet fire detection model; Step 7.4: Put the fire data to be detected into the DMANet fire detection model to obtain the detection results.
Citation Information
Patent Citations
Fire detection early warning method based on attention mechanism and multi-scale characteristics
CN116343077A
Flame detection method based on MPGD-YOLO network
CN116758393A
