Fire hazard detection method and device, electronic equipment and storage medium
By introducing multi-headed self-convolution mechanism and CBAM attention mechanism in the fire hazard detection model, the problems of traditional fire detection methods for detection delay and environmental interference at the power operation site are solved, and high accuracy and real-time fire hazards are achieved Test.
Patent Information
- Application Number
- CN202411070245.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-12-06
AI Technical Summary
Traditional fire detection methods are difficult to meet the needs of the power industry due to detection delays, susceptibility to environmental interference and high maintenance costs, especially in complex environments at power operations sites.
Adopting an improved fire hazard detection model, combining the multi-head attention self-convolution mechanism and CBAM attention mechanism, fire hazard detection is carried out on the target image through self-convolution processing, feature extraction, feature fusion and prediction feature layers, improving detection accuracy and model Convergence speed meets real-time requirements.
It improves the accuracy and efficiency of fire hazard detection, enhances the model's ability to focus on key features, and can accurately capture the details and contours of different sizes and targets in complex environments, meeting the real-time detection needs of power operations sites.
Smart Images

Figure CN119091272A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a fire hazard detection method, device, electronic equipment and storage medium. Background Art
[0002] There are often various disasters and risks in the space around outdoor overhead power lines that affect the stable operation of the lines. Various complex environmental hazards and potential safety risks have a great adverse impact on the power system. Early detection of fire sources and detection and evaluation of surrounding burning materials are crucial for handling emergencies and reducing losses. In addition, power operation sites are often large in area and have complex environmental conditions, which puts higher requirements on the coverage and adaptability of fire detection systems.
[0003] At present, traditional fire detection methods are all based on physical sensors, but this method is often difficult to meet the needs of the power industry due to its detection delay, susceptibility to environmental interference and high maintenance costs. Therefore, a new fire hazard detection method is urgently needed. Summary of the invention
[0004] The invention provides a fire hazard detection method, device, electronic equipment and storage medium.
[0005] According to one aspect of the present invention, a fire hazard detection method is provided, which is applied to an electronic device deployed with an improved fire hazard detection model, wherein the improved fire hazard detection model comprises at least a multi-head attention self-convolution mechanism arranged before a feature extraction layer, a CBAM attention mechanism arranged between a feature extraction layer and a feature fusion layer, and a prediction feature layer, and the method comprises:
[0006] Acquire a target image collected from a power operation site, and perform self-convolution processing on the target image through the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image;
[0007] Performing convolution processing on the target image through the self-convolution kernel to obtain a target feature map corresponding to the target image;
[0008] Based on the feature extraction layer, extracting feature maps of different levels from the target feature map;
[0009] The feature maps at different levels are enhanced by the CBAM attention mechanism to obtain enhanced feature maps at different levels.
[0010] Performing feature fusion processing on the enhanced feature maps of different levels through the feature fusion layer to obtain fused feature maps of different scales;
[0011] Fire hazard detection is performed on the fused feature maps of different scales through the prediction feature layer to obtain a fire hazard detection result.
[0012] According to another aspect of the present invention, there is provided a fire hazard detection device, which is configured in an electronic device in which an improved fire hazard detection model is deployed, wherein the improved fire hazard detection model at least includes a multi-head attention self-convolution mechanism arranged before a feature extraction layer, a CBAM attention mechanism arranged between a feature extraction layer and a feature fusion layer, and a prediction feature layer, and the device includes:
[0013] A self-convolution module is used to obtain a target image collected from the power operation site, and perform self-convolution processing on the target image through the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image;
[0014] A first feature extraction module, used for performing convolution processing on the target image through the self-convolution kernel to obtain a target feature map corresponding to the target image;
[0015] A second feature extraction module, used for extracting feature maps of different levels from the target feature map based on the feature extraction layer;
[0016] A feature enhancement module, used to perform feature enhancement on feature maps of different levels through the CBAM attention mechanism to obtain enhanced feature maps of different levels;
[0017] A feature fusion module, used for performing feature fusion processing on the enhanced feature maps of different levels through the feature fusion layer to obtain fused feature maps of different scales;
[0018] The detection module is used to perform fire hazard detection on the fused feature maps of different scales through the prediction feature layer to obtain a fire hazard detection result.
[0019] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0020] at least one processor; and
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the fire hazard detection method described in the embodiment of the present invention.
[0023] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the fire hazard detection method described in the embodiment of the present invention when executed.
[0024] The technical solution of the embodiment of the present invention newly introduces a multi-head attention mechanism and a CBAM attention mechanism into the improved fire hazard detection model. By integrating the multi-head attention self-convolution mechanism, not only the detection accuracy is improved, but also the model convergence speed is accelerated to meet the real-time requirements; and the newly introduced CBAM attention mechanism improves the focus of the improved fire hazard detection model on key features, thereby improving the accuracy of fire hazard detection.
[0025] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1a is a structural schematic diagram of an improved fire hazard detection model provided according to an embodiment of the present invention;
[0028] Figure 1b is a flow chart of a fire hazard detection method provided according to an embodiment of the present invention;
[0029] Figure 2 is a flow chart of a fire hazard detection method provided according to an embodiment of the present invention;
[0030] Figure 3 is a structural schematic diagram of a fire hazard detection device provided according to an embodiment of the present invention;
[0031] Figure 4 It is a schematic diagram of the structure of an electronic device for implementing the fire hazard detection method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0033] In an embodiment of the present invention, in order to improve the accuracy and efficiency of fire hazard detection at the power operation site, an improved fire hazard detection model is pre-designed and trained, and the fire hazard detection model can be optionally improved based on the YOLOv5 model. It should be noted that the reason why the new fire hazard detection model is improved based on the YOLOv5 model instead of improving based on other models is that the YOLOv5s and YOLOv5m models are characterized by fast processing speed, but usually poor performance in accuracy; YOLOv5x provides higher detection accuracy, but because its network is deeper and wider, its processing speed is slower. In order to meet the real-time and accuracy of complex power environment detection, the present invention chooses to make improvements based on the YOLOv5 model with relatively balanced performance.
[0034] In addition to the feature extraction layer (Backbone), feature fusion layer (Neck) and prediction feature layer (Head), the improved fire hazard detection model also includes a newly added multi-head attention self-convolution mechanism (MASC) set before the feature extraction layer and a CBAM attention mechanism set between the feature extraction layer and the feature fusion layer.
[0035] For example, see Figure 1a , which shows a schematic diagram of the network structure of the improved fire hazard detection model. The first layer of the improved fire hazard detection model is the newly added multi-head attention self-convolution mechanism (MASC). The 2nd to 8th layers of the fire hazard detection model are feature extraction layers. The feature extraction layer is mainly composed of Conv module, C3 module, and SPPF module. Among them, Conv module is the basic module in convolutional neural network (CNN), which is mainly composed of convolution layer, batch normalization (BatchNormalization, BN) layer and activation function. The function of Conv module is to extract the local spatial information of input data through convolution operation, and normalize the eigenvalue distribution through BN layer, and finally introduce nonlinear transformation capability through activation function, so as to realize the conversion and extraction of input features. C3 module is an important module used to increase network depth and receptive field in fire hazard detection model. Its main function is to further extract features through cross-layer connection (such as residual connection) and stacking of multiple convolution layers. For the specific structure, please refer to Figure 1aThe structure of C3 in the lower right corner. The SPPF module (Spatial Pyramid Pooling Fast) is mainly used to achieve the fusion of local features and global features. In the fire hazard detection model, the SPPF module performs pooling operations of different scales on the input feature map through multiple pooling layers (such as MaxPool2d) connected in series, and then fuses the pooled feature maps to obtain more comprehensive spatial information. The specific structure of the SPPF module can be found in Figure 1a The structure diagram of SPPF in the lower right corner.
[0036] Furthermore, the 9th, 12th, and 17th layers of the fire hazard detection model are the newly added CBAM attention mechanism. The feature fusion layer fuses the image features enhanced by the CBAM attention mechanism through the planned feature fusion path, and then transmits them to the feature prediction layer (Head) for fire hazard detection.
[0037] After introducing the improved fire hazard detection model, the specific process of performing fire hazard detection based on the improved fire hazard detection model can be referred to the following embodiment.
[0038] Embodiment 1
[0039] Figure 1b A flowchart of a fire hazard detection method is provided for an embodiment of the present invention. This embodiment is applicable to scenarios in which real-time detection of fire hazards existing in power operation sites is performed. The method can be executed by a fire hazard detection device, which can be implemented in the form of hardware and / or software. The fire hazard detection device can be configured in an electronic device, such as a server device.
[0040] like Figure 1b As shown, the fire hazard detection method includes:
[0041] S101, acquiring a target image collected from a power operation site, and performing self-convolution processing on the target image through the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image.
[0042] In the embodiment of the present invention, an image collector can be installed at the power operation site to collect images of the power operation site in real time. The image collector can be a camera of various models. After the image collector collects the images of the power operation site, it uploads them to the background server in real time. Therefore, the target image collected from the power operation site can be obtained from the background server of the image collector. The target image can be any image to be detected collected by the image collector.
[0043] After obtaining the target image, the target image can be used as the input of the improved fire hazard detection model. For the input target image, the multi-head attention self-convolution mechanism of the improved fire hazard detection model will perform self-convolution processing on the target image to obtain a self-convolution kernel including the target image related information. The specific implementation process is as follows: the multi-head attention self-convolution mechanism first expands the target image through a sliding window to obtain a feature map; in this way, the information of the target image can be embedded into the feature map; further, the feature map is subjected to global maximum pooling processing and global average pooling processing respectively to obtain a maximum pooling feature map and an average pooling feature map; the maximum pooling feature map and the average pooling feature map are fused to obtain a pooling fusion feature map; wherein, the feature fusion processing can be concatenation or element-by-element addition of two pooling feature maps; further, in order to improve the extraction of features and enhance the representation ability of the model, a Transformer Encoder module (i.e., self-attention mechanism) is introduced into the multi-head attention self-convolution mechanism, and the feature expression is strengthened by performing self-attention multi-head processing on the feature map to improve the detection performance. Therefore, after obtaining the pooled fusion features, features can be extracted from the pooled fusion feature map through the self-attention mechanism; further, the extracted features are reshaped, such as adjusting the size, to obtain a self-convolution kernel including information related to the target image. It should be noted that the generated self-convolution kernel carries rich information of the target image and is no longer an initial random number. In this way, when extracting features from the target image based on the self-convolution kernel, it can be guaranteed that important features can be extracted and the speed of feature extraction can be improved.
[0044] S102, performing convolution processing on the target image through the self-convolution kernel to obtain a target feature map corresponding to the target image.
[0045] In the embodiment of the present invention, after the self-convolution kernel is obtained in step S101, the target image is directly convolved based on the self-convolution kernel so as to extract features from the target image to form a target feature map. It can be understood that since the self-convolution kernel carries rich information of the target image and is no longer an initial random number, the target feature map extracted based on the self-convolution kernel is more accurate, thereby ensuring the accuracy of subsequent fire hazard detection.
[0046] S103. Based on the feature extraction layer, extract feature maps of different levels from the target feature map.
[0047] In the embodiment of the present invention, the feature extraction layer is mainly composed of the Conv module, the C3 module, and the SPPF module. Therefore, features can be extracted through different layers composed of the Conv module, the C3 module, and the SPPF module, so that feature maps of multiple different levels can be extracted. For example, the features extracted from the 3rd layer, the 5th layer, and the 8th layer can be used as the input of the CBAM attention mechanism.
[0048] S104. Perform feature enhancement on feature maps of different levels through the CBAM attention mechanism to obtain enhanced feature maps of different levels.
[0049] In the embodiment of the present invention, the CBAM attention mechanism includes a channel attention module and a spatial attention module; these two modules act on the input feature map in turn to sequentially reshape the channel and spatial dimensions of the feature map. The CBAM attention mechanism multiplies the output features of the channel attention module and the spatial attention module element by element to obtain the final attention-enhanced feature.
[0050] In an optional implementation, feature enhancement is performed on feature maps of different levels through the CBAM attention mechanism to obtain enhanced feature maps of different levels, including the following steps:
[0051] S1041. For a feature map at any level, the channel attention module is used to determine the weights of different feature channels of the feature map, and weighted enhancement is performed on features of different channels in the feature map according to the weights of different feature channels.
[0052] Optionally, global average pooling and global maximum pooling are used in the spatial dimension to extract global spatial features from the feature map; the weights of different feature channels are determined by combining the global spatial features with the shared fully connected layer and activation function (such as ReLU and Sigmoid); that is, the global spatial features are first input into the fully connected layer for processing, and then the output of the fully connected layer is converted into weights of different feature channels through the activation function.
[0053] S1042. For the weighted enhanced feature map, determine the spatial attention map through the spatial attention module, and perform spatial enhancement processing on the weighted enhanced feature map based on the spatial attention map to obtain the enhanced feature map.
[0054] Optionally, for the weighted enhanced feature map, the spatial attention module is used to determine the spatial attention map, including: performing global average pooling and global maximum pooling on the weighted enhanced feature map in the channel dimension, and stacking the two pooling results in the channel dimension; performing convolution processing on the stacked pooling results through a convolution layer, and generating a spatial attention map from the convolution processing results through an activation function; wherein the weights corresponding to different spatial positions are recorded in the spatial attention map. On this basis, the weighted enhanced feature map is spatially enhanced based on the spatial attention map, such as performing element-wise multiplication operation on the spatial attention map and the weighted enhanced feature map, so as to emphasize important spatial areas.
[0055] S105 . Perform feature fusion processing on the enhanced feature maps of different levels through the feature fusion layer to obtain fused feature maps of different scales.
[0056] After the feature maps of different levels are enhanced in step 104, feature fusion processing can be performed on the enhanced feature maps of different levels through a feature fusion layer to obtain fused feature maps of different scales.
[0057] In an optional implementation, based on the original feature fusion path of the feature fusion layer, at least one new cross-scale connection can be added to the feature fusion layer to enrich the feature fusion path in the feature fusion layer. Figure 1a , by introducing additional cross-scale connections in layers 10 and 13, connecting the outputs of these layers to layers 21 and 24 to form a more complex fusion path. The newly added cross-scale connections can be found in Figure 1a The red path in the feature fusion layer (Neck). It can be understood that by adding cross-scale connections and enriching the fusion path, the feature maps at different levels can be fully integrated, so that when dealing with scenes with complex backgrounds or subtle changes such as power sites, the details and contours of targets of different sizes can be captured more accurately, improving the detection ability of the fire hazard detection model for targets of different sizes.
[0058] S106. Perform fire hazard detection on the fused feature maps of different scales through the prediction feature layer to obtain a fire hazard detection result.
[0059] After step S105, the feature prediction layer of the fire hazard detection model can be directly used to perform fire hazard detection on fused feature maps of different scales to obtain fire hazard detection results; wherein the fire hazard detection results include the detected fire hazard type (such as smoke, hay, dead leaves, cigarette butts, etc.), object type confidence, and the bounding box of the fire hazard in the target image.
[0060] In the embodiment of the present invention, by integrating the multi-head attention self-convolution mechanism into the fire hazard detection model, not only the detection accuracy is improved, but also the model convergence speed is accelerated to meet the real-time requirements; and the newly introduced CBAM attention mechanism module optimizes the model's focus on key features and improves the accuracy of fire hazard detection.
[0061] Embodiment 2
[0062] Figure 2 The present invention provides a flowchart of a fire hazard detection method. The present invention mainly describes the process from training to using the improved fire hazard detection model. Figure 2 , the method comprises the following steps:
[0063] S201. Construct a data set for training a fire hazard detection model.
[0064] In the embodiment of the present invention, in order to construct a data set suitable for training a fire hazard detection model for a power site, data is collected from the following three ways:
[0065] 1. Power field work dataset: 1,200 images of power field work obtained from power grid units. These images directly reflect the on-site working environment and potential fire hazards.
[0066] 2. Use the Vincent graph model to generate images: Based on the scenarios provided by the power grid, the Vincent graph model was used to generate about 1,000 images for training. The method uses a data generation method based on the Stable Diffusion WebUI (Vincent graph), and uses Vincent graph and its various model configurations and parameter adjustments to optimize the quality of generated images. By designing and adjusting prompt words, AI is guided to generate images that are more accurate to the power site scenarios.
[0067] 3. Web crawling images: 3,000 relevant images were crawled from the Internet. The images were screened and included various possible fire hazard scenarios to enrich the actual scene coverage of the training and test sets.
[0068] After all the images were collected, necessary preprocessing was performed to standardize the image format and optimize the training effect. Finally, all the images were divided into training set and test set in a ratio of 8:2, that is, 4160 training set data and 1040 test set data.
[0069] S202. Build a network structure of an improved fire hazard detection model.
[0070] In the embodiment of the present invention, the improved fire hazard detection model is improved based on YOLOv5, mainly adding a multi-head attention self-convolution mechanism, a CBAM attention mechanism, and adding additional cross-scale connections. The constructed network structure can be seen in Figure 1a shown.
[0071] S203, training the model, using the loss function to optimize the model parameters of the improved fire hazard detection model to obtain the final fire hazard detection model.
[0072] In an embodiment of the present invention, before training begins, the model weights are initialized, and the learning rate, training rounds, batch size, momentum factor, etc. are set. During training, the data set is input into the model in batches, the output of each batch of data is calculated, and the loss is calculated based on the loss function. The total loss function of the improved fire hazard detection model consists of three parts: category loss, object confidence loss, and bounding box loss. Category loss and object confidence loss are calculated using binary cross entropy loss, which effectively solves the problem of slow weight update in the loss function caused by the use of Sigmoid activation function. The formula of binary cross entropy loss L is as follows:
[0073]
[0074] Among them, y represents the label value, Represents the predicted output value, i represents the i-th sample, and N represents the total number of samples.
[0075] The loss of the object bounding box usually adopts regression loss such as IoU loss, GIoU loss, DIoU loss, CIoU loss, etc. A good positioning loss needs to consider three factors: the overlap area between the predicted box and the true box, the distance between their centers, and the aspect ratio. For these reasons, CIoU loss is chosen as a better metric. The calculation formula of CIoU loss is expressed as:
[0076]
[0077]
[0078]
[0079]
[0080] Among them, L CIoU represents the bounding box loss function, u and v represent the center coordinates of the predicted box and the true box, respectively. 2 (u, v) represents the square of the distance between the center point of the predicted box and the true box, α represents the trade-off factor, B and B gt Represent the predicted box and the real box respectively, w and h represent the width and height of the real box, w gt and h gt Indicates the width and height of the prediction box.
[0081] Furthermore, after obtaining the loss value, the gradient is calculated based on the loss, and the model parameters are updated through back propagation. And according to the preset strategy, the learning rate is adjusted during the training process.
[0082] Furthermore, after each training cycle, the test set is used to evaluate the model performance, and the model parameters are adjusted or the training is stopped early according to the evaluation indicators (precision, recall, average precision, etc.) to avoid overfitting.
[0083] After the training is completed, the model is obtained and fire hazard detection begins.
[0084] S204: Use the trained fire hazard detection model to perform fire hazard detection.
[0085] The specific fire hazard detection process can be found in the description of the above embodiment and will not be repeated here.
[0086] The present invention accelerates the convergence speed of the model by integrating the multi-head attention self-convolution mechanism (MASC), and improves the real-time and accuracy of the detection of fire hazards at the power site; introduces the CBAM attention mechanism module: the present invention optimizes the model's focus on key features by integrating the CBAM attention mechanism module, and enhances the model's resolution and recognition capabilities in specific areas; by introducing additional cross-scale connections in the 10th and 13th layers of the model, a more complex fusion path is formed, so that the model can more accurately capture the details and contours of targets of different sizes. In summary, the present invention can improve the detection capability of fire hazards at power operation sites, especially the accuracy and processing efficiency in complex environments.
[0087] Embodiment 3
[0088] Figure 3 A schematic diagram of the structure of a fire hazard detection device provided by an embodiment of the present invention. This embodiment is applicable to the scenario of real-time detection of fire hazards existing in power operation sites. The fire hazard detection device in this embodiment is configured in an electronic device deployed with an improved fire hazard detection model, wherein the improved fire hazard detection model at least includes a multi-head attention self-convolution mechanism arranged before the feature extraction layer, a CBAM attention mechanism arranged between the feature extraction layer and the feature fusion layer, and a prediction feature layer, such as Figure 3 As shown, the fire hazard detection device includes:
[0089] The self-convolution module 301 is used to obtain a target image collected from the power operation site, and perform self-convolution processing on the target image through the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image;
[0090] A first feature extraction module 302, configured to perform convolution processing on the target image through the self-convolution kernel to obtain a target feature map corresponding to the target image;
[0091] A second feature extraction module 303, configured to extract feature maps of different levels from the target feature map based on the feature extraction layer;
[0092] A feature enhancement module 304 is used to perform feature enhancement on feature maps of different levels through the CBAM attention mechanism to obtain enhanced feature maps of different levels;
[0093] A feature fusion module 305 is used to perform feature fusion processing on the enhanced feature maps of different levels through the feature fusion layer to obtain fused feature maps of different scales;
[0094] The detection module 306 is used to perform fire hazard detection on the fused feature maps of different scales through the prediction feature layer to obtain a fire hazard detection result.
[0095] In an optional implementation, the self-convolution module 301 is specifically used for:
[0096] Expanding the target image through a sliding window to obtain a feature map;
[0097] Performing global maximum pooling processing and global average pooling processing on the feature map respectively to obtain a maximum pooling feature map and an average pooling feature map;
[0098] The maximum pooling feature map and the average pooling feature map are fused to obtain a pooling fusion feature map;
[0099] Features are extracted from the pooled fusion feature map through a self-attention mechanism, and the extracted features are reshaped to obtain the self-convolution kernel.
[0100] In an optional implementation, the CBAM attention mechanism includes a channel attention module and a spatial attention module;
[0101] The feature enhancement module 304 includes:
[0102] A first enhancement unit is used to determine, for a feature map at any level, weights of different feature channels of the feature map through the channel attention module, and perform weighted enhancement on features of different channels in the feature map according to the weights of different feature channels;
[0103] The second enhancement unit is used to determine the spatial attention map for the weighted enhanced feature map through the spatial attention module, and perform spatial enhancement processing on the weighted enhanced feature map based on the spatial attention map to obtain the enhanced feature map; wherein the spatial attention map records the weights corresponding to different spatial positions.
[0104] In an optional implementation manner, the first enhancement unit is specifically configured to:
[0105] Using global average pooling and global maximum pooling in the spatial dimension to extract global spatial features from the feature map;
[0106] The weights of different feature channels are determined by combining the global spatial features through a shared fully connected layer and an activation function.
[0107] In an optional implementation manner, the second enhancement unit is specifically configured to:
[0108] Perform global average pooling and global maximum pooling on the weighted enhanced feature map in the channel dimension, and stack the two pooling results in the channel dimension;
[0109] The stacked pooling results are convolved through the convolution layer, and the convolution results are converted into a spatial attention map through the activation function.
[0110] In an optional implementation, at least one new cross-scale connection is added to the feature fusion layer to enrich the feature fusion path in the feature fusion layer.
[0111] In an optional implementation, the improved fire hazard detection model is improved based on the YOLOv5 model; in the training stage of the improved fire hazard detection model, the loss function of the improved fire hazard detection model is composed of category loss, object confidence loss and bounding box loss; and the category loss and object confidence loss adopt binary cross entropy loss, and the bounding box loss adopts CIoU loss.
[0112] The fire hazard detection device provided in the embodiment of the present invention can execute the fire hazard detection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0113] Embodiment 4
[0114] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to be a controller device in a new energy vehicle. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0115] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0116] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0117] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as executing a fire hazard detection method.
[0118] In some embodiments, the fire hazard detection method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the fire hazard detection method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the fire hazard detection method in any other appropriate manner (e.g., by means of firmware).
[0119] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0120] The computer programs for implementing the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable fire hazard detection device, so that when the computer programs are executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0121] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0122] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0123] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0124] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0125] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0126] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A fire hazard detection method, characterized in that: Applied to an electronic device deployed with an improved fire hazard detection model, the improved fire hazard detection model at least includes a multi-head attention self-convolution mechanism arranged before a feature extraction layer, a CBAM attention mechanism arranged between a feature extraction layer and a feature fusion layer, and a prediction feature layer, the method comprising: Acquire a target image collected from a power operation site, and perform self-convolution processing on the target image through the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image; Performing convolution processing on the target image through the self-convolution kernel to obtain a target feature map corresponding to the target image; Based on the feature extraction layer, extracting feature maps of different levels from the target feature map; The feature maps at different levels are enhanced by the CBAM attention mechanism to obtain enhanced feature maps at different levels. Performing feature fusion processing on the enhanced feature maps of different levels through the feature fusion layer to obtain fused feature maps of different scales; Fire hazard detection is performed on the fused feature maps of different scales through the prediction feature layer to obtain a fire hazard detection result.
2. The method according to claim 1, characterized in that The self-convolution process of the target image is performed by the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image, including: Expanding the target image through a sliding window to obtain a feature map; Performing global maximum pooling processing and global average pooling processing on the feature map respectively to obtain a maximum pooling feature map and an average pooling feature map; The maximum pooling feature map and the average pooling feature map are fused to obtain a pooling fusion feature map; Features are extracted from the pooled fusion feature map through a self-attention mechanism, and the extracted features are reshaped to obtain the self-convolution kernel.
3. The method according to claim 1, characterized in that: The CBAM attention mechanism includes a channel attention module and a spatial attention module; The feature enhancement of feature maps at different levels is performed by the CBAM attention mechanism to obtain enhanced feature maps at different levels, including: For a feature map at any level, the channel attention module is used to determine the weights of different feature channels of the feature map, and weighted enhancement is performed on the features of different channels in the feature map according to the weights of different feature channels; For the weighted enhanced feature map, the spatial attention map is determined through the spatial attention module, and the weighted enhanced feature map is spatially enhanced based on the spatial attention map to obtain the enhanced feature map; wherein the spatial attention map records the weights corresponding to different spatial positions.
4. The method according to claim 3, characterized in that Determining the weights of different feature channels of the feature graph by the channel attention module includes: Using global average pooling and global maximum pooling in the spatial dimension to extract global spatial features from the feature map; The weights of different feature channels are determined by combining the global spatial features through a shared fully connected layer and an activation function.
5. The method according to claim 3, characterized in that: The step of determining a spatial attention map for the weighted enhanced feature map through the spatial attention module includes: Perform global average pooling and global maximum pooling on the weighted enhanced feature map in the channel dimension, and stack the two pooling results in the channel dimension; The stacked pooling results are convolved through the convolution layer, and the convolution results are converted into a spatial attention map through the activation function.
6. The method according to claim 1, characterized in that At least one new cross-scale connection is added to the feature fusion layer to enrich the feature fusion path in the feature fusion layer.
7. The method according to claim 1, characterized in that The improved fire hazard detection model is improved based on the YOLOv5 model; in the training stage of the improved fire hazard detection model, the loss function of the improved fire hazard detection model is composed of category loss, object confidence loss and bounding box loss; and the category loss and object confidence loss adopt binary cross entropy loss, and the bounding box loss adopts CIoU loss.
8. A fire hazard detection device, characterized in that: The device is configured in an electronic device in which an improved fire hazard detection model is deployed, wherein the improved fire hazard detection model comprises at least a multi-head attention self-convolution mechanism arranged before a feature extraction layer, a CBAM attention mechanism arranged between a feature extraction layer and a feature fusion layer, and a prediction feature layer, and comprises: A self-convolution module is used to obtain a target image collected from the power operation site, and perform self-convolution processing on the target image through the multi-head attention self-convolution mechanism to obtain a self-convolution kernel including information related to the target image; A first feature extraction module, configured to perform convolution processing on the target image through the self-convolution kernel to obtain a target feature map corresponding to the target image; A second feature extraction module, used for extracting feature maps of different levels from the target feature map based on the feature extraction layer; A feature enhancement module, used to perform feature enhancement on feature maps of different levels through the CBAM attention mechanism to obtain enhanced feature maps of different levels; A feature fusion module, used for performing feature fusion processing on the enhanced feature maps of different levels through the feature fusion layer to obtain fused feature maps of different scales; The detection module is used to perform fire hazard detection on the fused feature maps of different scales through the prediction feature layer to obtain a fire hazard detection result.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 7 when executed.
Citation Information
Cited By
Dense small target detection method and system based on weighted attention mechanism
CN119693773A
