A lightweight flame smoke detection method based on context-aware gating feature enhancement

By improving the YOLO-like target detection network and introducing a context-aware gated feature enhancement module and a lightweight shared detection head, the problems of small-scale target recognition and anti-interference in complex backgrounds are solved, achieving efficient flame and smoke detection, which is suitable for video surveillance and edge computing devices.

CN122391813APending Publication Date: 2026-07-14NANJING UNIV OF SCI & TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING UNIV OF SCI & TECH
Filing Date
2026-06-15
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing flame and smoke detection methods have shortcomings in small-scale target recognition, anti-interference in complex backgrounds, and lightweight deployment. In particular, they are insufficient in the detection of flame and smoke targets in the early stages of a fire, have weak anti-interference capabilities in complex backgrounds, and lightweight models are difficult to balance detection accuracy and real-time performance.

Method used

A lightweight flame and smoke detection method based on context-aware gating feature enhancement is adopted. By constructing a context-aware gating feature enhancement module, a QKV-guided split-interaction fusion module, and a lightweight shared detection head, the YOLO-like target detection network is improved, thereby enhancing the accuracy and real-time performance of small-scale target detection.

Benefits of technology

It improves the detection stability of small-scale flame and smoke targets, reduces false responses in complex backgrounds, and reduces computational overhead, which is beneficial for deployment in video surveillance and edge computing devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122391813A_ABST
    Figure CN122391813A_ABST
Patent Text Reader

Abstract

The application discloses a kind of light weight flame smoke detection methods based on context-aware gated feature enhancement, belong to fire intelligent detection technical field.The method is first obtained and is carried out scale normalization processing to the image to be detected, then the image is input into the improved light weight target detection network.The network introduces context-aware gated feature enhancement module in backbone and neck structure, extracts local detail features by partial channel convolution, obtains context information by multi-scale hollow depth convolution, and utilizes gating mechanism to dynamically modulate enhanced features;At the same time, a split interaction fusion module guided by QKV is introduced at the high-level features to realize the adaptive re-scaling of spatial branches and channel branches;The detection end uses a light shared detection head to output the position and category of flame and smoke targets.The application can reduce the model parameter quantity and computational complexity while improving the detection accuracy of flame and smoke targets in complex background.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent fire detection and computer vision target detection technology, specifically relating to a flame and smoke detection method based on a lightweight context-aware gating network. Background Technology

[0002] Fires are characterized by their suddenness, rapid spread, and wide range of damage. Early and accurate identification of flames and smoke is crucial for fire warning and coordinated fire control. Traditional fire detection methods rely heavily on temperature, smoke concentration, or gas sensors. However, these methods typically require fire products to diffuse to the vicinity of the sensor before they can respond, resulting in problems such as alarm lag, insufficient location capability, and susceptibility to installation location issues.

[0003] With the development of computer vision and deep learning technologies, image- or video-based flame and smoke detection methods are increasingly being applied to intelligent fire monitoring. These methods can directly identify flame and smoke areas from monitoring footage and output target category and location, offering advantages such as fast response, intuitive localization, and ease of deployment. Existing target detection models such as the YOLO series, Faster R-CNN, SSD, and DETR have been used for flame and smoke detection with some success. However, existing technologies mainly suffer from the following drawbacks:

[0004] (1) Insufficient detection capability for small-scale flames and smoke targets: In the early stages of a fire, flames and smoke targets are usually small in area, have unclear boundaries, and weak visual features. Existing detection models are prone to losing detailed information of small targets during multiple downsampling and feature fusion processes, resulting in missed detections.

[0005] (2) Weak anti-interference ability under complex backgrounds: In actual monitoring scenarios, there are often interference factors such as building edges, light reflections, welding sparks, sunlight spots, shadows and smoke. These interference sources are similar to flames and smoke in color, brightness or texture. Existing models are prone to false responses to bright background areas or complex textures, leading to false detections.

[0006] (3) It is difficult to balance detection accuracy and lightweight deployment: Although existing lightweight detection models have low parameter and computational cost and good real-time performance, their feature expression capabilities are limited. While introducing complex attention mechanisms, Transformer structures or large-scale feature enhancement modules may improve detection accuracy, they will increase the computational cost of the model, which is not conducive to deployment on edge devices or real-time monitoring systems. Summary of the Invention

[0007] To address the shortcomings of existing flame and smoke detection methods in small-scale target recognition, complex background interference resistance, and lightweight deployment, this invention provides a lightweight flame and smoke detection method based on context-aware gated feature enhancement. This method improves upon YOLO-like target detection networks by constructing a context-aware gated feature enhancement module, a QKV-guided split-interaction fusion module, and a lightweight shared detection head, thereby enhancing the detection accuracy and real-time performance of flames and smoke targets in complex scenes.

