A fire warning method and system based on a YOLOv5 improved algorithm

CN116824335BActive Publication Date: 2026-09-22SHANGHAI INST OF MICROSYSTEM & INFORMATION TECH CHINESE ACAD OF SCI
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310756773.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-26
Publication Date
2026-09-22
Estimated Expiration
2043-06-26

AI Technical Summary

Technical Problem

目前双阶段目标检测算法的模型设计使用大型深度网络,难以满足高精度和高实时性的检测需求,单阶段目标检测算法降低精度为代价换取检测的实时性,二者都存在对于火灾小目标检测精度低和定位不准等问题,无法准确实时地进行火灾检测及早期预警

Benefits of technology

[0045]由于采用了上述的技术方案,本发明与现有技术相比,具有以下的优点和积极效果:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116824335B_ABST
    Figure CN116824335B_ABST
Patent Text Reader

Abstract

The application relates to a fire warning method based on a YOLOv5 improved algorithm, which comprises the following steps: S1. acquiring streaming media data; S2. pre-processing the streaming media data to obtain a to-be-tested image sequence; S3. detecting the to-be-tested image sequence by using a fire detection model to obtain a detection result; the fire detection model is constructed based on the YOLOv5 improved algorithm and comprises the following steps: placing an attention module CAB in a deep layer of a backbone network to perform feature extraction; constructing a feature fusion module to perform multi-scale feature fusion and generating four detection heads with different receptive fields; and S4. judging whether a fire occurs based on the detection result of the fire detection model. The application can accurately and timely detect early fire.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of target detection technology, and in particular to a fire early warning method and system based on an improved YOLOv5 algorithm. Background Technology

[0002] Fire, recognized worldwide as one of the most serious natural disasters, severely endangers human life and property. Early and effective fire detection and warning are crucial for the security construction of smart cities. Physical signal-based sensors, such as smoke sensors, pyroelectric infrared flame sensors, and ultraviolet flame sensors, are widely used in fire alarm systems. However, these traditional physical sensors are limited to locations near the fire source and cannot work effectively in semi-enclosed large-space buildings and open underground spaces. Furthermore, they cannot provide detailed information about the fire's location, size, and extent of combustion. Visual sensor-based fire detection technology, on the other hand, can meet these needs.

[0003] In the early stages of visual fire detection research, the main approach relied on manually extracting static and dynamic features of flames, such as color, texture, shape, edges, and motion, to describe fire scenes. Machine learning methods were then used to design suitable classifiers for further classification and recognition. Traditional methods, by designing manual feature extractors to improve the accuracy of fire identification, have to some extent promoted the development of visual fire detection technology. However, due to the high complexity of fire scenes in videos, manually designed features are highly redundant and dependent on fixed scenes. The extracted information is only a shallow feature of the flames, making it a heuristic method with poor robustness and difficulty in adapting to fire detection in complex scenes. Therefore, in recent years, research has gradually shifted towards using deep learning methods for visual fire detection. Currently, two-stage target detection algorithms use large deep networks, which are insufficient to meet the requirements of high accuracy and real-time performance. Single-stage target detection algorithms sacrifice accuracy for real-time performance, but both suffer from low accuracy in detecting small fire targets and inaccurate localization, making accurate and real-time fire detection and early warning impossible. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a fire early warning method and system based on the improved YOLOv5 algorithm, which can accurately and in real time detect fires and provide early warnings.

[0005] The technical solution adopted by this invention to solve its technical problem is: to provide a fire early warning method based on an improved YOLOv5 algorithm, comprising the following steps:

[0006] S1. Obtain streaming media data;

[0007] S2. Preprocess the streaming media data to obtain the image sequence to be tested;

[0008] S3. The fire detection model is used to detect the image sequence to be tested, and the detection results are obtained; the fire detection model is constructed based on the improved YOLOv5 algorithm, including:

[0009] An attention module (CAB) is inserted deep into the backbone network for feature extraction;

[0010] A feature fusion module is constructed to perform multi-scale feature fusion and generate detection heads with four different receptive fields;

[0011] S4. Determine whether a fire has occurred based on the detection results of the fire detection model.

[0012] Furthermore, the feature extraction process by embedding an attention module (CAB) deep within the backbone network includes:

[0013] The image to be tested, which is placed into the fire detection model, is subjected to feature extraction twice by the first CBS module and the second CBS module, and then input into the first CSP1 module to output the first feature map.

