Early fire smoke detection method and system based on improved YOLOv9 algorithm
By improving the YOLOv9 algorithm and combining the RepVGG-GELAN module and the multi-scale attention module, the YOLO algorithm solves the problems of low small target detection accuracy and high false alarm rate in early fire smoke detection, achieving high accuracy and rapid detection effects.
Patent Information
- Application Number
- CN202410856292.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-18
AI Technical Summary
The existing YOLO algorithm has problems such as low detection accuracy of small targets, high false alarm rate, and limited dynamic response capabilities in fire smoke detection. It is especially difficult to accurately identify smoke features in early fire detection.
Improve the YOLOv9 algorithm by introducing the RepVGG-GELAN module, gating mechanism, DRNS module, dual-level attention mechanism and multi-scale attention module, combined with wavelet noise reduction processing and dynamic threshold determination, to enhance feature extraction and detection accuracy, and improve early detection Fire smoke sensitivity and accuracy.
It significantly improves the accuracy and robustness of early fire smoke detection, reduces the rate of false alarms and false alarms, improves the detection performance of small targets, achieves fast and real-time fire smoke detection, and adapts to the smoke detection needs of different scenarios.
Smart Images

Figure CN118799805A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a fire smoke detection method, and in particular to an early fire smoke detection method and system based on an improved YOLOv9 algorithm. Background Art
[0002] With the rapid development of artificial intelligence (AI), particularly breakthroughs in deep learning, computer vision-based fire smoke detection technology has begun to emerge. The YOLO family of algorithms, as a representative example, demonstrates great potential in video surveillance applications with its exceptional real-time performance and accuracy. YOLO (You Only Look Once) is a single-stage object detection algorithm that simultaneously locates and classifies objects in a single neural network forward pass, significantly improving detection speed and reducing computational resource consumption. However, while the YOLO algorithm performs well in general object detection tasks, its performance in the specific and complex context of fire smoke remains to be improved. Smoke, as a non-rigid object with irregular shapes and fuzzy boundaries in natural environments, poses significant challenges to algorithms. For example, small objects are difficult to detect. In the early stages of a fire, smoke is often thin and diffuse, small in size, and easily obscured by the background, placing higher demands on the algorithm's sensitivity and resolution. It also has poor adaptability to dynamic changes. The rapid diffusion rate and shape of smoke require algorithms to possess strong dynamic adaptability and the ability to effectively process time series data. In addition, different lighting conditions, background complexity, and changes in smoke color and transparency may affect the stability and accuracy of the algorithm.
[0003] The existing invention patent document, "Fire Detection Method Based on PD-YOLO," with publication number CN117333753A, discloses a fire detection method based on PD-YOLO. However, this technology is not sensitive enough to identify the subtle features of early-stage fire smoke and may cause false alarms due to other environmental factors, such as cooking fumes, dust, humidity, and other non-fire factors. Its recognition rate and positioning accuracy need to be improved. Traditional YOLO models may miss detections due to small, weak smoke features and blurred boundaries, resulting in low accuracy in early-stage small target detection. Therefore, existing technologies are prone to missing detections in the early stages of a fire, have limited dynamic response capabilities to changes in smoke concentration, and lack comprehensive and accurate fire detection. Summary of the Invention
[0004] Purpose of the invention: To address the above problems, the present invention proposes an early fire smoke detection method and system based on an improved YOLOv9 algorithm, which can improve the sensitivity and accuracy of smoke detection and enhance the ability to capture early fire smoke characteristics.
[0005] Technical solution: The technical solution adopted by the present invention is an early fire smoke detection method based on an improved YOLOv9 algorithm, which specifically includes the following steps:
[0006] Step 1: Collect smoke signals and image data from the relevant monitoring scene. The camera receives the video stream signal and captures the recorded video frame by frame. The training set contains 15,630 images, the validation set contains 1,500 images, and the test set contains 1,500 images.
[0007] Step 2: Perform image preprocessing at the model input. Compare the acquired smoke signals and perform noise reduction on the acquired images.
[0008] Dynamic thresholding and continuous frame fusion are used to compare collected data to address complex backgrounds. Dynamic thresholding strategies can be constructed by combining the ARIMA (Autoregressive Integrated Moving Average) model of time series analysis with anomaly detection algorithms. Continuous frame fusion technology uses a weighted moving average (WMA) to fuse smoke detection results from consecutive frames.
[0009] Image denoising is performed using wavelet denoising.
[0010] Specifically, image preprocessing involves dynamic thresholding and continuous frame fusion. The process involves the following: First, dynamic thresholding is applied to each captured image frame to identify areas where smoke may be present. Next, smoke detection is performed on these areas across multiple consecutive frames to obtain a result. Finally, the smoke detection results from these multiple frames are fused for a final judgment. This multi-frame analysis improves detection accuracy and reduces false alarms. This comparison allows for a more accurate determination of fire smoke. If smoke is detected, the corresponding alarm system is triggered, allowing for further processing.
[0011] The construction of the dynamic threshold in the dynamic threshold determination includes: predicting the smoke concentration at the future moment through the autoregressive integral moving average model; the continuous frame fusion technology uses the weighted moving average to fuse the smoke detection results of the continuous frames, and the calculation formula is:
[0012]
[0013] Among them, S t is the fused smoke detection signal, D t-i Indicates the detection result of the ti-th frame, w i It is a dynamic weight calculated based on the rate of change of smoke concentration between the current frame and the previous i frames. The larger the rate of change, the higher the weight, so as to reflect the dynamics of smoke in a timely manner.
[0014] The image denoising process in the image preprocessing adopts wavelet denoising, including:
[0015] In the subspace of wavelet domain distribution, let f x and f y The Riesz transform image in the wavelet scale x and y directions is used to decompose the local features of the image using the pixel values in the single direction in the wavelet domain. The principal component feature distribution matrix Q is constructed in the N×N local area. i Is f x The PCA principal components corresponding to fy, the local block binary pattern of the image is expressed as:
[0016] Q i =U i S i V i T =U i S i [v1 v2] f
[0017] Among them: [v1v2] is a vector group, v1=[v 11 ,v 12 ] represents the horizontal concatenation of a set of vectors; U i is an orthogonal matrix containing left singular vectors; S i is a diagonal matrix containing singular values; f is the Riesz transform image.
[0018] Wavelet decomposition is used in combination with Log-gabor filter to filter out the redundant information of the local main direction in the image at a certain scale, and the phase reference value of the main direction is obtained as follows:
[0019]
[0020] The matrix S is used to represent the information of the image in the high-frequency band. The distribution function in the main direction of the local block can be expressed as:
[0021]
[0022] Where σ is the regularization parameter, P is the distribution function, s1 and s2 are two eigenvalues. VR imaging technology is combined to enhance image information and suppress the influence of noise. For an input image of size n×m, the local energy distribution conversion method is used to obtain R b ×R b The main direction of the image block of size, the main direction component map model after information enhancement is:
[0023]
[0024] After determining the main direction of the image pixels in the local binary pattern, since θ∈[-π / 2,π / 2], the wavelet features and local binary pattern are used to improve the robustness of imaging, and the image pixel projection area is evenly quantized into T intervals, which can be expressed as:
[0025]
[0026] Among them, θ′ n,m is the n,m The updated value, θ n,m Represents an angle, this formula means that when θ n,m When it falls within the given range, θ′ n,m The value is updated to t, where T is an interval number used to adjust the magnitude of the angle, and t = 0, 1, ... T-1 is the main component area after the image pixel vector is quantized.
[0027] Step 3: Improve the YOLOv9 model;
[0028] Build a YOLOv9 network model. The YOLOv9 network includes a feature extraction network, a feature fusion network, and a detection head. The improvements include:
[0029] (1) In the feature extraction network of the original YOLOv9 algorithm, the Conv convolution module is replaced with the RepVGG-GELAN module, and a gating mechanism is introduced to enhance the interactivity between features, thereby better extracting fire smoke features. The RepVGG-GELAN module is an improved module based on RepVGG and GELAN technologies, aiming to improve the representation ability and inference efficiency of the model. By combining the efficient convolution structure of RepVGG and the attention mechanism of GELAN, the RepVGG-GELAN module provides a network module that is simple and efficient during inference and powerful during training. This design not only improves the performance of the model, but also enhances the feature representation capability while maintaining efficient inference. In addition, a gating mechanism is introduced to adjust the attention weight so that it can dynamically focus on features in different regions. Gated attention fusion realizes dynamic weighting of source feature maps and target feature maps to emphasize key information and suppress noise. Bilinear interpolation is added after the RepVGG-GELAN module to enhance the interactivity between features, and more refined control is achieved through the gating unit. The attention-weighted features are fused with the features after the convolution operation, and finally a feature map enhanced by the attention mechanism is output.
[0030] (2) A new DRNS module is designed on the backbone network of YOLOv9. The high-precision large convolution kernel DilatedReparam Block module is combined with RepNCSPELAN4. It can reduce memory access and redundant calculations while extracting spatial features, accelerate the inference time of the model, and reduce the delay time of the model on the terminal device.
[0031] (3) Based on (2), the model is further improved by designing a module (BSAM) that combines a two-level attention mechanism and spatial attention between the feature extraction network and the feature fusion network. This can enhance the model's feature representation capability and detection accuracy, and improve the robustness and accuracy of fire smoke detection. A Convolutional Block Attention Module (CBAM), whose original structure includes a Channel Attention Module and a Spatial Attention Module. The Channel Attention Module is replaced with a two-level attention module (BiLevel Attention), forming a new attention module BSAM (BiLevel Spatial Attention Module).
[0032] The combination of these two levels of attention mechanisms (dual-level attention and spatial attention) can better capture information at different levels of features, effectively enhance the representation ability of smoke features, and thus improve the performance of the model in early fire smoke detection.
[0033] (4) In the feature fusion module of YOLOv9, the C2f structure and multi-scale attention module MSAM in YOLOv8 are integrated into the neck part of the YOLOv9 model to enhance the ability to capture multi-scale features and improve the accuracy of feature extraction and target detection.
[0034] The C2f architecture consists of two convolutional layers and a residual connection module. The Multiscale Attention Module (MSAM) effectively enhances the model's ability to perceive multi-scale objects by weightedly fusing features at different scales. Specifically, the MSAM module uses multiple parallel convolutional layers to process feature maps at different scales. It then uses an attention mechanism to perform a weighted summation of these feature maps to generate fused features. Finally, these fused features are element-wise added to the input features to form the output of the C2f architecture.
[0035] In the neck of the YOLOv9 model, we define two convolutional layers and a concat operation to process feature maps extracted from different layers. These feature maps are concatenated along the channel dimension and then fed into a C2f structure containing an MSAM module for further feature extraction and fusion. This improved neck structure provides a more efficient and accurate feature extraction method. By enhancing the ability to process multi-scale features, it improves the accuracy and robustness of fire smoke detection. This significantly enhances the performance of the object detection model in complex scenarios.
[0036] In order to more comprehensively capture the multi-dimensional information of smoke and improve detection accuracy, a dimension-aware selective integration module (DASFM) is designed after the feature map is output from the NECK module and then output to the detection head. The DASFM module first separates the input features into channel and spatial dimensions, and extracts features from these two dimensions through two parallel branches. Then, an attention mechanism is used to perform a weighted summation of the extracted features to generate fused features. DASFM can dynamically adjust the weights of different features, making the feature fusion process more flexible and adaptable to the smoke detection needs in different scenarios. It can not only significantly enhance the effectiveness and adaptability of feature map fusion, but also enable the YOLOv9 model to demonstrate higher accuracy, robustness, and generalization capabilities when facing a variety of smoke detection tasks.
[0037] (5) To improve the network loss function, a new adaptive threshold focus loss function ATFL is proposed to decouple the target and background, and use an adaptive mechanism to adjust the loss weight, forcing the model to allocate more attention to the target features, thereby improving the detection performance of small targets in early fire smoke.
[0038] Step 4: Train the improved YOLOv9 model;
[0039] When collecting the dataset used in the model training process, it is necessary to collect more high-quality fire smoke images, smoke images in different environments, different time periods, different concentrations, and different fire conditions; and use different datasets to train the model and evaluate the model's performance.
[0040] The present invention proposes an early fire smoke detection system based on an improved YOLOv9 algorithm, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the early fire smoke detection method based on the improved YOLOv9 algorithm is implemented.
[0041] The present invention provides a computer program product, comprising a computer program and / or instructions, which, when executed by a processor, implements the early fire smoke detection method based on the improved YOLOv9 algorithm.
[0042] Beneficial effects: Compared with the existing technology, the present invention has the following advantages: (1) The YOLOv9 model is improved by replacing the Conv convolution module with the RepVGG-GELAN module, and introducing a gating mechanism to achieve more refined control. Bilinear interpolation is added after the module to enhance the interactivity between features and better extract fire smoke features. By designing a new DRNS module on the backbone network, using a high-precision large convolution kernel Dilated Reparam Block module combined with RepNCSPELAN4, and designing a module BSAM combining a two-level attention mechanism and spatial attention between the feature extraction network and the feature fusion network, the feature representation ability and detection accuracy of the model are enhanced, and the robustness and accuracy of early fire smoke small target detection are improved. By integrating the C2f structure and multi-scale attention module MSAM in YOLOv8 into the neck part of the YOLOv9 model in the feature fusion module of YOLOv9, the ability to capture multi-scale features is enhanced, and the accuracy of feature extraction and target detection is improved. By improving the network loss function, a new adaptive threshold focus loss function ATFL is proposed to decouple the target and background, and use an adaptive mechanism to adjust the loss weight, forcing the model to allocate more attention to the target features, thereby improving the detection performance of small targets in early fire smoke. The improved YOLOv9 algorithm fully considers the problem of small target detection. Its improved structure can effectively improve the detection accuracy of small targets, which is conducive to the timely detection of early fire smoke. At the same time, the algorithm has the ability of adaptive adjustment and can automatically adjust the network structure according to the different sizes of the input image, which makes it more adaptable when processing fire smoke detection in different scenes. The improved YOLOv9 algorithm can quickly perform target detection, which can make the entire fire smoke detection system have a high detection speed while ensuring detection accuracy, which is of great significance for real-time monitoring of fire smoke. (2) The present invention uses dynamic threshold judgment and continuous frame fusion to compare the collected data, reduce the false alarm and missed alarm rates, and perform wavelet denoising on the obtained image, which can effectively decompose the image into detailed information of different scales and directions, thereby helping to capture important features in the image and retain these features in the denoising process. At the same time, it can also identify and retain edges, lines, and other directional features in the image. By applying different processing strategies to different parts of the image, it can optimize image quality while reducing noise. (3) The present invention optimizes the data set to collect more high-quality fire smoke images, smoke images under different environments, different time periods, different concentrations, and different fire conditions; and uses different data sets to train the model and evaluate the model's performance; the model performance evaluation includes the model's accuracy, recall rate, and F1 score, so that the trained model can be more targeted to the characteristics of fire smoke in different situations, and the data is more comprehensive, making the model more flexible and adaptable. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a flow chart of the early fire smoke detection method based on the improved YOLOv9 algorithm described in the present invention;
[0044] Figure 2 This is a schematic diagram of the structure of the fire detection model based on the YOLOv9 algorithm architecture described in the present invention;
[0045] Figure 3 This is a schematic diagram of the RepVGG-GELAN module according to an embodiment of the present invention;
[0046] Figure 4 This is a schematic diagram of a DRNS module according to an embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of a C2f-MSAM module according to an embodiment of the present invention;
[0048] Figure 6 This is a schematic diagram of a DASFM module according to an embodiment of the present invention;
[0049] Figure 7 A curve diagram of the training process of the fire detection model based on the YOLOv9 algorithm architecture described in the present invention;
[0050] Figure 8 This is a diagram showing the detection effect of the early fire smoke detection method based on the improved YOLOv9 algorithm described in the present invention. DETAILED DESCRIPTION
[0051] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0052] Example 1
[0053] The early fire smoke detection method based on the improved YOLOv9 algorithm described in the present invention first uses a camera to capture video signals and divides them into separate images. Next, the obtained smoke acquisition signals are compared, and the images are subjected to noise reduction processing to provide the best input for the subsequent fire detection model. Using the trained fire detection model, flames and smoke are detected on these images, and the detection results are marked on the images. Among them, the fire detection model is specifically: based on YOLOv9-C as the basic model, YOLOv9 includes a feature extraction network and a feature fusion network; the feature extraction network adopts a more efficient RepVGG-GELAN module, and an improved feature fusion network is used to strengthen the multi-scale feature fusion process and improve the feature expression ability. A module BSAM combining a two-level attention mechanism and spatial attention is designed between the feature extraction network and the feature fusion network to enhance the feature representation ability and detection accuracy of the model; such as Figure 1 As shown, the method specifically includes the following steps:
[0054] Step 1: Collect smoke signals and image data for the relevant monitoring scene. The camera receives the video stream signal and captures the recorded video frame by frame. The data folder is called Datasets, which contains two subfolders: Images and Labels. Images stores the training images, and Labels stores the XML files corresponding to the training images. The training set and test set ratio is 8:2. The training set image path is stored in train.txt, and the test set image path is stored in test.txt. The relative paths of the training images and labels are stored. The training set contains 15,630 images, the validation set contains 1,500 images, and the test set contains 1,500 images.
[0055] Step 2: Perform image preprocessing at the model input. Compare the smoke signal and perform noise reduction on the image.
[0056] Dynamic thresholding and continuous frame fusion are used to compare collected data to cope with complex backgrounds. Dynamic thresholding strategies can be constructed based on a method that combines the ARIMA (autoregressive integrated moving average) model of time series analysis with anomaly detection algorithms. The specific formula is as follows: Let the time series data of historical smoke concentration be Xt, where t = 1, 2, ..., T. The smoke concentration at future moments is predicted using the ARIMA model:
[0057]
[0058] The continuous frame fusion technology uses weighted moving average (WMA) to fuse the smoke detection results of continuous frames. The weight distribution is dynamically adjusted according to the smoke change rate:
[0059]
[0060] Among them, S t is the fused smoke detection signal, D t-i Indicates the detection result of the ti-th frame, w i It is a dynamic weight calculated based on the rate of change of smoke concentration between the current frame and the previous i frames. The larger the rate of change, the higher the weight, so as to reflect the dynamics of smoke in a timely manner.
[0061] Preprocess the time series data of historical smoke concentration, and the mathematical expression is:
[0062]
[0063] Among them, Zt is the result obtained by standardizing the variable Xt, μ is the mean, σ is the standard deviation, and Td is the threshold obtained by adjusting the mean μ by the standardized variable Zα based on a given confidence level α.
[0064] Image denoising is performed using wavelet denoising. In wavelet denoising, in the subspace of wavelet domain distribution, let f x and fy are Riesz transform images in the wavelet scale x and y directions, and the image is decomposed into local features using the pixel values in the single direction in the wavelet domain, and the principal component feature distribution matrix Q is constructed in the N×N local area. i Is f x and f y The corresponding PCA principal components, the local block binary pattern of the image is expressed as:
[0065] Q i =U i S i V i T =U i S i [v1v2]] f (4)
[0066] Where: v1=[v 11 ,v 12 ],[v 11 , ν 12 ] is a vector group; [v1v2] is a vector group, which means the horizontal splicing of a group of vectors; U i is an orthogonal matrix containing left singular vectors; S i is a diagonal matrix containing singular values; f is the Riesz transform image.
[0067] Wavelet decomposition is used in combination with Log-gabor filter to filter out the redundant information of the local main direction in the image at a certain scale, and the phase reference value of the main direction is obtained as follows:
[0068]
[0069] The matrix S is used to represent the information of the image in the high-frequency band. The distribution function in the main direction of the local block can be expressed as:
[0070]
[0071] Where σ is the regularization parameter, P is the distribution function, s1 and s2 are two eigenvalues. VR imaging technology is combined to enhance image information and suppress the influence of noise. For an input image of size n×m, the local energy distribution conversion method is used to obtain R b ×R b The main direction of the image block of size, the main direction component map model after information enhancement is:
[0072]
[0073] After determining the main direction of the image pixels in the local binary pattern, since θ∈[-π / 2,π / 2], the wavelet features and local binary pattern are used to improve the robustness of imaging, and the image pixel projection area is evenly quantized into T intervals, which can be expressed as:
[0074]
[0075] where θ n,m is an angle, θ n ′, m Indicates that when θ n,m When it falls within the given range, θ n ′, m The value is t. T is a positive number used to adjust the magnitude of the angle, t = 0, 1, ... T-1, which is the main component area after the image pixel vector is quantized.
[0076] Step 3: Improve the YOLOv9 model;
[0077] Construct the YOLOv9 network model. The YOLOv9 network includes feature extraction network, feature fusion network, and detection head. The improved model is as follows Figure 2 As shown; the improvements of the present invention are as follows:
[0078] (1) In the feature extraction network of the original YOLOv9 algorithm, the Conv convolution module is replaced with the RepVGG-GELAN module, and a gating mechanism is introduced to enhance the interactivity between features, thereby better extracting fire smoke features. Figure 3 As shown, the RepVGG-GELAN module is an improved module based on RepVGG and GELAN technologies, designed to enhance the model's representation capabilities and inference efficiency. By combining RepVGG's efficient convolutional structure with GELAN's attention mechanism, the RepVGG-GELAN module provides a network module that is simple and efficient during inference and powerful during training. This design not only improves model performance but also enhances feature representation while maintaining efficient inference. The specific implementation method is as follows: A feature map X of size H×W×C is input, where H is the height, W is the width, and C is the number of channels. Multiple convolution kernels of different sizes are used to convolve the input features. The outputs of multiple branches are fused during training and combined into an equivalent single-branch convolution operation during inference. Linear attention scores are calculated for the input features, and attention weights are obtained through dot product calculations. A gating mechanism is introduced to dynamically adjust the attention weights, enabling them to focus on features in different regions. Gated attention fusion dynamically weights the source and target feature maps Fs and Fo to emphasize key information and suppress noise. Add bilinear interpolation after the RepVGG-GELAN module to enhance the interactivity between features and achieve finer control through the gating unit:
[0079] C=σ(W g BI(F s ,F o ))☉tanh(W a BI(F s ,F o ))+F o (9)
[0080] Among them, C represents the final output, F s ,F o represents the input feature, BI represents the interaction feature obtained by bilinear interpolation, which can capture the complex relationship between the two feature maps, σ is the Sigmoid function, the output range is between 0 and 1, and it is often used to control the amount of information transmitted (i.e., gating), tanh is the hyperbolic tangent activation function, its output range is between -1 and 1, and it is used for data normalization, W g and W a are the weight matrices for gating and regulation, respectively.
[0081] The attention-weighted features are fused with the features after the convolution operation, and finally a feature map enhanced by the attention mechanism is output.
[0082] (2) Design a new DRNS module on the backbone network of YOLOv9, such as Figure 4 As shown in the figure, a high-precision large convolution kernel Dilated Reparam Block module is used in combination with RepNCSPELAN4. The number of convolution kernels in the DRNS module corresponds to the number of input channels. First, a 1×1 convolution layer is used to reduce the number of input channels and divide them into two parts. Then, the convolved feature map y is split into y1 and y2 in the channel dimension. y1 and y2 are respectively enhanced by a non-expanded large kernel conversion layer using a non-expanded small kernel and multiple expanded small kernel layers through an expanded reparameter bottleneck block. In the extended, heavily parameterized bottleneck block, a global average pooling layer and a full convolution layer are used to obtain the classified output. A single full convolution kernel performs a full-dimensional dynamic convolution calculation on a single channel. The processed result and the feature map y are then concatenated in the channel dimension. A 3×3 convolution is then performed to output the feature map. The number of output channels matches the number of input channels. A dilation layer is added for DRNS dynamic convolution calculation. The convolution kernel size of the DRNS module is 3×3×n, where n is the number of channels in the previous layer. The full-dimensional dynamic convolution operation performs a weighted combination of the DRNS module's maps in the depth direction to generate a new feature map. Using high-precision, large convolution kernel modules can reduce memory access and redundant computation while extracting spatial features, accelerating the model's inference time and reducing latency on terminal devices.
[0083] (3) Based on (2), the model is further improved by designing a module BSAM that combines a two-level attention mechanism and spatial attention between the feature extraction network and the feature fusion network. This can enhance the model's feature representation ability and detection accuracy, and improve the robustness and accuracy of fire smoke detection. A convolutional block attention module (CBAM), whose original structure includes a channel attention module (Channel Attention Module) and a spatial attention module (Spatial Attention Module). The channel attention module is replaced with a two-level attention module (BiLevel Attention) to form a new attention BSAM (BiLevel Spatial Attention Module). First, the feature map is input and the input features are passed to the two-level attention module. This module combines two levels of attention mechanisms to better capture information at different levels of features. The two-level attention module generates a channel attention map whose size is the same as the number of channels of the input features. The input features are weighted using the channel attention map:
[0084] F′=Mc ☉F (10)
[0085] Among them, F is the input feature map or feature tensor, F′ is the feature map after channel attention weighting, M c It is a weight matrix used to weight the input feature F.
[0086] The feature F′ processed by the two-stage attention module is input to the spatial attention module. The spatial attention module generates a spatial attention map whose size is the same as the spatial dimension of the input feature. The spatial attention map is used to perform a weighted operation on the channel-weighted features:
[0087] F″=M s ☉F′ (11)
[0088] Among them, F″ is the feature map after spatial attention weighting, and Ms is a mask or control matrix with the same shape as F'.
[0089] Finally, the feature map F″ processed by the dual-level attention module and the spatial attention module is used as the output feature, denoted as the output feature. The combination of these two-level attention mechanisms (dual-level attention and spatial attention) can effectively enhance the representation ability of smoke features, thereby improving the performance of the model in early fire smoke detection.
[0090] (4) In the feature fusion module of YOLOv9, the C2f structure and multi-scale attention module (MSAM) in YOLOv8 are integrated into the neck part of the YOLOv9 model to improve the accuracy of early fire smoke feature extraction and target detection. Figure 5 Specifically, the MSAM module is integrated into the C2f structure to enhance the ability to capture multi-scale features.
[0091] The C2f architecture consists of two convolutional layers and a residual connection module. First, the input features pass through a 1×1 convolutional layer to reduce the channel dimension, followed by a 3×3 convolutional layer for feature extraction. To further improve feature extraction, the MSAM module is introduced between the 1×1 and 3×3 convolutional layers.
[0092] The MSAM module effectively enhances the model's ability to perceive multi-scale objects by weightedly fusing features at different scales. Specifically, the MSAM module uses multiple parallel convolutional layers to process feature maps at different scales. It then uses an attention mechanism to perform a weighted summation of these feature maps to generate fused features. Finally, these fused features are element-wise added to the input features to form the output of the C2f structure.
[0093] In the neck of the YOLOv9 model, we define two convolutional layers and a concat operation to process feature maps extracted from different layers. These feature maps are concatenated along the channel dimension and then fed into a C2f structure containing an MSAM module for further feature extraction and fusion. This improved neck structure provides a more efficient and accurate feature extraction method. By enhancing the ability to process multi-scale features, it improves the accuracy and robustness of early fire smoke detection. This significantly enhances the performance of small object detection models in complex scenarios.
[0094] In order to more comprehensively capture the multi-dimensional information of early smoke and improve the accuracy of small target detection, a dimension-aware selective integration module DASFM (Dimension-aware Selective Fusion Module) is designed after the feature map is output from the neck module, and then output to the detection head. The DASFM module first separates the input features into channel dimensions and spatial dimensions, and extracts features from these two dimensions through two parallel branches. Then, the attention mechanism is used to perform weighted summation on the extracted features to generate fused features. Figure 6 As shown in the figure, two feature maps are input, one from the low-level layer and the other from the high-level layer. Each feature map is processed through a 1×1 convolution. The processed feature map is divided into three parts, and feature fusion operations, including multiplication, addition, and sigmoid activation, are performed on each part. The fused feature maps are then concatenated together. The final output is generated through point-by-point convolution, batch normalization, and ReLU activation. DASFM can dynamically adjust the weights of different features, making the feature fusion process more flexible and adaptable to the smoke detection needs of different scenarios. This not only significantly enhances the effectiveness and adaptability of feature map fusion, but also enables the model to demonstrate higher accuracy, robustness, and generalization capabilities when facing a variety of smoke detection tasks.
[0095] (5) Improve the network loss function and propose a new adaptive threshold focal loss function ATFL, which decouples the target and background and uses an adaptive mechanism to adjust the loss weight, forcing the model to allocate more attention to the target features, thereby improving the detection performance of small objects. ATFL combines the idea of adaptive threshold into the basic Focal Loss.
[0096] The traditional Focal Loss formula is:
[0097] FL(p t )=-α(1-p t ) γ log(p t ) (12)
[0098] Here tIs the probability of predicting the positive class. If it is actually positive, then p t =p, otherwise p t =1-p. The parameters α and γ are used to adjust the weight of samples and focus on samples that are difficult to classify, respectively.
[0099] For ATFL (Adaptive Threshold Focal Loss), an adaptive adjustment function can be introduced to dynamically adjust the value of γ. This function can be adjusted based on the characteristics of the sample or the prediction confidence of the model. ATFL is as follows:
[0100]
[0101] Among them, γ is a dynamic function, which is based on p t The value of is adjusted, α represents a constant, p t is the predicted probability, for example:
[0102] γ(p t )=γ0×(1-p t ) (14)
[0103] Here γ0 is the focusing parameter of the basis, and 1-p t The influence of γ is used to adaptively adjust the prediction uncertainty.
[0104] Step 4: Train the improved YOLOv9 model:
[0105] When collecting datasets for model training, it is necessary to collect more high-quality fire smoke images, including smoke images in different environments, different time periods, different concentrations, and different fire intensity. Different datasets should be used to train the model and evaluate its performance. Model performance evaluation includes precision and mean average precision (mAP). The accuracy of the target detected by the model is the precision, which is defined as the proportion of correctly predicted positive samples to all predicted positive samples.
[0106]
[0107] In the above formula, Recall is the recall rate, TP represents the number of samples correctly predicted as positive samples, and FP represents the number of negative samples in the sample that were incorrectly predicted as positive samples. n represents the number of categories, and APi represents the average precision (AP) of the i-th category.
[0108] Input the training set image data in the fire dataset into the improved network model in step 3 for training. Save the model parameters with the highest accuracy on the validation set during the training process and name the file as best.pt.
[0109] This paper presents a fire smoke detection system and method based on improved YOLOv9 algorithm data analysis. The experimental environment configuration uses the Ubuntu 20.04 operating system, an NVIDIA GeForce RTX 4060Ti graphics card, and the PyTorch deep learning framework. The specific configuration is shown in Table 1 below:
[0110] Table 1 Experimental environment configuration table
[0111]
[0112] The training set images from the fire dataset were fed into the improved network model. GPU training was performed, and the improved network model parameters were set to 300 training epochs, a momentum of 0.937, an initial learning rate of 0.01, a minimum learning rate of 0.0001, a weight decay coefficient of 0.00005, the SGD optimizer, and a batch size of 16. During model training, the model parameters with the best accuracy were saved and named best.pt.
[0113] Figure 7 The graph in the figure shows the changes in various metrics during 300 rounds of model training. After model training, the validation set achieved 95% Precision and 98.5% mAP. Compared to the original YOLOv9-c, our algorithm improved Precision by 2.8%, mAP by 5.7%, and Recall by 6%. Precision represents the accuracy of the model; a higher mAP indicates better recognition performance; mAP indicates how well the model performs across all categories; a higher mAP indicates better network performance. A comparison of the algorithm metrics, shown in Table 2, demonstrates the feasibility of our algorithm.
[0114] Table 2 Comparison of experimental results of different models
[0115] Model Class Precision(P) Recall(R) mAP (%) YOLOv9-c ALL 0.922 0.852 0.928 Ours ALL 0.95 0.912 0.985
[0116] Figure 8 This is the detection effect diagram of the algorithm in this paper. It not only has good feature extraction capabilities, but also has a small model size, low computational complexity, and strong real-time performance. It meets the requirements for deploying early fire smoke detection and provides a technical basis for early fire smoke detection. It has certain scientific and practical significance.
[0117] Through the above steps, not only the recognition accuracy and generalization ability of early fire smoke are improved, but also the efficient training and deployment of the model are achieved by optimizing the utilization of computing resources.
[0118] Example 2
[0119] The early fire smoke detection system based on the improved YOLOv9 algorithm described in the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the early fire smoke detection method based on the improved YOLOv9 algorithm is implemented.
[0120] The early-stage fire smoke detection system based on the improved YOLOv9 algorithm segments the video signal captured by the camera into separate images and performs image preprocessing. These images are then detected using a trained fire detection model and the detection results are displayed. The preprocessing and fire detection model processing and training are similar to those described in Example 1 for the early-stage fire smoke detection method based on the improved YOLOv9 algorithm.
[0121] In one embodiment, a computer program product is provided, including a computer program / instruction, which, when executed by a processor, implements the early fire smoke detection method based on the improved YOLOv9 algorithm.
[0122] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0123] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0124] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1The function specified in one or more boxes.
[0125] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
Claims
1. An early fire smoke detection method based on improved YOLOv9 algorithm, Features: It includes image preprocessing, inputting the preprocessed image into the fire detection model, and the fire detection model outputs the detection result; the image preprocessing includes dynamic threshold determination and continuous frame fusion, the dynamic threshold determination is used to determine the smoke characteristics in each frame of the image, and the continuous frame fusion is used to perform fusion determination on the smoke detection results in multiple continuous frames of images; The fire detection model is improved based on the YOLOv9 algorithm architecture. The improvement includes: a BSAM module combining a dual-level attention mechanism and spatial attention is provided between a feature extraction network and a feature fusion network; in the feature fusion module of YOLOv9, a C2f structure and a multi-scale attention module are integrated into the neck part of the YOLOv9 model, including: adding a C2f module in the connection between several feature maps of the neck part, adding a multi-scale attention module in the output stage of the C2f module, and adding a dimension-aware selective integration module DASFM after the output of the neck module, and outputting to the detection head through the dimension-aware selective integration module; the improvement also includes: the loss function of the YOLOv9 algorithm adopts an adaptive threshold focal loss function.
2. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The image preprocessing includes dynamic threshold determination and continuous frame fusion, and includes the following processes: first, applying dynamic threshold determination to each frame of acquired image to extract the area where smoke may exist; Then, smoke detection is performed on the areas where smoke may exist in the continuous multiple frames of images to obtain a judgment result; finally, the smoke detection results of the continuous multiple frames of images are fused and judged.
3. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The construction of dynamic threshold in dynamic threshold determination includes: predicting the smoke concentration at future time by autoregressive integral moving average model; continuous frame fusion technology uses weighted moving average to fuse the smoke detection results of continuous frames, and the calculation formula is: Among them, S t is the fused smoke detection signal, D t-i represents the detection result of the ti-th frame, w i It is a dynamic weight calculated based on the rate of change of smoke concentration between the current frame and the previous i frames.
4. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The image denoising process in the image preprocessing adopts wavelet denoising, including: In the subspace of wavelet domain distribution, let f x and f y The Riesz transform image in the x and y directions of the wavelet scale is used to decompose the local features of the image using the pixel values in the single direction in the wavelet domain, and the principal component feature distribution matrix Q is constructed in the N×N local area. i It is f x and f y The corresponding PCA principal component, the local block binary pattern of the image is expressed as: Where: Vi represents an orthogonal matrix containing right singular vectors; U i is an orthogonal matrix containing left singular vectors; S i is a diagonal matrix containing singular values; Wavelet decomposition is used in combination with Log-gabor filter to filter out the redundant information of the local main direction in the image at a certain scale, and the phase reference value of the main direction is obtained as follows: Among them, V 11 The first parameter of the transverse volume representing the orthogonal matrix containing the right singular vectors, V 12 represents the second argument of the same vector; The matrix S is used to represent the information of the image in the high-frequency band, and the distribution function in the main direction of the local block can be expressed as: Where σ is the regularization parameter, P is the distribution function in the main direction of the local block, and s 1 ,s 2 are the two eigenvalues of the matrix S in the main directions of the local block, s 1 is the larger of the two eigenvalues. For an input image of size n×m, the local energy distribution conversion method is used to obtain R b ×R b The main direction of the image block of size, the main direction component map model after information enhancement is: Update the main direction of the image pixels in the local binary pattern, calculated as: Among them, θ n ' ,m is the n,m The updated value, θ n,m represents the angle, T is the number of intervals of uniform quantization of the image pixel projection area, t is the main component area after the image pixel vector is quantized, t=0,1,…T-1.
5. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The improvements also include replacing the Conv convolution modules of the first and second layers of the backbone network with RepVGG-GELAN modules, adding bilinear interpolation after the RepVGG-GELAN modules to enhance the interactivity between features, and implementing control through gating units: C=σ(W g ·BI(F s ,F o ))⊙tanh(W a ·BI(F s ,F o ))+F o Among them, C represents the final output of the RepVGG-GELAN module, Fs represents the input features, Fo represents the output features, BI represents the interaction features obtained by bilinear interpolation, σ is the Sigmoid function, tanh is the hyperbolic tangent activation function, and W g and W a are the weight matrices for gating and regulation, respectively.
6. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The BSAM module combining the dual-level attention mechanism and spatial attention includes: First, input the feature map and pass the input features to the two-level attention module; the two-level attention module generates a channel attention map whose size is the same as the number of channels of the input features; the input features are weighted using the channel attention map: F′=M c ⊙F Among them, F is the input feature map or feature tensor, F′ is the feature map after channel attention weighting, and M c It is a weight matrix, which is used to weight the input feature F; The feature F′ processed by the two-level attention module is input into the spatial attention module. The spatial attention module generates a spatial attention map whose size is the same as the spatial dimension of the input feature. The spatial attention map is used to perform a weighted operation on the channel-weighted features: F″=M s ⊙F′ Among them, F″ is the feature map after spatial attention weighting, Ms is the mask matrix with the same shape as F', and F″ is the output feature after processing by the two-level attention module and the spatial attention module.
7. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The DASFM module first separates the input features into channel dimensions and spatial dimensions, extracts features from these two dimensions respectively through two parallel branches, and then uses the attention mechanism to perform weighted summation of the extracted features to generate fused features.
8. The early fire smoke detection method based on the improved YOLOv9 algorithm according to claim 1, Features: The adaptive threshold focus loss function dynamically adjusts the value of γ by introducing an adaptive adjustment function, and the calculation formula is: Among them, γ is the dynamic index, ATFL is the adaptive threshold focal loss function, α represents a constant, and p t is the predicted probability, calculated as: c(p t )=γ 0 ×(1-p t ) Among them, γ 0 It is the basic focusing parameter.
9. An early fire smoke detection system based on an improved YOLOv9 algorithm, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the early fire smoke detection method based on the improved YOLOv9 algorithm according to any one of claims 1 to 7 is implemented.
10. A computer program product comprising a computer program and / or instructions, It is characterized in that When the computer program and / or instruction is executed by a processor, the early fire smoke detection method based on the improved YOLOv9 algorithm described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Fire detection method based on PD-YOLO
CN117333753A
Cited By
Intelligent management system for smart factory
CN119558802A
Sow delivery behavior intelligent monitoring method based on improved YOLOv8 model
CN119992648A
Intelligent Monitoring Method for Sow Farrowing Behavior Based on Improved YOLOv8 Model
CN119992648B
CNN (Convolutional Neural Network) smoke and fire detection method and system based on double attention mechanisms
CN120088740A
Flame smoke identification method and equipment
CN120612569A