[0008] In a first aspect, the present invention provides a lightweight flame and smoke detection method based on context-aware gating feature enhancement, comprising the following steps:

[0009] S1: Obtain a publicly available flame and smoke detection dataset, organize and format-verify the images and their corresponding annotation files in the dataset, and divide them into a training set, a validation set, and a test set according to a preset ratio;

[0010] S2: Construct an initial flame and smoke detection model based on the YOLO11n target detection network. The initial flame and smoke detection model includes a backbone network, a feature fusion network, and a detection head.

[0011] S3: Introduce a context-aware gated feature enhancement module CAGF into the backbone network and / or feature fusion network, construct a C3k2CAGF structure, and replace part of the C3k2 feature extraction module in the initial flame and smoke detection model with the C3k2CAGF structure;

[0012] S4: Set up a QKV-guided splitting and fusion module QSF in the high-level semantic feature layer. Generate branch gating weights, spatial gating features and channel gating features through the QSF module, and perform adaptive modulation on the split spatial branches and channel branches.

[0013] S5: In the feature fusion network, features of different scales are upsampled, spliced ​​and enhanced to output small-scale detection features, medium-scale detection features and large-scale detection features.

[0014] S6: The lightweight shared detection head SLD-Head is used to predict the small-scale, medium-scale, and large-scale detection features, and output the category, confidence level, and bounding box coordinates of the flame and smoke targets.

[0015] S7: Use the training set and validation set to train and optimize the parameters of the flame and smoke detection model improved in step S6 to obtain the optimal detection model, and use the test set to evaluate the performance of the optimal detection model.

[0016] Furthermore, the CAGF module includes a fast local branch, a context branch, a gating branch, and a retention branch; wherein, the fast local branch is used to extract local detail features, the context branch is used to extract multi-scale context features, the gating branch is used to dynamically modulate the enhanced features, and the retention branch is used to preserve the input feature information.

[0017] Furthermore, the fast local branch includes the DGPartialConv3 module, which divides the input features along the channel dimension into convolutional channel groups and reserved channel groups. Only the convolutional channel groups are subjected to 3×3 convolution operations, while the reserved channel groups retain their features unchanged. The convolutional channel groups after convolution processing are concatenated with the reserved channel groups to concatenate features, thereby reducing computational overhead while preserving the ability to extract local features.

[0018] Furthermore, the context branch includes a DAC module, which has multiple parallel deep dilated convolution branches. Each deep dilated convolution branch uses a different dilation rate to extract context features under the corresponding receptive field. The output features of each branch are concatenated along the channel dimension and then fused by a 1×1 convolution.

[0019] Furthermore, the C3k2CAGF structure first performs channel mapping on the input features through a 1×1 convolution, converting the input features into a feature map with twice the number of intermediate channels; then, the feature map is split into a retention branch and an enhancement branch along the channel dimension. The retention branch directly participates in subsequent fusion, while the enhancement branch sequentially inputs one or more CAGF modules to perform feature enhancement; finally, the initial features of the retention branch and enhancement branch, as well as the outputs of each level of CAGF modules, are concatenated along the channel dimension and fused through a 1×1 convolution to complete the output.

[0020] Furthermore, the QSF module first maps the input features through a 1×1 convolution pair to obtain preprocessed features; the preprocessed features are split into spatial branches and channel branches along the channel dimension, and lightweight QKV descriptors are input to extract branches, generating Q features, K features and V features.

[0021] Furthermore, the Q-feature and K-feature are multiplied element-wise to obtain the QK-correlation feature, and the QK-correlation feature is subjected to global average pooling to obtain the QK descriptor; the V-feature is subjected to global average pooling to obtain the V descriptor; the QK descriptor and V descriptor are concatenated and input into the branch gating network, and the spatial branch weights and channel branch weights are generated by the Sigmoid function.

[0022] Furthermore, the Q-feature and V-feature are averaged along the channel dimension and then concatenated, and input into the group-level spatial gating module to generate spatial gating features; the QK descriptor is input into the channel gating module to generate channel gating features; the spatial branch is modulated according to the spatial branch weight and the spatial gating features, and the channel branch is modulated according to the channel branch weight and the channel gating features.

[0023] Furthermore, the spatial branch and the channel branch employ cross-gated modulation, as shown in the formula:

[0024]

[0025]

[0026] in, Represents spatial branching characteristics, Indicates channel branching characteristics, Indicates the spatial branch weight, Indicates the channel branch weight. Indicates spatial gating characteristics, Indicates channel gating characteristics, Indicates the shared gating scaling factor. Indicates the characteristics after spatial branch modulation. This indicates the characteristics after channel branch modulation.