[0014] The first feature map is processed by the third CBS module to extract features, and then input into the second CSP1 module to output the second feature map.

[0015] The second feature map is processed by the fourth CBS module to extract features, and then input into the third CSP1 module to output the third feature map.

[0016] The third feature map is processed by the fifth CBS module for feature extraction and then input into the attention module CAB to increase the weight of the target feature. After spatial pyramid pooling, it is input into the sixth CBS module, and the output fourth feature map is used as the input of the feature fusion module.

[0017] Furthermore, the spatial pyramid pooling is performed through a bidirectional pyramid network.

[0018] Furthermore, the feature fusion module performs multi-scale feature fusion and generates detection heads with four different receptive fields, including:

[0019] The fourth feature map is upsampled and then concatenated with the third feature map. The result is then processed by the first CSP2 module and the seventh CBS module to obtain the first fused feature map.

[0020] The first fused feature map is upsampled and then concatenated with the second feature map. The result is then processed by the second CSP2 module and the eighth CBS module to obtain the second fused feature map.

[0021] The second fused feature map is upsampled and then concatenated with the first feature map. The third fused feature map is then obtained by passing it through the third CSP2 module. The third fused feature map is then convolved to obtain the first detection feature map.

[0022] The third fused feature map is concatenated with the second fused feature map after passing through the ninth CBS module, and then passed through the fourth CSP2 module to obtain the fourth fused feature map. The fourth fused feature map is then convolved to obtain the second detection feature map.

[0023] The fourth fused feature map is concatenated with the first fused feature map and the third feature map after downsampling after passing through the tenth CBS module, and then passed through the fifth CSP2 module to obtain the fifth fused feature map. The fifth fused feature map is then convolved to obtain the third detection feature map.

[0024] The fifth fused feature map is concatenated with the fourth feature map and the second feature map after downsampling after passing through the eleventh CBS module, and then passed through the sixth CSP2 module to obtain the sixth fused feature map. The sixth fused feature map is then convolved to obtain the fourth detection feature map.

[0025] Furthermore, the size of the first detection feature map is 1 / 4 of the image to be tested, the size of the second detection feature map is 1 / 8 of the image to be tested, the size of the third detection feature map is 1 / 16 of the image to be tested, and the size of the fourth detection feature map is 1 / 32 of the image to be tested.

[0026] Furthermore, the attention module CAB is constructed based on the coordinate attention mechanism and uses the mish function as the activation function of the batch normalization layer.

[0027] Furthermore, the preprocessing of the streaming media data to obtain the image sequence to be tested includes:

[0028] The streaming media data is saved as an image sequence at interval frames;

[0029] The image sequence is normalized to obtain the image sequence to be tested.

[0030] Furthermore, the determination of whether a fire has occurred based on the detection results of the fire detection model includes:

[0031] Based on the detection results, the fire type and probability of occurrence are analyzed.

[0032] The predicted voting value is obtained by analyzing and comparing the occurrence probability with the threshold.

[0033] The predicted voting values ​​are used to determine whether a fire has occurred.

[0034] Furthermore, the steps for acquiring and preprocessing training data during the training of the fire detection model include:

[0035] Acquire a multi-scene fire image set containing both flames and smoke as targets;

[0036] The images in the fire image set are normalized to a preset size, and the background is filled with gray to obtain a standard image set;

[0037] An enhanced image set is obtained by performing affine transformation, transmission transformation, and combined transformation on the images in the standard image set.

[0038] A certain number of images from the enhanced image set are selected as the training image set.

[0039] The technical solution adopted by this invention to solve its technical problem is: It also provides a fire early warning system based on an improved YOLOv5 algorithm, characterized in that it includes:

[0040] The data acquisition unit is used to acquire streaming media data;

[0041] The data input unit is used to preprocess the streaming media data to obtain a sequence of images to be tested, and to sequentially input the images to be tested in the sequence of images to be tested into the fire detection unit for detection.

[0042] The fire detection unit is used to detect the image to be tested and obtain the detection result. The fire detection unit is built based on the YOLOv5 improved algorithm and includes a backbone network for feature extraction, a feature fusion module for multi-scale feature fusion, and four detection heads with different receptive fields. The backbone network has a deep attention module CAB.

[0043] The result output unit is used to determine whether a fire has occurred based on the detection results.

[0044] Beneficial effects

