A smoke image detection method based on split Top-K attention mechanism
By constructing a deep learning network based on the split Top-K attention mechanism, the accuracy problem of smoke detection under foggy conditions is solved, efficient smoke recognition in foggy and hazy environments is achieved, and the detection accuracy and adaptability are improved.
Patent Information
- Application Number
- CN202411286918.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2044-09-13
AI Technical Summary
Existing smoke detection methods lack accuracy under foggy conditions, especially deep learning-based methods, which have high parameter counts, poor time performance, and fail to effectively deal with the similarity of smoke features in foggy environments, resulting in a high false detection rate.
A deep learning network based on split Top-K attention mechanism is adopted to construct a smoke detection model through adaptive dark channel prior guidance network, feature extraction network and cross-stage fusion module. The model is trained using a fully supervised method to extract global features of the image and reduce noise of irrelevant long-range dependencies.
It improves the accuracy of smoke detection under foggy conditions, enhances the adaptability and detection accuracy of the model in foggy and hazy environments, and is suitable for deployment on edge computing devices.
Smart Images

Figure CN119107508B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of fire detection technology, and in particular to a smoke image detection method based on a split Top-K attention mechanism. Background Art
[0002] In industrial environments, fires pose a significant threat to human life and cause significant property damage. Therefore, timely fire detection and control are crucial. In the early stages of a fire, smoke often appears before the flames, making smoke detection a crucial component of early fire warning systems. Smoke detection can be broadly categorized into two technical approaches. One is based on smoke sensors, which offer high accuracy but a limited detection range, making them suitable only for specific indoor scenarios. In complex industrial workshops and outdoor IoT environments, fixed smoke sensors can lead to latency and high false alarm rates. The other is based on computer vision technology. The widespread use of monitoring devices in IoT environments has created a broad space for the development of this technology. Computer vision-based smoke detection methods can be broadly divided into two categories: traditional image processing methods and deep learning-based methods.
[0003] Early image-based smoke detection methods typically employed manually designed prior information based on smoke statistical features, such as color, texture, and statistical properties. For example, smoke color can change significantly during a fire, while smoke texture can reveal its diffusion pattern and speed. However, since smoke morphology and properties can vary significantly depending on fire type, burning material, and environmental conditions, fixed prior features may not accurately capture smoke in all situations. Furthermore, changing environmental conditions can significantly impact these methods. Statistical properties can also be affected by ambient noise or background variations, increasing the likelihood of false positives. A drawback of these methods is that they often require manual adjustment of filtering parameters, limiting their application to certain specific conditions. When detection conditions vary, such as in different environments and detection distances, they often suffer from high false positive rates. Convolutional neural networks (CNNs) have demonstrated powerful modeling capabilities in image processing. Unlike prior-based methods, these deep learning models do not rely on a single feature, but instead automatically learn high-level features from large amounts of labeled data. This has led to widespread application in vision-based smoke detection, achieving encouraging results. Deep learning-based methods such as CNNs have significantly improved the accuracy of smoke detection. However, due to the inherent limited receptive field of CNNs and the lack of well-designed architectures, their detection accuracy still needs to be improved. Most studies focus on normal conditions, and there is limited research on smoke detection under foggy conditions. To address the limitations of CNNs, the Transformer architecture has been introduced to various vision tasks, including smoke detection, and has shown excellent performance. However, these Transformer-based methods usually have a large parameter count and poor time performance, which makes them unsuitable for deployment on edge computing devices. In summary, existing smoke detection methods have the following main shortcomings: prior-based methods lack generalization and accuracy; deep learning-based methods usually have a large parameter count and poor time performance, and poor real-time and edge device deployability feasibility; most existing methods do not take foggy conditions into account, in which the feature similarity between smoke and fog significantly increases the false detection rate.
[0004] Therefore, how to improve the accuracy of smoke image detection under foggy conditions is an urgent problem that needs to be solved. Summary of the Invention
[0005] This application provides a smoke image detection method based on the split Top-K attention mechanism. By constructing a deep learning network based on the split Top-K attention mechanism, it can effectively extract global features from the long-distance noise of the image and improve the accuracy of smoke detection under foggy conditions.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a smoke image detection method based on a split Top-K attention mechanism, the method comprising:
[0008] Constructing a smoke network model and training the smoke network model using a fully supervised method to obtain a pre-trained smoke network model. The smoke network model includes, from input to output, an adaptive dark channel prior guidance network, a feature extraction network, a cross-stage fusion module, and a linear classifier. The feature extraction network includes extraction modules in four different stages. The extraction modules in the third and fourth stages are constructed based on the Transformer module with a Top-K attention mechanism.
[0009] Collecting a smoke image and inputting the image into the adaptive dark channel prior guidance network of the pre-trained smoke network model;
[0010] The adaptive dark channel prior guide network extracts features of the smoke image, and uses the features to distinguish smoke and non-smoke areas to obtain enhanced image features;
[0011] The feature extraction network receives the enhanced image features, and each extraction module sequentially downsamples the enhanced image features to obtain a hierarchical information feature map corresponding to each stage, wherein the extraction modules in the third and fourth stages aggregate local features and global features in the enhanced image features to reduce noise irrelevant to long-range dependencies;
[0012] The stage fusion module aggregates the hierarchical information feature maps of different stages to obtain aggregated features, and inputs the aggregated features into the linear classifier;
[0013] The linear classifier predicts scores of different stages based on the aggregated features, and outputs a category corresponding to the smoke image based on the scores.
[0014] In a preferred example of the present application, it can be further configured that the adaptive dark channel prior guidance network includes a mapping module, an adaptive dark channel extraction module, and a prior information fusion module. The adaptive dark channel prior guidance network extracts features of the smoke image, uses the features to distinguish smoke and non-smoke areas, and obtains enhanced image features, including:
[0015] The mapping module maps the smoke image to obtain mapping features;
[0016] The adaptive dark channel extraction module extracts the prior information of the smoke image;
[0017] The prior information fusion module fuses the mapping features with the prior information to obtain enhanced image features.
[0018] In a preferred example of the present application, it can be further configured that the adaptive dark channel extraction module extracts the prior information of the smoke image, including:
[0019] The smoke image Convert to a tensor Where B and C represent the batch size and the number of channels respectively. represents a set of real numbers, H and W represent the height and width of the image respectively, and the tensor is processed by the minimum operation to obtain the minimum channel tensor;
[0020] Using a maximum pooling layer with a window size of k and applying two negative extraction regions, the calculation process is as follows:
[0021]
[0022] Among them, T dark is the extracted dark channel tensor, Represents the maximum pooling layer with a window size of k;
[0023] T dark It is input into two convolutional layers and converted into a network of size A dark channel priori feature matrix of learnable parameters is provided, and prior information of the smoke image is obtained based on the dark channel priori feature matrix.
[0024] In a preferred example of the present application, it can be further configured that the extraction modules in the third and fourth stages aggregate the local features and global features in the enhanced image features, including:
[0025] The extraction modules of the third and fourth stages aggregate local features and global features in the enhanced image features, including:
[0026] Define the number of attention heads in stage i as N hi , by query and key Generating attention maps L = H × W represents the sequence length, where H and W represent the height and width of the image respectively, and D represents the dimension of the feature. represents the set of real numbers;
[0027] During the self-attention process, the attention map M is divided into two parts using the head splitting operation, and we get and The split ratio is determined by the head split ratio α;
[0028] The Top-K attention mechanism in the third and fourth stages processes M α , get local features;
[0029] Using dense attention to capture M 1-α The global features are obtained.
[0030] In a preferred example of the present application, it can be further configured to introduce a Top-K selection operator into the extraction modules of the third and fourth stages, and use the Top-K selection operator to identify and retain K attention scores.
[0031] In a preferred example of the present application, it can be further configured that the stage fusion module aggregates the hierarchical information feature maps of different stages to obtain aggregated features, including:
[0032] The feature alignment module of the stage fusion module normalizes the hierarchical information feature maps of different stages to the same spatial resolution and high channel number to obtain a standardized feature map;
[0033] The multi-head cross attention module of the stage fusion module receives the standardized feature map, extracts and integrates the information of the standardized feature maps of different stages, and obtains aggregated features.
[0034] In a second aspect, the present application provides a smoke image detection device based on a split Top-K attention mechanism, the device comprising:
[0035] A model construction module is used to construct a smoke network model and train the smoke network model using a fully supervised method to obtain a pre-trained smoke network model. The smoke network model includes an adaptive dark channel prior guidance network, a feature extraction network, a cross-stage fusion module, and a linear classifier from the input end to the output end. The feature extraction network includes extraction modules in four different stages. The extraction modules in the third and fourth stages are constructed based on the Transformer module with a Top-K attention mechanism.
[0036] A data acquisition module, configured to acquire smoke images and input the images into the adaptive dark channel prior guidance network of the pre-trained smoke network model;
[0037] A dark channel module is used to control the adaptive dark channel prior guidance network to extract features of the smoke image, and use the features to distinguish smoke and non-smoke areas to obtain enhanced image features;
[0038] A feature extraction network module is used to control the feature extraction network to receive the enhanced image features, and each extraction module sequentially downsamples the enhanced image features to obtain a hierarchical information feature map corresponding to each stage, wherein the extraction modules in the third and fourth stages aggregate local features and global features in the enhanced image features to reduce noise irrelevant to long-range dependencies;
[0039] a stage fusion module, configured to control the stage fusion module to aggregate the hierarchical information feature maps of different stages to obtain aggregated features, and input the aggregated features into the linear classifier;
[0040] The linear classifier module is used to control the linear classifier to predict scores of different stages based on the aggregated features, and output the category corresponding to the smoke image based on the scores.
[0041] In a third aspect, the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, the steps of the smoke image detection method based on the split Top-K attention mechanism as described in any one of the above items are implemented.
[0042] In a fourth aspect, the present application provides a computer-readable storage medium having a program stored thereon, wherein when the program is executed by a processor, a smoke image detection method based on a split Top-K attention mechanism as described in any one of the above items is implemented.
[0043] In a fifth aspect, the present application provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the steps of the smoke image detection method based on the split Top-K attention mechanism as described in any one of the above items.
[0044] In summary, compared with the prior art, the technical solutions provided by the embodiments of the present application have at least the following beneficial effects:
[0045] This application provides a smoke image detection method based on a split Top-K attention mechanism. This method constructs a smoke network model and trains it using a fully supervised approach. Smoke images are then collected and fed into the pre-trained smoke network model, which then outputs a classification of the smoke image. This method enables more accurate classification of smoke images under foggy conditions. The adaptive dark channel prior guidance network in the model enhances the representation of smoke images under foggy conditions. The feature extraction network obtains hierarchical information from the image through downsampling. The third and fourth stage extraction modules of the feature extraction network are constructed based on the Transformer module with a split Top-K attention mechanism. These modules effectively extract global features from long-range noise in the image, aggregate local and global features, and reduce noise related to irrelevant long-range dependencies. The cross-stage fusion module aggregates the outputs from the four stages, improving the flexibility and adaptability of smoke features at different scales, thereby improving detection accuracy. The aggregated results are fed into a linear classifier to predict scores for four pre-defined categories: normal, smoke, fog, and smoke with fog. In summary, this method improves the accuracy of smoke image category detection under foggy conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A flowchart of a smoke image detection method based on a split Top-K attention mechanism is provided for one embodiment of the present application.
[0047] Figure 2 A smoke detection model structure diagram of a smoke image detection method based on a split Top-K attention mechanism provided in one embodiment of the present application.
[0048] Figure 3 A structural diagram of a split Top-K attention mechanism for a smoke image detection method based on a split Top-K attention mechanism is provided in one embodiment of the present application.
[0049] Figure 4 A structural diagram of a dual-path attention downsampling method for smoke image detection based on a split Top-K attention mechanism provided in one embodiment of the present application.
[0050] Figure 5 A structural diagram of an adaptive dark channel prior guidance network for a smoke image detection method based on a split Top-K attention mechanism provided in one embodiment of the present application.
[0051] Figure 6 A structural diagram of a prior information fusion module of a smoke image detection method based on a split Top-K attention mechanism provided in one embodiment of the present application.
[0052] Figure 7 A cross-stage fusion module structure diagram of a smoke image detection method based on a split Top-K attention mechanism is provided in one embodiment of the present application.
[0053] Figure 8 A structural diagram of a smoke image detection device based on a split Top-K attention mechanism provided in one embodiment of the present application. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0055] In one embodiment of the present application, a smoke image detection method based on split Top-K attention mechanism is provided. Figure 1 As shown, the method includes:
[0056] S100: Construct a smoke network model, and use a fully supervised method to train the smoke network model to obtain a pre-trained smoke network model. The smoke network model includes an adaptive dark channel prior guidance network, a feature extraction network, a cross-stage fusion module and a linear classifier from the input end to the output end. The feature extraction network includes extraction modules in four different stages. The extraction modules of the third and fourth stages are constructed based on the Transformer module of the Top-K attention mechanism.
[0057] Specifically, the structure of the smoke network model is as follows: Figure 2 As shown, it includes an adaptive dark channel prior guidance network, a feature extraction network consisting of 4 stages, a cross-stage fusion module and a linear classifier ( Figure 2 The network is an end-to-end fully supervised deep learning network. The network directly learns the mapping from smoke image to smoke image category. The input of the network is a 3-channel RGB image, and the output is the category of the image, which includes normal, smoke, fog, and smoke with fog. The system determines whether to send an alarm to the control center based on the output image category.
[0058] The extraction modules in the third and fourth stages are based on the Transformer module structure of the Top-K attention mechanism. Figure 2 The calculation process is as follows:
[0059] X′ l =X l-1 +STKA(X l-1 );
[0060] X l =X′ l +Le-MLP(X l-1 );
[0061] where X′ l and X l Represents the output of split Top-K attention and local enhancement MLP (Le-MLP).
[0062] In standard self-attention, for a given query Q, key K, and value V, the calculation process is as follows:
[0063] Attention(Q,K,V)=softmax(QK T / √d+pose)V;
[0064] Here, d represents the dimension of the input feature sequence, and pose represents the positional encoding. In standard global attention, all pixels are densely connected, which weakens local features and introduces irrelevant long-range dependent noise, affecting recognition accuracy. This problem is particularly important in smoke detection tasks.
[0065] To solve this problem, the split Top-K attention mechanism (STKA) used in this embodiment can filter out irrelevant noise while retaining the most effective attention score and adaptively maintaining dense attention capabilities. The specific structure is as follows: Figure 3 shown.
[0066] Specifically, suppose the number of attention heads in stage i is defined as N hi , by query and key Generating attention maps L = H × W represents the sequence length, where H and W represent the height and width of the image respectively, and D represents the dimension of the feature. represents the set of real numbers, .
[0067] Different from traditional self-attention, we use a head-splitting operation to split the attention map M into two parts, obtaining and The split ratio is determined by the head split ratio α.
[0068] Ma is processed by the Top-K attention mechanism to filter out irrelevant long-term dependencies and retain the most effective attention scores.
[0069] A Top-K selection operator is introduced, which identifies and retains the most informative K attention scores, ensuring that each query only interacts with the most relevant keys and reducing noise and unnecessary interference information.
[0070] The other part, M 1-α Used for regular dense attention to adaptively capture necessary global features.
[0071] Finally, the two parts of the attention map are concatenated and softmaxed to obtain the attention score, which is then multiplied by the value to produce the final output.
[0072] The calculation process of the split Top-K attention mechanism (STKA) is summarized as follows:
[0073]
[0074] STKA(Q,K,V)=softmax(Cat[τ k (M α ), M 1-α ])V;
[0075] Among them, τ k It is a learnable Top-K selection operator:
[0076]
[0077] For hierarchical feature extraction backbone networks, effective downsampling strategies can reduce the loss of high-dimensional information and enhance the representation ability of the model. Currently, most visual backbone networks use strided convolution or pooling layers for downsampling. Recently, some studies have begun to explore attention-based downsampling methods, specifically by reducing the number of query tags in the attention mechanism to achieve downsampling. Dual-path attention downsampling (DP-Attention-DS) combines the advantages of both, such as Figure 4 shown.
[0078] DP-Attention DS consists of two branches: convolutional downsampling and attention downsampling. For attention downsampling, we use pooling as a static local downsampling method and 3×3 depthwise convolution as a learnable local downsampling method, and combine the results and project them to the query dimension. The result of the attention downsampling module is residually connected with the downsampling result of the strided convolution to form a local and global integration. However, the dual-path attention downsampling also introduces additional computational overhead. In order to maintain real-time inference while ensuring accuracy, this embodiment applies DP-Attention-DS between the two stages containing the STKformer block and uses strided convolution for downsampling in the early high-resolution stage.
[0079] The smoke network model is trained using a fully supervised method, and the specific steps include:
[0080] The network is first trained on a labeled dataset containing images from various categories. Each sample in the dataset is labeled to indicate its category. During training, the network learns to identify image features through forward propagation and adjusts weights through backpropagation using a loss function to minimize prediction error. After multiple rounds of iterative training, the network gradually learns to classify images into different categories, thereby detecting images containing smoke. The specific training process includes the following steps:
[0081] The training method is fully supervised, using a labeled dataset containing images from multiple categories. Each sample in the dataset is labeled to indicate its category. During training, the network learns to identify image features through forward propagation and adjusts weights through backpropagation of the loss function to minimize prediction error.
[0082] The network structure parameters can be set as follows: the number of layers in the four stages, denoted as [N1, N2, N3, N4], is set to [3, 3, 9, 6]. The corresponding channel numbers, denoted as [C1, C2, C3, C4], are set to [32, 48, 120, 224]. In the adaptive dark channel prior guidance network, the window size of the Maxpooling layer used in the adaptive dark channel extraction module is set to k = 5. For the last two stages, the STKA head split ratio α is set to 0.75, and the TopK is set to [100, 25].
[0083] First, we pre-trained the model for 300 epochs on the ImageNet dataset. Then, we fine-tuned the pre-trained network parameters and trained each model 100 times with a base learning rate of 0.0002 and an initial learning rate of 2×10 -7 5 warm-up periods with a minimum learning rate of 1×10 -6 This example uses a weight decay of 0.05 and applies gradient clipping at 5.0 to stabilize training.
[0084] The AdamW optimizer is used, and the epsilon is set to 1×10 -8 , beta is (0.9, 0.999). For network training and validation, the present invention resizes the image to 224×224 as input and normalizes it. Experimental verification shows that the trained network model has a high accuracy rate for smoke detection.
[0085] S200: Collecting a smoke image and inputting the image into the adaptive dark channel prior guidance network of the pre-trained smoke network model;
[0086] S300: The adaptive dark channel prior guide network extracts features of the smoke image, and uses the features to distinguish smoke and non-smoke areas to obtain enhanced image features;
[0087] Specifically, the structure of the adaptive dark channel prior guidance network is as follows: Figure 5 As shown in the figure, the adaptive dark channel extraction module enhances the model's adaptability to complex foggy environments. The prior information fusion module uses a fusion attention strategy to improve smoke detection accuracy while preserving image details. The input RGB smoke image takes two routes: one is mapped into the feature space by the input mapping module, and the other is input into a learnable prior knowledge extraction module. This prior information is then fused with the mapped features of the smoke image through a prior knowledge fusion module. These two modules work together to extract and utilize key image features, effectively distinguishing between smoke and non-smog areas and adaptively reducing the impact of foggy conditions.
[0088] S400: The feature extraction network receives the enhanced image features, and each extraction module sequentially downsamples the enhanced image features to obtain a hierarchical information feature map corresponding to each stage, wherein the extraction modules in the third and fourth stages aggregate local features and global features in the enhanced image features to reduce noise irrelevant to long-range dependencies;
[0089] The structure of the feature extraction network is as follows Figure 2 As shown, this embodiment uses dual-path attention downsampling, and the specific implementation includes:
[0090] For hierarchical feature extraction backbone networks, effective downsampling strategies can reduce the loss of high-dimensional information and enhance the representation ability of the model. Currently, most visual backbone networks use strided convolution or pooling layers for downsampling. Recently, some studies have begun to explore attention-based downsampling methods, specifically by reducing the number of query tags in the attention mechanism to achieve downsampling. Dual-path attention downsampling (DP-Attention-DS) combines the advantages of both, such as Figure 4 As shown in Figure 2, DP-Attention-DS consists of two branches: convolutional downsampling and attention downsampling. For attention downsampling, we use pooling as a static local downsampling method and 3×3 depthwise convolution as a learnable local downsampling method. The results are combined and projected to the query dimension. The results of the attention downsampling module are residually connected with the downsampling results of the strided convolution to form a local and global integration.
[0091] However, dual-path attention downsampling also introduces additional computational overhead. To maintain real-time inference while ensuring accuracy, this embodiment applies DP-Attention-DS between the two stages containing the STKformer block and uses strided convolution for downsampling in the early high-resolution stage.
[0092] S500: The stage fusion module aggregates the hierarchical information feature maps of different stages to obtain aggregated features, and inputs the aggregated features into the linear classifier;
[0093] S600: The linear classifier predicts scores of different stages based on the aggregated features, and outputs a category corresponding to the smoke image based on the scores.
[0094] In this embodiment, a smoke network model is constructed and trained using a fully supervised approach. Smoke images are then collected and fed into the pre-trained smoke network model, which then outputs a classification of the smoke image. This allows for more accurate classification of smoke images under foggy conditions. The adaptive dark channel prior guidance network in the model enhances the representation of smoke images under foggy conditions. The feature extraction network obtains hierarchical information from the image through downsampling. The extraction modules in the third and fourth stages of the feature extraction network are constructed based on Transformer modules with a split Top-K attention mechanism. These modules effectively extract global features from long-range image noise, aggregate local and global features, and reduce noise related to irrelevant long-range dependencies. The cross-stage fusion module aggregates the outputs from the four stages, improving the flexibility and adaptability of smoke features at different scales, thereby enhancing detection accuracy. The aggregated results are fed into a linear classifier to predict scores for four pre-defined categories: normal, smoke, fog, and smoke with fog. In summary, this method improves the accuracy of smoke image category detection under foggy conditions.
[0095] In some embodiments, the adaptive dark channel prior guidance network includes a mapping module, an adaptive dark channel extraction module, and a prior information fusion module. The adaptive dark channel prior guidance network extracts features of the smoke image and uses the features to distinguish smoke and non-smoke areas to obtain enhanced image features, including:
[0096] The mapping module maps the smoke image to obtain mapping features;
[0097] The adaptive dark channel extraction module extracts the prior information of the smoke image. Specifically, the implementation steps include:
[0098] The smoke image Convert to a tensor Where B and C represent the batch size and the number of channels respectively. represents a set of real numbers, H and W represent the height and width of the image respectively, and the tensor is processed by the minimum operation to obtain the minimum channel tensor;
[0099] Using a maximum pooling layer with a window size of k and applying two negative extraction regions, the calculation process is as follows:
[0100]
[0101] Among them, T dark is the extracted dark channel tensor, Represents the maximum pooling layer with a window size of k;
[0102] T dark It is input into two convolutional layers and converted into a network of size A dark channel priori feature matrix of learnable parameters is provided, and prior information of the smoke image is obtained based on the dark channel priori feature matrix.
[0103] The prior information fusion module fuses the mapping features with the prior information to obtain enhanced image features.
[0104] In practice, traditional dark channel extraction directly selects the minimum brightness value from the image. Given an input image The corresponding dark channel image I dark It can be obtained by the following formula:
[0105] Among them, I c (y) represents the cth channel of channel I at pixel y, while Ω(x) represents the local region at x. This method of extracting dark channels effectively identifies fog and mitigates its impact on visual images. However, this method is not suitable for real-time smoke detection systems and cannot be accelerated or trained using deep learning frameworks.
[0106] Furthermore, its fixed parameters limit its generalization ability.
[0107] Therefore, this embodiment uses an adaptive dark channel extraction strategy, which calculates the dark channel in tensor form, improving the model speed. This method combines dark channel priors with deep learning feature extraction networks, improving adaptability to complex foggy environments.
[0108] The process is similar to the traditional dark channel extraction. First, the input image Convert to a tensor Where B and C represent the batch size and number of channels, respectively. The input tensor is first processed through a minimum operation to obtain the minimum channel tensor. Unlike the original minimum filter in traditional dark channel extraction, this method uses a maximum pooling layer with a window size of k and applies two negations to achieve regional minimum extraction. This design allows the dark channel extraction network to be trained and tested in parallel, accelerating computation using deep learning frameworks. The computation process can be summarized as follows:
[0109]
[0110] Among them, T dark is the extracted dark channel tensor. T dark It is further input into two convolutional layers to convert it into a network of size The dark channel prior feature matrix with learnable parameters is constructed. This feature matrix helps the subsequent feature extraction process and enhances the recognition robustness under haze conditions.
[0111] To better integrate the adaptive dark channel feature matrix into the subsequent feature extraction process, this embodiment uses a prior information fusion module. This module adopts a Transformer-like structure, replacing the traditional self-attention layer with prior fusion attention to utilize prior information that helps the feature extraction process, thereby enhancing the model's representation capabilities. Its operation process is as follows:
[0112] X′ out =PFA[X p , X I ]+X I ;
[0113] X out =LeMLP(X′ out )+X′ out ;
[0114] Specifically, the features of the original input embedding features are used to generate the Key (K) and Value (V) of PFA through 1×1 convolution and 3×3 depth convolution. At the same time, the prior features extracted by the adaptive dark channel extraction module generate the query (Q prior ) and additional V value (V prior ). The Key (K) generated from the original output and the Query (Q) derived from the prior features prior ) is used in the transposed attention mechanism to calculate the prior fused attention map (M prior ). Then the obtained M prior With V and V prior Together they are used for attention point multiplication. The final results are concatenated and passed through a 1×1 convolutional layer for channel adjustment to obtain the final output. This process enhances the model’s predictive power by integrating prior information and current input data. The overall module is as follows Figure 6 shown.
[0115] This embodiment utilizes an adaptive dark channel prior guidance mechanism, which, compared to existing technologies, enhances smoke recognition in foggy conditions and more effectively guides network learning. It employs a pooling operation rather than minimum filtering, enabling the dark channel prior extraction module to effectively utilize learnable parameters and adaptively mitigate the effects of fog. This extracted prior information is then used in a prior information fusion module to guide feature extraction, improving the robustness of the model.
[0116] In some embodiments, the stage fusion module aggregates the hierarchical information feature maps of different stages to obtain aggregated features, including:
[0117] The feature alignment module of the stage fusion module normalizes the hierarchical information feature maps of different stages to the same spatial resolution and high channel number to obtain a standardized feature map;
[0118] The multi-head cross attention module of the stage fusion module receives the standardized feature map, extracts and integrates the information of the standardized feature maps of different stages, and obtains aggregated features.
[0119] In practice, the diverse sizes and shapes of smoke pose a significant challenge in smoke recognition tasks. In a hierarchical feature extraction network, information processed at different stages is processed in different dimensions, resulting in differences in their ability to recognize smoke of different sizes. In order to effectively utilize the feature information output by the hierarchical network, this embodiment uses a cross-stage fusion module, such as Figure 7 As shown in Figure 2, it primarily consists of a feature alignment module and a multi-head crisscross attention (MHCA). The goal is to enable the model to effectively aggregate feature information from different stages, rather than relying solely on the final stage for classification. This flexibility allows the model to adapt to the characteristics of smoke of varying sizes, improving smoke detection accuracy.
[0120] The main function of the Feature Alignment Module (FAM) is to normalize the feature maps (F1, F2, F3, F4) of different stages of the network to the same spatial resolution and high number of channels. This ensures that the features from different stages can be considered uniformly and effectively fused. Specifically, we first use an AvgPooling layer to reduce the size of the feature maps of the first three stages to Then, the features of all four stages are passed through the convolutional layer to adjust the number of channels to Finally, the features of all four stages are concatenated to form the cross-stage fusion feature
[0121] The cross-stage fusion module adopts a multi-head cross attention mechanism, which allows the network to learn how to effectively extract and integrate information from features at different stages. This enables the model to focus on finer feature differences, thereby improving detection accuracy. The calculation process of multi-head cross attention is as follows: Figure 7 As shown in the multi-head cross attention in.
[0122] Specifically, in Multi-Head Cross Attention (MHCA), the query comes from the output F4 of the final stage of the model, while the key and value come from the aggregated output F of all stages. fusion The query, key, and value are processed in MHCA to achieve feature interaction, ensuring that features from earlier stages are effectively focused on at deeper levels. After completing the MHCA interaction, the data enters a feedforward network similar to the Transformer to produce the final output. The computation process can be summarized as follows:
[0123] Qb=Conv 1×1 (F4);
[0124] K h , V h =Conv 1×1 (F fusion );
[0125] F′ out =F4+MHCA(Q b , K h , V h );
[0126] F out =F′ out +LeMLP(F′ out );
[0127] where Q b represents the query matrix from the underlying stage features, and K h and V h represents the key and value matrices from the hierarchical aggregated features. The input and final output of Le-MLP are denoted as F′ respectively. out and F out .
[0128] In this embodiment, by using a cross-stage fusion method, the problem of feature aggregation in the hierarchical network is overcome, the features of different stages are effectively combined, and flexible adaptation of smoke features at different scales is allowed, thereby improving the accuracy of smoke detection.
[0129] This application also provides a smoke image detection device based on the split Top-K attention mechanism, please refer to Figure 8 As shown, the device includes:
[0130] A model construction module 100 is used to construct a smoke network model. The smoke network model is trained using a fully supervised method to obtain a pre-trained smoke network model. The smoke network model includes, from the input end to the output end, an adaptive dark channel prior guidance network, a feature extraction network, a cross-stage fusion module, and a linear classifier. The feature extraction network includes extraction modules in four different stages. The extraction modules in the third and fourth stages are constructed based on the Transformer module with a Top-K attention mechanism.
[0131] A data acquisition module 200 is used to collect smoke images and input them into the adaptive dark channel prior guidance network of the pre-trained smoke network model;
[0132] A dark channel module 300 is configured to control the adaptive dark channel prior guidance network to extract features of the smoke image, and utilize the features to distinguish smoke and non-smoke areas to obtain enhanced image features;
[0133] A feature extraction network module 400 is configured to control the feature extraction network to receive the enhanced image features, and each extraction module sequentially downsamples the enhanced image features to obtain a hierarchical information feature map corresponding to each stage. The extraction modules in the third and fourth stages aggregate local and global features in the enhanced image features to reduce noise irrelevant to long-range dependencies.
[0134] A stage fusion module 500 is used to control the stage fusion module to aggregate the hierarchical information feature maps of different stages to obtain aggregated features, and input the aggregated features into the linear classifier;
[0135] The linear classifier module 600 is used to control the linear classifier to predict scores of different stages based on the aggregated features, and output the category corresponding to the smoke image based on the scores.
[0136] The functional implementation of each module in the above-mentioned smoke image detection device based on the split Top-K attention mechanism corresponds to the steps in the above-mentioned smoke image detection method embodiment based on the split Top-K attention mechanism, and their functions and implementation processes will not be repeated here one by one.
[0137] The present application also provides a computer device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, the steps of the smoke image detection method based on the split Top-K attention mechanism as described in any of the above embodiments are implemented.
[0138] This application also provides a computer-readable storage medium having a program stored thereon. The computer-readable storage medium refers to a data storage medium and may include, but is not limited to, a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive, and / or a memory stick. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable device. The operating process, operating details, and technical effects of the computer-readable storage medium provided in this embodiment can be found in the above embodiment of a smoke image detection method based on a split Top-K attention mechanism and will not be further described here.
[0139] The application also provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the steps of the smoke image detection method based on the split Top-K attention mechanism as described in any of the above embodiments.
[0140] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0141] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. The above-mentioned embodiments only express several implementation methods of the present application. The description is relatively specific and detailed, but it cannot be understood as a limitation on the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, without departing from the concept of the present application, several variations and improvements can be made, which all fall within the scope of protection of the present application. Therefore, the scope of protection of the patent of this application shall be based on the attached claims.
Claims
1. A smoke image detection method based on split Top-K attention mechanism, characterized in that: include: Constructing a smoke network model and training the smoke network model using a fully supervised method to obtain a pre-trained smoke network model. The smoke network model includes, from input to output, an adaptive dark channel prior guidance network, a feature extraction network, a cross-stage fusion module, and a linear classifier. The feature extraction network includes extraction modules in four different stages. The extraction modules in the third and fourth stages are constructed based on the Transformer module with a Top-K attention mechanism. Collecting a smoke image and inputting the image into the adaptive dark channel prior guidance network of the pre-trained smoke network model; The adaptive dark channel prior guide network extracts features of the smoke image, and uses the features to distinguish smoke and non-smoke areas to obtain enhanced image features; The feature extraction network receives the enhanced image features, and each extraction module sequentially downsamples the enhanced image features to obtain a hierarchical information feature map corresponding to each stage, wherein the extraction modules in the third and fourth stages aggregate local features and global features in the enhanced image features to reduce noise irrelevant to long-range dependencies; The cross-stage fusion module aggregates the hierarchical information feature maps of different stages to obtain aggregated features, and inputs the aggregated features into the linear classifier; The linear classifier predicts scores of different stages based on the aggregated features, and outputs a category corresponding to the smoke image based on the scores.
2. The smoke image detection method based on split Top-K attention mechanism according to claim 1 is characterized in that: The adaptive dark channel prior guidance network includes a mapping module, an adaptive dark channel extraction module and a prior information fusion module. The adaptive dark channel prior guidance network extracts features of the smoke image and uses the features to distinguish smoke and non-smoke areas to obtain enhanced image features, including: The mapping module maps the smoke image to obtain mapping features; The adaptive dark channel extraction module extracts the prior information of the smoke image; The prior information fusion module fuses the mapping features with the prior information to obtain enhanced image features.
3. The smoke image detection method based on split Top-K attention mechanism according to claim 2 is characterized in that: The adaptive dark channel extraction module extracts the prior information of the smoke image, including: The smoke image Convert to a tensor , where B and C represent the batch size and the number of channels respectively, represents a set of real numbers, H and W represent the height and width of the image respectively, and the tensor is processed by the minimum operation to obtain the minimum channel tensor; Using a maximum pooling layer with a window size of k and applying two negative extraction regions, the calculation process is as follows: ; in, is the extracted dark channel tensor, Represents the window size The maximum pooling layer; Will Input into two convolutional layers and convert it into a size of A dark channel priori feature matrix of learnable parameters is used, and prior information of the smoke image is obtained based on the dark channel priori feature matrix.
4. The smoke image detection method based on split Top-K attention mechanism according to claim 1 is characterized in that: The extraction modules of the third and fourth stages aggregate local features and global features in the enhanced image features, including: Define the number of attention heads in stage i as , by query and key Generating attention maps , Represents the sequence length, where H and W represent the height and width of the image respectively. Represents the dimension of the feature, represents the set of real numbers; During the self-attention process, the attention map M is divided into two parts using the head splitting operation, and we get and , where the split ratio is determined by the head split ratio Decide; The Top-K attention mechanism processing in the third and fourth stages , get local features; Using dense attention capture The global features are obtained.
5. The smoke image detection method based on split Top-K attention mechanism according to claim 4 is characterized in that: include: A Top-K selection operator is introduced into the extraction modules of the third and fourth stages, and the Top-K selection operator is used to identify and retain K attention scores.
6. The smoke image detection method based on split Top-K attention mechanism according to claim 1 is characterized in that: The cross-stage fusion module aggregates the hierarchical information feature maps of different stages to obtain aggregated features, including: The feature alignment module of the cross-stage fusion module normalizes the hierarchical information feature maps of different stages to the same spatial resolution and high channel number to obtain a normalized feature map; The multi-head cross attention module of the cross-stage fusion module receives the standardized feature map, extracts and integrates the information of the standardized feature maps of different stages, and obtains aggregated features.
7. A smoke image detection device based on split Top-K attention mechanism, characterized in that: include: A model construction module is used to construct a smoke network model and train the smoke network model using a fully supervised method to obtain a pre-trained smoke network model. The smoke network model includes an adaptive dark channel prior guidance network, a feature extraction network, a cross-stage fusion module, and a linear classifier from the input end to the output end. The feature extraction network includes extraction modules in four different stages. The extraction modules in the third and fourth stages are constructed based on the Transformer module with a Top-K attention mechanism. A data acquisition module, configured to acquire smoke images and input the images into the adaptive dark channel prior guidance network of the pre-trained smoke network model; A dark channel module is used to control the adaptive dark channel prior guidance network to extract features of the smoke image, and use the features to distinguish smoke and non-smoke areas to obtain enhanced image features; A feature extraction network module is used to control the feature extraction network to receive the enhanced image features, and each extraction module sequentially downsamples the enhanced image features to obtain a hierarchical information feature map corresponding to each stage, wherein the extraction modules in the third and fourth stages aggregate local features and global features in the enhanced image features to reduce noise irrelevant to long-range dependencies; a cross-stage fusion module, configured to control the cross-stage fusion module to aggregate the hierarchical information feature maps of different stages to obtain aggregated features, and input the aggregated features into the linear classifier; The linear classifier module is used to control the linear classifier to predict scores of different stages based on the aggregated features, and output the category corresponding to the smoke image based on the scores.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the smoke image detection method based on the split Top-K attention mechanism are implemented as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program, wherein when the program is executed by the processor, the smoke image detection method based on the split Top-K attention mechanism according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising computer instructions, characterized in that When executed by a processor, the computer instructions implement the steps of the smoke image detection method based on the split Top-K attention mechanism described in any one of claims 1 to 6.
Citation Information
Patent Citations
Vision-based foggy day smoke detection method, device, equipment and medium
CN116524430A
Laparoscopic image smoke removal method, system and equipment based on conditional diffusion model
CN117649362A