[0027] Furthermore, the SLD-Head lightweight shared detection head includes a channel mapping layer, a shared lightweight convolutional layer, a bounding box regression branch, and a category prediction branch; after the detection features at different scales are mapped to a unified number of hidden channels by the channel mapping layer, they are input into the shared lightweight convolutional layer to reduce the repetitive parameters of each scale detection branch.

[0028] Secondly, the present invention provides a smoke detection system based on a lightweight flame and smoke detection method enhanced by context-aware gating features, comprising:

[0029] The dataset preprocessing module is used to obtain a publicly available flame and smoke detection dataset, organize and verify the format of the images and corresponding annotation files in the dataset, and divide them into training set, validation set and test set according to a preset ratio.

[0030] An initial model building module is used to build an initial flame and smoke detection model based on the YOLO11n target detection network. The initial flame and smoke detection model includes a backbone network, a feature fusion network, and a detection head.

[0031] The feature enhancement module is used to introduce a context-aware gated feature enhancement module (CAGF) into the backbone network and / or feature fusion network, construct a C3k2CAGF structure, and replace part of the C3k2 feature extraction module in the initial flame and smoke detection model with the C3k2CAGF structure.

[0032] The split interactive fusion module QSF is used to generate branch gating weights, spatial gating features and channel gating features at the high-level semantic feature layer, and to perform adaptive modulation on the split spatial branches and channel branches.

[0033] The multi-scale feature fusion module is used to upsample, stitch, and enhance features at different scales, and output small-scale detection features, medium-scale detection features, and large-scale detection features.

[0034] The lightweight shared detection head SLD-Head is used to predict the small-scale, medium-scale, and large-scale detection features, and output the category, confidence level, and bounding box coordinates of the flame and smoke targets.

[0035] The model training and evaluation module is used to train and optimize the parameters of the improved flame and smoke detection model using the training set and validation set, to obtain the optimal detection model, and to evaluate the performance of the optimal detection model using the test set.

[0036] Thirdly, the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the flame and smoke detection method described in the first aspect.

[0037] Fourthly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the flame and smoke detection method described in the first aspect.

[0038] Compared with the prior art, the present invention has at least the following beneficial effects:

[0039] First, this invention performs 3×3 convolution operations on only a portion of the channels using DGPartialConv3 while retaining information from the remaining channels. This reduces the computational overhead of local convolutions while preserving the detailed features of the flame and smoke targets, such as edges and textures.

[0040] Second, this invention introduces multi-scale dilated deep convolutional context modeling through the DAC (Dilated Adaptive Context) module, which can expand the feature receptive field and enhance the ability to express the smoke diffusion area, the area around the flame, and complex background context.

[0041] Third, this invention achieves dynamic modulation of enhanced features and preservation of original feature information through gating branches and retention branches in the CAGF module, which helps to reduce information loss during feature enhancement and improve the detection stability of small-scale flame and smoke targets.

[0042] Fourth, this invention uses the QKV descriptor to generate branch gating, spatial gating and channel gating through the QSF module, realizing adaptive recalibration of spatial branches and channel branches, which can enhance the target-related response and reduce false responses caused by background highlight areas, building textures and other interference sources.

[0043] Fifth, the present invention uses a lightweight shared detection head to reduce the number of detection parameters and computational complexity, thereby improving inference speed while maintaining detection accuracy, which is beneficial for deployment and application in video surveillance, edge computing devices and real-time fire early warning systems. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0045] Figure 1 This is a schematic diagram of the flame and smoke detection method provided by the present invention;

[0046] Figure 2 This is a schematic diagram of the overall structure of the improved detection network provided in an embodiment of the present invention;

[0047] Figure 3 This is a schematic diagram of the C3k2CAGF module structure provided in an embodiment of the present invention;

[0048] Figure 4 A schematic diagram of the CAGF Block structure provided in an embodiment of the present invention;

[0049] Figure 5 This is a schematic diagram of the DGPartialConv3 module structure provided in an embodiment of the present invention;

[0050] Figure 6 This is a schematic diagram of the DAC module structure provided in an embodiment of the present invention;

[0051] Figure 7 This is a schematic diagram of the QSF module structure provided in an embodiment of the present invention;

[0052] Figure 8This is a schematic diagram of the SLD-Head lightweight shared detection head structure provided in an embodiment of the present invention. Detailed Implementation

[0053] The technical solution of the present invention will be further described below with reference to specific embodiments. The following embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Any equivalent substitutions or improvements made by the inventors of this method to the relevant network structure, parameter settings, training methods, and deployment methods without departing from the technical concept of the present invention should fall within the scope of protection of the present invention.