[0045] By adopting the above-mentioned technical solution, the present invention has the following advantages and positive effects compared with the prior art:

[0046] (1) This invention constructs a fire detection model based on the improved YOLOv5 algorithm. The model introduces an attention mechanism into the backbone network to enhance the weight representation of the target location and further improve the average accuracy of detection.

[0047] (2) Based on the principle of bidirectional feature pyramid network, this invention transforms the partial path aggregation network into a bidirectional cross-scale connection. Through a simple splicing operation, features at various scales can be better integrated.

[0048] (3) Based on the original structure of YOLOv5, this invention adds a small target detection head to focus on detecting small targets in visual tasks, and realizes real-time early warning of fire through a video frame voting mechanism.

[0049] (4) The detection model of the present invention is based on a dynamic neural network with variable depth and width, which can adjust the size of the network model to be deployed on different hardware devices;

[0050] (5) This invention constructs a multi-scene fire and smoke image dataset and uses a variety of data augmentation methods to preprocess the image dataset, thus solving the problem of imbalance between large, medium and small fire and smoke targets in the training images. Attached Figure Description

[0051] Figure 1 This is a schematic diagram of the fire detection model of the present invention;

[0052] Figure 2 This is a structural diagram of the CAB module of the present invention;

[0053] Figure 3 This is a flowchart of the present invention;

[0054] Figure 4 This is a flowchart of the training phase in the first embodiment of the present invention.

[0055] Figure 5 This is the confidence curve of the fire detection model in the first embodiment of the present invention;

[0056] Figure 6 This is the accuracy-confidence curve of the fire detection model in the first embodiment of the present invention;

[0057] Figure 7 This is the recall curve of the fire detection model in the first embodiment of the present invention;

[0058] Figure 8 This is the recall-confidence curve of the fire detection model according to the first embodiment of the present invention;

[0059] Figure 9 This is a performance comparison chart of the present invention with other methods. Detailed Implementation

[0060] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be understood that after reading the teachings of this invention, those skilled in the art can make various alterations or modifications to the invention, and these equivalent forms also fall within the scope defined by the appended claims.

[0061] The first embodiment of the present invention relates to a fire early warning method based on an improved YOLOv5 algorithm, such as... Figure 3 As shown, it includes the following steps:

[0062] S1: Acquire streaming media data through the tunnel monitoring and acquisition module.

[0063] S2: Preprocess the streaming media data to obtain the image sequence to be tested, including:

[0064] Save streaming media data as an image sequence at interval frames;

[0065] The image sequence is normalized to obtain the image sequence to be tested.

[0066] S3: Use a fire detection model to detect the image sequence under test, obtain the areas containing both flames and smoke and the probability of a fire, mark them in the original image sequence, and finally frame them into a video.

[0067] S4: Compare the fire probability obtained in step S3 with the threshold, deduce N predicted voting values, and use these N voting values ​​to make a judgment, so as to achieve early warning of fire in the early stage.

[0068] Before conducting detection, a fire detection model needs to be built and trained, such as... Figure 4 As shown, it includes the following steps:

[0069] Step A1. Establish a multi-scenario fire dataset, preprocess the data, and obtain the training sample set {train1,…,traind,…,trainm} and the test sample set {test1,…,teste,…,testn};

[0070] Step A2. Based on the improved YOLOv5 algorithm, build the deep learning network model Fire-YOLOv5;

[0071] Step A3. Iterate through training to minimize the loss function to obtain the trained model, and then deploy it to the edge server for tunnel monitoring.

[0072] The following is a detailed explanation of step A1.

[0073] A101: Obtain multi-scene fire images containing two types of targets, flame and smoke, from an open-source dataset: Image = {Image1, ..., Imagei, ..., ImageN}. Create sample labels in a uniform format: Label = {Label1, ..., Labeli, ..., LabelN}. Each label Labeli represents the center point coordinates (Xij, Yij), width and height (Wij, Hij), and category {0, 1} of the j-th target in the corresponding sample Imagei. Imagei represents the i-th sample in the dataset, i ∈ [0, N], N represents the total number of images, and the categories {0, 1} represent {flame, smoke}, respectively.

[0074] A102: Each sample in the dataset is normalized to 640 pixels × 640 pixels, and the background is filled with gray. Scaling ratios for images with different aspect ratios. The image is scaled up to The image contains pixels, where max(w,h) and min(w,h) are the maximum and minimum values ​​between the image width and height, respectively. To round up, the gray fill value is (114,114,114).