[0054] Combination Figure 1 This invention provides a flowchart for a flame and smoke detection method, with the specific steps as follows:

[0055] Step S1: Obtain the D-Fire public flame and smoke detection dataset, organize and check the format of the images and their corresponding annotation files in the dataset, and remove data samples that cannot be read normally, have abnormal annotations, or have significantly poor image quality; according to the requirements of the flame and smoke detection task, divide the images and annotation files in the dataset into training set, validation set and test set according to a preset ratio for subsequent model training, parameter optimization and performance testing.

[0056] Step S2: Based on the YOLO11n target detection network, establish an initial flame and smoke detection model. The initial model includes a backbone network, a feature fusion network, and a detection head. The backbone network is used to extract multi-scale features from the input image, the feature fusion network is used to fuse semantic information and spatial detail information at different scales, and the detection head is used to output the category, confidence level, and bounding box position of the flame and smoke targets.

[0057] Step S3: Introduce a Context-Aware Gated Faster Block (CAGF) into the backbone network and feature fusion network, and construct a C3k2CAGF structure based on this module to replace part of the C3k2 feature extraction module in the original network. The CAGF module includes a fast local branch, a context branch, a gate branch, and a retention branch. The fast local branch is used to extract local detail features, the context branch is used to extract multi-scale context features, the gate branch is used to dynamically modulate the enhanced features, and the retention branch is used to preserve the input feature information.

[0058] Step S4: Set up a QKV-guided Split-interactive Fusion Module (QSF) at the high-level semantic features; the QSF module generates Q features, K features and V features based on the preprocessed complete features, and generates branch gating weights, spatial gating features and channel gating features according to QK correlation features and V response features, and adaptively modulates the split spatial branches and channel branches, thereby enhancing the response of the target related region and reducing interference from complex backgrounds.

[0059] Step S5: In the feature fusion network, a multi-scale feature fusion structure is adopted to upsample, stitch together and enhance features of different scales step by step, and output small-scale detection features, medium-scale detection features and large-scale detection features for detection. Among them, small-scale detection features are used to enhance the recognition ability of early small flame and small smoke targets, while medium-scale and large-scale detection features are used to improve the adaptability to flame and smoke targets of different sizes.

[0060] Step S6: Use a lightweight shared detection head (SLD-Head) to predict multi-scale detection features. The lightweight shared detection head reduces the number of detection parameters and computational complexity by sharing a convolutional structure, and outputs the category, confidence level and bounding box coordinates of flame and smoke targets respectively.

[0061] Step S7: Train and optimize the improved flame and smoke detection network from steps S3 to S6 using the training and validation sets to obtain the optimal detection model; test the optimal detection model using the test set, and evaluate the model's detection performance based on metrics such as accuracy, recall, mAP50, mAP50-95, number of parameters, and computational cost.

[0062] Example

[0063] This embodiment provides a lightweight flame and smoke detection method based on context-aware gating feature enhancement. This method uses flame and smoke images as detection objects and achieves flame and smoke target identification and localization based on an improved YOLO11 target detection network. The improved network includes a backbone network, a feature fusion network, and a lightweight shared detection head. The specific steps are as follows:

[0064] Step S1: Dataset preparation.

[0065] The D-Fire public flame and smoke detection dataset is used as the base dataset for this embodiment. The image categories in the dataset include flame and smoke, and the corresponding annotation files are in YOLO format. The annotation content includes the target category number, the x-coordinate of the target center point, the y-coordinate of the target center point, the target width, and the target height.

[0066] The image and annotation files in the dataset were processed to check if the images could be read correctly, and to verify that the annotation files corresponded one-to-one with the image files, and to standardize the category numbers. Image samples that could not be read correctly, had missing annotation files, incorrect annotation categories, or obviously abnormal target boxes were removed. After processing, a total of 21,519 valid images were obtained, including 14,683 flame targets and 11,857 smoke targets.

[0067] The processed dataset is divided into training, validation, and test sets according to a preset ratio. In one optional implementation, the ratio of training, validation, and test sets is 7:2:1, where the training set contains 15063 images, the validation set contains 4303 images, and the test set contains 2153 images. The training set is used for model parameter learning, the validation set is used for model selection and hyperparameter tuning, and the test set is used for final performance evaluation.

[0068] Before model training, the input image size is uniformly adjusted to 640×640. To improve the model's adaptability to different lighting conditions, scale variations, and complex backgrounds, data augmentation is performed on the training set images. This data augmentation includes one or more of the following: random scaling, random cropping, horizontal flipping, color space perturbation, Mosaic enhancement, and Gaussian noise perturbation. The validation and test sets do not undergo random data augmentation; only scale normalization is performed to ensure the stability and comparability of the model evaluation results.

[0069] Step S2: Construct a lightweight flame and smoke detection network.

[0070] S21: An initial flame and smoke detection model is constructed based on the YOLO11n target detection network. The initial flame and smoke detection model includes a backbone network, a feature fusion network, and a detection head. The input image first passes through convolutional layers and downsampling layers to extract initial features, and then outputs detection features at different scales through multi-scale feature extraction and feature fusion structures.

[0071] S22: As Figure 1As shown, the flame and smoke detection method provided by this invention includes the following processes: dataset preparation, detection network construction, context-aware gated feature enhancement, QKV-guided splitting and interactive fusion, multi-scale feature fusion, lightweight shared detection head prediction, model training, and performance evaluation. The input image is preprocessed and then fed into the improved detection network, which ultimately outputs the category, confidence level, and bounding box coordinates of the flame and smoke targets.

[0072] S23: As Figure 2 As shown, the improved detection network consists of three parts: Backbone, Neck, and Head. Backbone is used to extract hierarchical features from the input image, Neck is used to upsample, stitch, and fuse features at different scales, and Head is used to output the detection results of flame and smoke targets based on the fused multi-scale features.

[0073] S24: Set up a C3k2CAGF module in the backbone network and the feature fusion network. The C3k2CAGF module is used to replace part of the C3k2 feature extraction module in the original YOLO11n network to enhance the local detail features and contextual semantic features of flame and smoke targets.

[0074] S25: Set up a QSF module at the high-level semantic features. The QSF module is used to perform QKV-guided splitting and interactive fusion of high-level semantic features, enhance the response of target-related regions, and reduce the interference of light reflection, building textures, and bright areas in complex backgrounds on the detection results.

[0075] S26: Set up a lightweight shared detection head (SLD-Head) at the detection end. The SLD-Head reduces redundant parameters between detection branches of different scales by sharing a lightweight convolutional structure, thereby reducing the number of parameters and computational complexity at the detection end.

[0076] Step S3: Construct the C3k2CAGF module.

[0077] S31: As Figure 3 As shown, the C3k2CAGF module takes the input feature map X as input, where H is the feature map height, W is the feature map width, and C is the number of input channels. The input feature map X is first input into the first 1×1 convolutional layer for channel mapping, resulting in the intermediate feature map F, where... , This represents the number of intermediate channels.

[0078] S32: Split the intermediate feature map F into first branch features along the channel dimension. Second branch features ,in , First branch feature As a retained branch, it directly participates in subsequent feature fusion; the second branch features... As an input to the enhanced branch, the CAGF Block is used.

[0079] S33: Features of the second branch By sequentially inputting n concatenated CAGF blocks, the enhancement features at each level are obtained. , … ,in n represents the number of times the CAGF Block is stacked.

[0080] S34: Features of the first branch Initial features of the second branch and enhancement features at all levels , … By stitching along the channel dimension, the stitching feature is obtained. ,in .

[0081] S35: Features of splicing The input is a second 1×1 convolutional layer for channel fusion, and the output is the C3k2CAGF module feature Y, where , This represents the number of output channels. Through the above processing, the C3k2CAGF module retains the feature splitting and fusion capabilities of C3k2 while introducing CAGF Blocks for local detail and contextual semantic enhancement.

[0082] Step S4: Construct the CAGF Block.

[0083] S41: As Figure 4 As shown, the CAGF Block uses the input feature map For input, where , Input channel number. Input feature map. First, a 1×1 convolutional layer is input for feature mapping to obtain an intermediate feature map. ,in .

[0084] S42: Transfer intermediate feature map The input consists of a fast local branch, a context branch, a gating branch, and a retention branch. The fast local branch is used to extract flame edges, smoke textures, and local spatial details; the context branch is used to extract multi-scale contextual features; the gating branch is used to generate gating weights and dynamically modulate the enhanced features; and the retention branch is used to preserve stable information in the input features.

[0085] S43: Fast Local Branch Pairs Perform partial channel spatial convolution to output local features. ,in Context branch pairs Perform multi-scale dilated depthwise convolution to output contextual features. ,in .

[0086] S44: Local features and context features By stitching along the channel dimension, the features before fusion are obtained. ,in Subsequently, Input a 1×1 convolutional layer for channel compression and fusion to obtain fused enhanced features. ,in .

[0087] S45: Gated branch pair Perform a 1×1 convolution mapping and generate gated features M using the Sigmoid function, where Fusion enhancement features Element-wise multiplication with the gated feature M yields the gated enhanced feature. ,in .

[0088] S46: Preserve the branch through a 1×1 convolutional layer. Mapping is performed to obtain preserved features. ,in Enhance gating features and retain features By concatenating along the channel dimension, the pre-output features are obtained. ,in .