[0075] A103: Divide the normalized dataset into a training set (Train) and a test set (Test). For each class of images, select 80% as the training set and the remaining 20% ​​as the test set.

[0076] A104: Set the parameter vector for data augmentation to perform affine transformations, perspective transformations, and combination transformations on the image samples in the training set to enrich the training sample set.

[0077] The following is a detailed explanation of step A2.

[0078] Step A201: Set the depth and width coefficients of the neural network to adjust the size of the network model and adapt it to different hardware platforms. The network depth, number of layers, network width, and network output channels are controlled by the depth factor DM and the width factor WM, respectively. The number of layers is max(round(number×DM),1), where number is the number of layers in different modules, and round is rounding to the nearest integer. The network output channels are... Where channel represents the number of channels in different modules. This is for rounding up.

[0079] Step A202: Construct a coordinate attention module (CAB) based on an improved coordinate attention mechanism, using the Mish activation function as the activation function for the batch normalization layer. For example... Figure 2As shown, this module uses two spatially defined pooling kernels to perform one-dimensional feature encoding on each channel along the horizontal and vertical coordinates, respectively. The two one-dimensional feature encoding outputs of the c-th channel are:

[0080]

[0081] in, This is the output of the c-th channel with height h. For the output of the c-th channel with width w, x c (h,i) and x c (j, w) represents the values ​​in the feature map vector, where W and H are the width and height of the c-th channel. A 1×1 convolutional kernel is used to transform the number of channels, and the Mish activation function is used to obtain global spatial information in the horizontal and vertical directions. The output of the intermediate feature map is f = δ(F1([z h ,z w ])), [z h ,z w The [] represents a tensor concatenation operation along two directions, horizontal and vertical. This splits the intermediate feature map into two independent tensors along the spatial dimension and uses two 1×1 convolutions to transform the channels to match the input channels. Transformation process.

[0082]

[0083] Among them, f h and f w F represents the output value of the corresponding delta transformation function. h and F w This represents two 1×1 convolution transformations, where m represents the Mish activation function, resulting in two tensors g. h and g w The weights are used as attention parameters. The Mish activation function used is m = x × tanh(ln(1+e^(-x / 2))). x The ReLU activation function is a smooth curve that doesn't completely truncate in the negative portion, allowing for smaller negative gradients to flow into the neural network and more favorable information to penetrate deeper, resulting in higher accuracy and generalization. As layer depth increases, the ReLU activation function causes a rapid decrease in training accuracy, while the Mish activation function offers comprehensive improvements in training stability, average accuracy, and peak accuracy. Finally, the output of the attention module is obtained as follows:

[0084]

[0085] in, and These are the weight parameters corresponding to the m-function.

[0086] Step A203: Replace the CSP2_X module in the YOLOv5 backbone network with the coordinate attention module CAB to enhance the weight parameter representation of the region of interest.

[0087] Step A204: Use Concat to connect bidirectional cross-scale links to fuse feature maps of different scales, achieving multi-layer semantic fusion. The Fire-YOLOv5 algorithm combines the principle of bidirectional feature pyramid networks, connecting input and output nodes at the same level across layers, shortening the path of semantic transmission from lower layers to higher layers. It also organically combines rich semantic features from higher layers with features from lower layers by concatenating adjacent layers instead of adding them, significantly improving prediction accuracy. This implementation uses a weight-free bidirectional cross-scale connection method for feature fusion, aiming to improve detection accuracy without affecting the network's inference speed.

[0088] Step A205: Add a set of small target anchor boxes and a detection head to achieve the detection of targets at the pixel level after a 32x downsampling of the original image. Excessive downsampling multiple times in the network model can lead to information loss in small targets. Considering the limited available resolution and contextual information of the model, a set of anchor boxes and a small target detection layer is added to address the problem of undetectable small targets in fires. The feature map output from layer 19 (the seventh CBS module) of the network model is upsampled to obtain a 160×160 feature map, which is then concatenated with the feature map output from layer 3 of the backbone network. This concatenation is then performed on the CSP_2X layer and the convolutional layer. The input image size is uniformly adjusted to 640×640 pixels. The 160×160 feature map is used to detect targets larger than 4×4 pixels, the 80×80 feature map is used to detect targets larger than 8×8 pixels, the 40×40 feature map is used to detect targets larger than 16×16 pixels, and the 20×20 feature map is used to detect targets larger than 32×32 pixels. With the addition of a small target detection layer, the four-layer detection structure can cover different receptive fields, enabling rapid detection and accurate localization of ultra-small pixel targets.

[0089] More specifically, such as Figure 1 As shown, the Fire-YOLOv5 network model includes a backbone network for feature extraction, a feature fusion module for multi-scale feature fusion, and four detection heads with different receptive fields. This model is used to perform the following operations:

[0090] The image to be tested, which is placed into the fire detection model, is processed by two CBS modules for feature extraction and then input into the CSP1_1 module to output the first feature map.

[0091] The first feature map is processed by the CBS module to extract features, and then input into the CSP1_2 module to output the second feature map.

[0092] The second feature map is processed by the CBS module to extract features, and then input into the CSP1_3 module to output the third feature map.

[0093] The third feature map is processed by the CBS module for feature extraction and then input into the attention module CAB. After passing through the bidirectional pyramid network, it is input into the CBS module, and the output fourth feature map is used as the input of the feature fusion module.

[0094] The fourth feature map is upsampled and then concatenated with the third feature map. The result is then processed by the CSP2_1 module and the CBS module to obtain the first fused feature map.

[0095] The first fused feature map is upsampled and then concatenated with the second feature map. The result is then processed by the CSP2_2 module and the CBS module to obtain the second fused feature map.

[0096] The second fused feature map is upsampled and then concatenated with the first feature map. The third fused feature map is obtained by passing it through the CSP2_3 module. The third fused feature map is then convolved to obtain the first detection feature map, which is 1 / 4 the size of the image to be tested.

[0097] The third fusion feature map is concatenated with the second fusion feature map after passing through the CBS module, and then passed through the CSP2_4 module to obtain the fourth fusion feature map. The fourth fusion feature map is then convolved to obtain the second detection feature map, which is 1 / 8 the size of the image to be tested.

[0098] The fourth fusion feature map is concatenated with the first fusion feature map and the third feature map after downsampling by the CBS module, and then passed through the CSP2_5 module to obtain the fifth fusion feature map. The fifth fusion feature map is then convolved to obtain the third detection feature map, which is 1 / 16 of the image to be tested.

[0099] The fifth fused feature map is concatenated with the fourth feature map and the second feature map after downsampling by the CBS module, and then passed through the CSP2_6 module to obtain the sixth fused feature map. The sixth fused feature map is then convolved to obtain the fourth detection feature map, which is 1 / 32 of the image to be tested.

[0100] Step A3 will be explained in detail below.

[0101] S301: Set the maximum number of iterations Itera, the learning rate η, the training batch size B, and input B images from the training dataset {train1,…,traind,…,trainm} for each iteration, with the number of inputs Num being... Where m is the total number of samples in the training dataset. The loss function L is...

[0102] L = Lclass +L CIoU +L obj +L noobj

[0103] Among them, L class For classification loss, L CIoU To locate the loss, L obj L noobj These represent the confidence losses for positive and negative samples, respectively. Let T be the number of output feature maps t, and S be the... 2 N is the number of feature map grid cells, N is the number of anchor boxes in each grid n, w is the width of the predicted box, and h is the height of the predicted box. r<4 This is a condition for classifying a sample as positive; the ratio of the width and height of the calibration box to the width and height of the prediction box is set to be less than 4. The classification loss is calculated as the error between the inferred class and its corresponding calibration class.

[0104]

[0105] Where, x i For each of the N categorized classes, the value y takes the range {0, 1, ..., N-1}. i For normalized class probabilities, The network infers the probability of the target category. The localization loss calculates the error between the predicted bounding box and the calibration box.

[0106]

[0107] in,

[0108]

[0109] w gt It is the width of the calibration frame, h gt ρ is the height of the bounding box, IoU is the ratio of the intersection and union of the bounding box and the predicted box, and ρ is the height of the bounding box. 2 (b,b gt () is the distance between the center points of the calibration box and the predicted box. Calculate the positive sample confidence loss of the network.

[0110]

[0111] Calculate the negative sample confidence loss of the network.

[0112]

[0113] The confidence level, denoted by C, takes values ​​{0, 1}, where 0 represents that the target is not the target and 1 represents that the target is the target. gr is the set probability factor. It represents the confidence level of the inference; the confidence level for negative samples is zero.

[0114] S302: Using gradient descent method The network is iteratively optimized by minimizing the loss function, using the SGD learner optimizer with a global initial learning rate of η, where ω t+1 As a network parameter and for prediction, ω t These are the current network weight parameters. It is the gradient value for the next iteration.

[0115] S303: If the loss function L stops decreasing before the number of iterations reaches the set minimum number of iterations Itera, then training stops; if the number of iterations reaches the set minimum number of iterations Itera, then training stops and the trained network model is obtained; otherwise, iterative optimization continues.

[0116] In practice, network training utilized the open-source PyTorch deep learning framework, an Ubuntu 20.04 system environment, CUDA 10.0 and Python 3.7 programming environment, and an NVIDIA GeForce RTX 2070 Max-Q GPU with 8GB of VRAM, an Intel(R) Core(TM) i-10750H CPU @ 2.60GHz, and 12GB of RAM. Training and testing were completed using this platform. Due to hardware limitations, the training batch size was set to 2, the SGD learning optimizer was employed, and the initial global learning rate was set to 0.001.

[0117] Experimental results show that, Figures 5 to 9As shown, Fire-YOLOv5x achieves a good balance between performance and efficiency in flame and smoke detection tasks, with stronger robustness. The network has 70.7M parameters, which is 18.0% smaller than the YOLOv5x network, achieving a detection accuracy of 93.5%, a 2.0% improvement over YOLOv5x. With an IoU threshold of 0.5, the average detection accuracy reaches 71.8%, a 0.2% improvement, while the inference speed is comparable to YOLOv5x. The F1 score, precision, and recall curves of Fire-YOLOv5x show that the class average precision and recall reach 93.5% and 96%, respectively, demonstrating that the new method presented in this paper has higher detection accuracy and a lower false negative rate. Using a publicly available dataset for testing, experimental results show that Fire-YOLOv5x achieves a 1.6% and 2% improvement in detection accuracy compared to EfficientDet-D4 and YOLOv5, respectively, a 1.7% improvement in recall compared to EfficientDet-D4, and a 14.5% improvement in average detection accuracy at an IoU threshold of 0.5 compared to EfficientDet-D4. Its detection speed is comparable to EfficientDet-D4. Especially when handling extremely small pixels and dense fire targets, its performance surpasses existing deep learning-based flame and smoke detection methods. Results on tunnel fire video detection demonstrate that it can achieve rapid fire detection and timely early warning. The depth and width of the deep neural network model can be flexibly adjusted, allowing for the training of networks of different sizes and deployment on hardware devices with varying computing power.

[0118] A second embodiment of the present invention relates to a fire early warning system based on an improved YOLOv5 algorithm, comprising:

[0119] The data acquisition unit is used to acquire streaming media data;

[0120] The data input unit is used to preprocess the streaming media data to obtain the image sequence to be tested, and then put the images to be tested in the image sequence into the fire detection unit for detection in sequence.

[0121] The fire detection unit is used to detect the image under test and obtain the detection result. The fire detection unit is built based on the improved YOLOv5 algorithm and includes a backbone network for feature extraction, a fusion module for multi-scale feature fusion, and four detection heads with different receptive fields. The backbone network has a deep attention module CAB.

[0122] The result output unit is used to determine whether a fire has occurred based on the detection results.

Claims

1. A fire early warning method based on an improved YOLOv5 algorithm, characterized in that, Includes the following steps: S1. Obtain streaming media data; S2. Preprocess the streaming media data to obtain the image sequence to be tested; S3. Use a fire detection model to detect the image sequence to be tested and obtain the detection results; The fire detection model is built based on an improved YOLOv5 algorithm and includes: An attention module (CAB) is inserted deep into the backbone network for feature extraction; A feature fusion module is constructed to perform multi-scale feature fusion and generate detection heads with four different receptive fields; S4. Determine whether a fire has occurred based on the detection results of the fire detection model; The feature extraction process, which involves embedding a CAB attention module deep within the backbone network, includes: The image to be tested, which is placed into the fire detection model, is processed by the first CBS module and the second CBS module for feature extraction, and then input into the first CSP1 module to output the first feature map. The first feature map is processed by the third CBS module to extract features, and then input into the second CSP1 module to output the second feature map. The second feature map is processed by the fourth CBS module to extract features, and then input into the third CSP1 module to output the third feature map. The third feature map is processed by the fifth CBS module for feature extraction and then input into the attention module CAB to increase the weight of the target feature. After passing through the bidirectional pyramid network pooling, it is input into the sixth CBS module, and the output fourth feature map is used as the input of the feature fusion module.

2. The fire early warning method based on the improved YOLOv5 algorithm according to claim 1, characterized in that, The feature fusion module performs multi-scale feature fusion and generates four detection heads with different receptive fields, including: The fourth feature map is upsampled and then concatenated with the third feature map. The result is then processed by the first CSP2 module and the seventh CBS module to obtain the first fused feature map. The first fused feature map is upsampled and then concatenated with the second feature map. The result is then processed by the second CSP2 module and the eighth CBS module to obtain the second fused feature map. The second fused feature map is upsampled and then concatenated with the first feature map. The third fused feature map is then obtained by passing it through the third CSP2 module. The third fused feature map is then convolved to obtain the first detection feature map. The third fused feature map is concatenated with the second fused feature map after passing through the ninth CBS module, and then passed through the fourth CSP2 module to obtain the fourth fused feature map. The fourth fused feature map is then convolved to obtain the second detection feature map. The fourth fused feature map is concatenated with the first fused feature map and the third feature map after downsampling after passing through the tenth CBS module, and then passed through the fifth CSP2 module to obtain the fifth fused feature map. The fifth fused feature map is then convolved to obtain the third detection feature map. The fifth fused feature map is concatenated with the fourth feature map and the second feature map after downsampling after passing through the eleventh CBS module, and then passed through the sixth CSP2 module to obtain the sixth fused feature map. The sixth fused feature map is then convolved to obtain the fourth detection feature map.

3. The fire early warning method based on the improved YOLOv5 algorithm according to claim 2, characterized in that, The size of the first detection feature map is 1 / 4 of the image to be tested, the size of the second detection feature map is 1 / 8 of the image to be tested, the size of the third detection feature map is 1 / 16 of the image to be tested, and the size of the fourth detection feature map is 1 / 32 of the image to be tested.

4. The fire early warning method based on the improved YOLOv5 algorithm according to claim 1, characterized in that, The attention module CAB is constructed based on the coordinate attention mechanism and uses the mish function as the activation function of the batch normalization layer.

5. The fire early warning method based on the improved YOLOv5 algorithm according to claim 1, characterized in that, The preprocessing of the streaming media data to obtain the image sequence to be tested includes: The streaming media data is saved as an image sequence at interval frames; The image sequence is normalized to obtain the image sequence to be tested.

6. The fire early warning method based on the improved YOLOv5 algorithm according to claim 1, characterized in that, The determination of whether a fire has occurred based on the detection results of the fire detection model includes: Based on the detection results, the fire type and probability of occurrence are analyzed. The predicted voting value is obtained by analyzing and comparing the occurrence probability with the threshold. The predicted voting values ​​are used to determine whether a fire has occurred.

7. The fire early warning method based on the improved YOLOv5 algorithm according to claim 1, characterized in that, The steps for acquiring and preprocessing training data during the training of the fire detection model include: Acquire a multi-scene fire image set containing both flames and smoke as targets; The images in the fire image set are normalized to a preset size, and the background is filled with gray to obtain a standard image set; An enhanced image set is obtained by performing affine transformation, transmission transformation, and combined transformation on the images in the standard image set. A certain number of images from the enhanced image set are selected as the training image set.

8. A fire early warning system based on an improved YOLOv5 algorithm, used to implement the method as described in any one of claims 1-7, characterized in that, include: The data acquisition unit is used to acquire streaming media data; The data input unit is used to preprocess the streaming media data to obtain a sequence of images to be tested, and to sequentially input the images to be tested in the sequence of images to be tested into the fire detection unit for detection. The fire detection unit is used to detect the image to be tested and obtain the detection result. The fire detection unit is built based on the YOLOv5 improved algorithm and includes a backbone network for feature extraction, a feature fusion module for multi-scale feature fusion, and four detection heads with different receptive fields. The backbone network has a deep attention module CAB. The result output unit is used to determine whether a fire has occurred based on the detection results.

Citation Information

Patent Citations

  • Flame detection method based on improved YOLOv5 model

    CN114662605A

  • Fire detection method based on improved YOLOV5

    CN114821423A

  • Flame and smoke detection method and device and storage medium

    CN115424171A