[0089] S47: Will Input a 1×1 convolutional layer for channel fusion to obtain the CAGF Block output features. ,in When input features With output features When the number of channels is the same, and The residuals are summed to obtain the final output features. This structure enables CAGF Block to simultaneously achieve local detail preservation, multi-scale context modeling, and effective feature selection with relatively low computational overhead.

[0090] Step S5: Build the DGPartialConv3 module.

[0091] S51: As Figure 5As shown, the DGPartialConv3 module takes the input feature map as input. For input, where , The number of input channels. Input feature map. Divide into convolutional channel groups along the channel dimension and reserved channel group .

[0092] S52: Convolutional Channel Group Number of channels satisfy:

[0093]

[0094] in, Channel partitioning coefficient. Reserve channel groups. Number of channels satisfy:

[0095]

[0096] S53: Convolution channel group Spatial feature extraction is performed by inputting a 3×3 convolutional layer to obtain convolutional features. ,in Reserve channel group Without spatial convolution, it is directly used as the preserved feature.

[0097] S54: Convolutional features and reserved channel group By concatenating along the channel dimension, we obtain the fast local branch output features. ,in .

[0098] S55: Yes Channel rearrangement is performed to allow the convolutional channel information to interact with the unconvolutional channel information. Through this process, DGPartialConv3 performs spatial convolution only on a subset of channels, reducing the computational redundancy caused by full-channel 3×3 convolution while preserving the original channel information.

[0099] Step S6: Construct the DAC module.

[0100] S61: As Figure 6 As shown, the DAC module uses the input feature map For input, where , Input channel number. Input feature map. Input multiple parallel 3×3 depth-dilated convolution branches respectively.

[0101] S62: In one alternative implementation, the DAC module includes three parallel deep-dilated convolutional branches. The first deep-dilated convolutional branch has a dilation rate of 1 and outputs features. ,in The dilation rate of the second deep dilated convolution branch is 3, and the output features are... ,in The third deep dilated convolution branch has a dilation rate of 5, and its output features... ,in .

[0102] S63: The equivalent receptive fields corresponding to the three deep-dilated convolution branches mentioned above are 3×3, 7×7, and 11×11, respectively. The branches with different receptive fields are used to extract local details, medium-range contextual features, and large-range contextual features, respectively.

[0103] S64: Will , and By concatenating along the channel dimension, we obtain the context concatenation feature. ,in .

[0104] S65: Concatenate contextual features Input a 1×1 convolutional layer for channel fusion, and output context-enhanced features. ,in Through the above processing, the DAC module can expand the feature receptive field without significantly increasing the number of parameters, thereby improving the model's ability to model the context of smoke diffusion areas, the background around the flames, and targets at different scales.

[0105] Step S7: Build the QSF module.

[0106] S71: As Figure 7 As shown, the QSF module uses high-level semantic features For input, where Input features First, a 1×1 convolutional layer is input for channel mapping to obtain preprocessed features. ,in .

[0107] S72: Preprocessing features Decomposed into spatial branch features along the channel dimension and channel branch features At the same time, preprocessed features The lightweight QKV descriptor is used to extract branches, which yield Q features, K features, and V features respectively.

[0108] S73: Multiply the Q features and K features element by element to obtain the QK correlation features. .right Perform global average pooling to obtain the QK descriptor. Perform global average pooling on the V features to obtain the V descriptor. .

[0109] S74: Transfer QK descriptor and V descriptor The data is concatenated along the channel dimension and input into a branch-gated network. The branch-gated network generates spatial branch weights using the Sigmoid function. and channel branch weights These are used for modulating spatial branching and channel branching, respectively.

[0110] S75: The Q and V features are meand along the channel dimension, concatenated, and then input into the group-level spatial gating module to generate spatially gated features. . QK descriptor Input channel gating module to generate channel gating features .

[0111] S76: Based on spatial branch weights and spatial gating features Spatial branching features Modulation is performed to obtain spatial branch modulation features. Based on channel branch weights and channel gating features Channel branching features Modulation is performed to obtain channel branch modulation characteristics. .

[0112] In one alternative implementation, the modulation schemes for spatial branching and channel branching are as follows:

[0113]

[0114]

[0115] in, Represents spatial branching characteristics, Indicates channel branching characteristics, Indicates the spatial branch weight, Indicates the channel branch weight. Indicates spatial gating characteristics, Indicates channel gating characteristics, Indicates the shared gating scaling factor. Represents the spatial branch modulation features (spatial branch with spatial branch weights) and spatial gating features Modulated features). This represents the characteristics after channel branch modulation (channel branch through channel branch weight). and channel gating features (Modulated characteristics).

[0116] S77: Spatial branch modulation feature and channel branch modulation characteristics The features are concatenated along the channel dimension and fed into a grouped 1×1 convolutional layer and a channel rearrangement layer to obtain the output features of the QSF module. ,in When the number of input and output channels is the same, and The residuals are summed to obtain the final output features. Through the above processing, the QSF module can enhance the response in flame and smoke-related areas and reduce false responses caused by complex background interference.

[0117] Step S8: Construct a feature fusion network.

[0118] S81: The input image is processed by the backbone network to obtain backbone feature maps at multiple scales. Shallow features contain richer spatial details, while high-level features contain stronger semantic information.

[0119] S82: Perform top-down feature fusion. The high-level features output from the backbone network are upsampled sequentially and concatenated with the shallow features of the corresponding scale. Then, feature enhancement is performed through the C3k2CAGF module to obtain small-scale detection features.

[0120] S83: Perform bottom-up feature fusion. Continue to construct medium-scale and large-scale detection features through convolutional downsampling and feature concatenation to enhance the information interaction between features of different scales.

[0121] S84: Output multi-scale detection features. In one optional implementation, the detection features at the three scales are P3, P4, and P5, respectively. Specifically, feature P3 is used for small-scale flame and smoke target detection, feature P4 for medium-scale target detection, and feature P5 for large-scale target detection. This multi-scale feature fusion method can simultaneously preserve shallow spatial details and high-level semantic information, improving adaptability to early-stage small flames, sparse smoke, and large smoke areas.

[0122] Step S9: Construct the SLD-Head lightweight shared detection head.

[0123] S91: As Figure 8 As shown, the detection features at three scales, P3, P4, and P5, are input into the SLD-Head lightweight shared detection head. Specifically, P3 is used for small-scale flame and smoke target detection, P4 for medium-scale target detection, and P5 for large-scale target detection.

[0124] S92: Input P3, P4, and P5 into the corresponding channel mapping layers respectively, and map the detection features at different scales to the number of hidden channels. In one alternative implementation, the number of hidden channels is unified. Set it to 96.

[0125] S93: The three scale features after channel mapping are respectively input into a shared lightweight convolutional structure for feature transformation. The shared lightweight convolutional structure includes depthwise separable convolution and point convolution. Different scale detection branches share some convolutional parameters to reduce redundant feature transformation calculations in the detection head.

[0126] S94: Features from the shared lightweight convolutional structure are input to the bounding box regression branch and the class prediction branch, respectively. The bounding box regression branch outputs the target bounding box coordinates and confidence score, while the class prediction branch outputs the flame class probability and smoke class probability.

[0127] S95: The detection head outputs the detection results at three scales, P3, P4 and P5, respectively, and summarizes the detection results at each scale to obtain the candidate detection boxes, categories and confidence scores of flame and smoke targets.

[0128] Step S10: Model training and parameter optimization.

[0129] S101: Set training parameters. In one specific implementation, the model training input image size is 640×640, the number of categories is 2, including flame and smoke; the number of training rounds is set to 100, the batch size is set to 64, the optimizer is SGD, and the initial learning rate is set to 0.01.

[0130] S102: Training the improved flame and smoke detection network. The model parameters are learned using the training set, and model performance is monitored using the validation set. During training, the weights of the model with the best performance on the validation set are saved as the final detection model.

[0131] S103: Determine the final detection model. After training, select the optimal model weights from the validation set mAP50 or mAP50-95 as the final model for subsequent flame and smoke image detection.

[0132] Step S11: Output of model inference and detection results.

[0133] S111: Obtain the image to be detected. Use the monitoring image, video frame, or test set image as the image to be detected, and record the original size of the image to be detected.

[0134] S112: Perform scale normalization. Scale the image to be detected to 640×640 and then input it into the final, trained detection model.

[0135] Step S12: Evaluation of detection performance and verification of results.

[0136] S121: Set evaluation metrics. Evaluate the final detection model using the test set. Evaluation metrics include Precision, Recall, mAP50, mAP50-95, number of parameters, computational cost, and inference speed.

[0137] S122: Comparison with the basic model. To verify the technical effectiveness of the method of this invention, a comparative test was conducted between the method of this invention and the basic YOLO11n model under the same dataset partitioning, input size, and training parameters. The test results are shown in Table 1.

[0138] Table 1

[0139]

[0140] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A lightweight flame and smoke detection method based on context-aware gating feature enhancement, characterized in that, Includes the following steps: S1: Obtain a publicly available flame and smoke detection dataset, organize and format-verify the images and their corresponding annotation files in the dataset, and divide them into a training set, a validation set, and a test set according to a preset ratio; S2: Construct an initial flame and smoke detection model based on the YOLO11n target detection network. The initial flame and smoke detection model includes a backbone network, a feature fusion network, and a detection head. S3: Introduce a context-aware gated feature enhancement module CAGF into the backbone network and / or feature fusion network, construct a C3k2CAGF structure, and replace part of the C3k2 feature extraction module in the initial flame and smoke detection model with the C3k2CAGF structure; S4: Set up a QKV-guided splitting and fusion module QSF in the high-level semantic feature layer. Generate branch gating weights, spatial gating features and channel gating features through the QSF module, and perform adaptive modulation on the split spatial branches and channel branches. S5: In the feature fusion network, features of different scales are upsampled, spliced ​​and enhanced to output small-scale detection features, medium-scale detection features and large-scale detection features. S6: The lightweight shared detection head SLD-Head is used to predict the small-scale, medium-scale, and large-scale detection features, and output the category, confidence level, and bounding box coordinates of the flame and smoke targets. S7: Use the training set and validation set to train and optimize the parameters of the flame and smoke detection model improved in step S6 to obtain the optimal detection model, and use the test set to evaluate the performance of the optimal detection model.

2. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 1, characterized in that, The CAGF module includes a fast local branch, a context branch, a gating branch, and a retention branch; wherein, the fast local branch is used to extract local detail features, the context branch is used to extract multi-scale context features, the gating branch is used to dynamically modulate the enhanced features, and the retention branch is used to preserve the input feature information.

3. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 2, characterized in that, The fast local branch includes the DGPartialConv3 module, which divides the input features into convolutional channel groups and reserved channel groups along the channel dimension. Only the convolutional channel groups are subjected to 3×3 convolution operations, while the reserved channel groups retain their features unchanged. The convolutional channel groups after convolution processing are concatenated with the reserved channel groups to concatenate features, thereby reducing computational overhead while preserving the ability to extract local features.

4. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 2, characterized in that, The context branch includes a DAC module, which has multiple parallel deep dilated convolution branches. Each deep dilated convolution branch uses a different dilation rate to extract context features under the corresponding receptive field. The output features of each branch are concatenated along the channel dimension and then fused by a 1×1 convolution.

5. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 1, characterized in that, The C3k2CAGF structure first performs channel mapping on the input features through a 1×1 convolution, converting the input features into a feature map with twice the number of intermediate channels; then, the feature map is split into a retention branch and an enhancement branch along the channel dimension. The retention branch directly participates in subsequent fusion, while the enhancement branch sequentially inputs one or more CAGF modules to perform feature enhancement; finally, the initial features of the retention branch and enhancement branch, as well as the outputs of each level of CAGF module, are concatenated along the channel dimension and fused through a 1×1 convolution to complete the output.

6. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 1, characterized in that, The QSF module first maps the input features using 1×1 convolution pairs to obtain preprocessed features; The preprocessed features are split into spatial branches and channel branches along the channel dimension. At the same time, a lightweight QKV descriptor is input to extract the branches, generating Q features, K features and V features.

7. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 6, characterized in that, The Q-feature and K-feature are multiplied element-wise to obtain the QK correlation feature, which is then subjected to global average pooling to obtain the QK descriptor. The V-feature is then subjected to global average pooling to obtain the V descriptor. The QK descriptor and V descriptor are concatenated and input into the branch gating network, where the spatial branch weights and channel branch weights are generated by the Sigmoid function.

8. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 7, characterized in that, The Q feature and V feature are meand along the channel dimension and then concatenated, and input into the group-level spatial gating module to generate spatial gating features; The QK descriptor input channel gating module generates channel gating features; the spatial branch is modulated based on the spatial branch weight and the spatial gating features, and the channel branch is modulated based on the channel branch weight and the channel gating features.

9. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 8, characterized in that, The spatial branch and the channel branch employ cross-gated modulation, as shown in the formula: in, Represents spatial branching characteristics, Indicates channel branching characteristics, Indicates the spatial branch weight, Indicates the channel branch weight. Indicates spatial gating characteristics, Indicates channel gating characteristics, Indicates the shared gating scaling factor. Indicates the characteristics after spatial branch modulation. This indicates the characteristics after channel branch modulation.

10. The lightweight flame and smoke detection method based on context-aware gating feature enhancement according to claim 1, characterized in that, The SLD-Head lightweight shared detection head includes a channel mapping layer, a shared lightweight convolutional layer, a bounding box regression branch, and a category prediction branch. Detection features at different scales are mapped to a unified number of hidden channels by the channel mapping layer and then input into the shared lightweight convolutional layer to reduce redundant parameters in each scale detection branch.