Urban fire early warning analysis method
By improving the YOLOv5s network model and using ShuffleNetv2 and attention mechanism CA, the problem of insufficient accuracy of lightweight models in fire warning detection is solved, efficient and accurate fire detection is achieved, and computing resource requirements are reduced.
Patent Information
- Application Number
- CN202410606212.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-16
- Publication Date
- 2024-08-27
AI Technical Summary
Among existing fire warning detection technologies, lightweight models lack detection accuracy, while high-precision models require a large amount of computing resources and complex model architectures, resulting in low detection efficiency.
The improved YOLOv5s network model is adopted, the lightweight network framework ShuffleNetv2 is used to replace Darknet53, the attention mechanism CA is introduced, and the loss function CIOU is replaced by EIOU to optimize feature extraction and target detection.
It improves the speed and accuracy of fire detection, reduces the amount of model parameters and calculations, improves the model's reasoning speed and generalization ability, and enhances the sensitivity and regression accuracy of the target frame.
Smart Images

Figure CN118552873A
Abstract
Description
Technical Field
[0001] The invention belongs to the field of urban safety and fire protection, and in particular relates to an urban fire early warning analysis method. Background Art
[0002] There are two main types of smoke detection technologies currently used for fire warning, namely traditional feature extraction-based smoke detection methods and deep learning-based smoke detection methods. The traditional feature extraction-based smoke detection method first uses the background modeling method to obtain the suspected smoke area, then manually extracts relevant features based on the smoke characteristics, and finally achieves classification and recognition through network training. The deep learning-based smoke detection method uses deep learning architectures such as convolutional neural networks (CNNs) to automatically learn and extract deeper and more abstract smoke features by training a large amount of image data, thereby achieving more efficient detection performance.
[0003] Traditional feature extraction-based video smoke detection technology mainly relies on manually designed feature extractors, combining features such as color, texture, motion and energy to characterize the characteristics of smoke, thereby distinguishing smoke from non-smoke. However, this method relies too much on manual feature extraction, which is not only time-consuming and labor-intensive, but also the instability of feature quality will directly affect the smoke detection effect. Compared with the traditional manual feature extraction method, the video smoke detection method based on deep learning can more effectively extract deep and abstract features. Through continuous iterative training and parameter updates, a deep network model that can better capture the characteristics of smoke is generated, thereby obtaining better smoke detection performance. Although a deeper and wider network structure can improve detection accuracy, a complex network structure will also reduce the real-time performance of detection. The model designed in the current study has not yet achieved an ideal balance between lightweight and detection accuracy. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide an urban fire warning analysis method to solve the problem that in the existing fire warning detection technology, lightweight models lack sufficient detection accuracy, while high-precision models often require a large amount of computing resources and complex model architecture. The method of the present invention uses deep learning to automatically identify and locate fires and smoke in video images, and sends warning signals in a timely manner to reduce the loss of personnel and property and improve the efficiency and effectiveness of fire prevention and rescue.
[0005] To achieve the above object, the technical solution adopted by the present invention is as follows:
[0006] The urban fire early warning analysis method of the present invention comprises the following steps:
[0007] 1) Collect video images of fire scene monitoring in real time through cameras;
[0008] 2) Preprocessing the collected video image to obtain the image to be detected;
[0009] 3) Use the improved YOLOv5s network model to detect the preprocessed image and obtain the image smoke detection result;
[0010] 4) Determine whether the number of consecutive smoke detections exceeds a threshold. If it exceeds a preset threshold, it is considered that a fire has occurred and an early warning notification is issued; if it does not exceed the threshold, return to step 1).
[0011] Furthermore, the method for preprocessing the collected video image in step 2) is as follows:
[0012] Calculate the scaling ratios c1 and c2 of the input image;
[0013] c1=s / a
[0014] c2=s / b
[0015] Among them, s is the standard size required for network input; a and b are the width and height of the initial image respectively; select the smaller of c1 and c2 as the scaling ratio; when the scaling ratio is c1, multiply c1 by a and b respectively to get the scaled sizes m and n. At this time, m and s are equal, and there is no need to fill the width on both sides. Use (sn) / 2 to fill the height on both sides to get an input image of size s*s.
[0016] Furthermore, the improved YOLOv5s network model in step 3) includes:
[0017] Use the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network;
[0018] Introduce attention mechanism CA into the backbone network to optimize feature extraction;
[0019] The loss function CIOU of the original YOLOv5s network model is replaced by EIOU.
[0020] Furthermore, the improved YOLOv5s network model in step 3) includes three parts: a backbone network Backbone, a neck network Neck and a prediction head network Prediction;
[0021] The backbone network Backbone is used to extract features from the input image and use the extracted features as the input of the neck network Neck; the backbone network includes the first Conv module, the Maxpool module, the first ShuffleNetv2_2 module, the first ShuffleNetv2_1 module, the second ShuffleNetv2_2 module, the second ShuffleNetv2_1 module, the third ShuffleNetv2_2 module, the attention mechanism CA module and the third ShuffleNetv2_1 module in sequence;
[0022] The neck network Neck adopts the structure of FPN and PAN, in which FPN generates a top-down feature pyramid; PAN generates a bottom-up feature pyramid. The two structures cooperate with each other to aggregate the parameters of different backbone layers and different prediction layers together; the neck network includes the second Conv module, the first Upsample module, the first C3 module, the third Conv module, the second Upsample module, the second C3 module, the fourth Conv module, the third C3 module, the fifth Conv module and the fourth C3 module in sequence;
[0023] The input image to be detected is subjected to feature extraction by the first Conv module, the Maxpool module and the first ShuffleNetv2_2 module, and then input into the first ShuffleNetv2_1 module to obtain the first feature map P1;
[0024] The first feature map P1 is input into the second ShuffleNetv2_1 module after feature extraction by the second ShuffleNetv2_2 module to obtain the second feature map P2;
[0025] The second feature map P2 is input into the third ShuffleNetv2_1 module after feature extraction by the third ShuffleNetv2_2 module and the attention mechanism CA module to obtain the third feature map P3;
[0026] After the third feature map P3 is subjected to feature extraction by the second Conv module, a fourth feature map P4 is obtained;
[0027] The fourth feature map P4 is processed by the first Upsample module and concatenated with the second feature map P2 processed by the second ShuffleNetv2_1 module of the backbone network, and then processed by the first C3 module and the third Conv module to obtain the fifth feature map P5;
[0028] The fifth feature map P5 processed by the second Upsample module is concatenated with the first feature map P1 processed by the first ShuffleNetv2_1 module of the backbone network to obtain a sixth feature map P6;
[0029] The sixth feature map P6 is processed by the second C3 module to obtain the seventh feature map P7; the seventh feature map P7 is then convolved to obtain the first detection feature map DP1;
[0030] The seventh feature map P7 is processed by the fourth Conv module and then concatenated with the fifth feature map P5 obtained by the third Conv module, and then processed by the third C3 module to obtain the eighth feature map P8, and then the eighth feature map P8 is convolved to obtain the second detection feature map DP2;
[0031] The eighth feature map P8 is processed by the fifth Conv module and concatenated with the fourth feature map P4 obtained by the second Conv module, and then processed by the fourth C3 module to obtain a ninth feature map, and then the ninth feature map P9 is convolved to obtain a third detection feature map DP3;
[0032] The prediction head network Prediction includes three prediction layers of different scales, which are suitable for detecting large, medium and small targets respectively. After the feature map to be detected is input into the prediction layer, the position and size of the prediction box are calculated by the predicted offset and scale. At the same time, the probability distribution of the predicted target belonging to each category is predicted. After non-maximum suppression processing, the prediction boxes with high overlap are filtered out and the box with the highest confidence is retained as the final detection result.
[0033] Furthermore, the backbone network Backbone uses the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network, including the basic unit ShuffleNetv2_1 and the spatial downsampling unit ShuffleNetv2_2:
[0034] The basic unit ShuffleNetv2_1 divides the feature channel into two parts through Channel Split, one part is not processed, and the other part is processed by convolution and batch normalization, and then the two parts are spliced, and feature reorganization and fusion are performed through Channel Shuffle;
[0035] The spatial downsampling unit ShuffleNetv2_2 does not perform channel division. After the feature input, it is spliced after the two-way convolution feature dimensionality reduction, and finally the feature is reorganized and fused through Channel Shuffle.
[0036] Furthermore, the attention mechanism CA is introduced into the backbone network, which includes two stages: embedding coordinate information into channel attention and generating coordinate attention:
[0037] The coordinate information embedding stage performs average pooling in the X direction and average pooling in the Y direction on the features with an input feature size of H×W×C to obtain an output of each channel with a height of h and a width of w, where H, W, and C are the height, width, and number of channels of the feature map, respectively;
[0038] Use a pooling kernel of size (H, 1) to pool each channel along the horizontal X direction, as expressed below:
[0039]
[0040] in, is the output of the cth channel with height h, x c (h,i) is the eigenvector of the i-th row;
[0041] Use a pooling kernel of size (1, W) to pool each channel along the vertical Y direction. The expression is as follows:
[0042]
[0043] in, is the output of the cth channel with width w, x c (j,w) is the jth column eigenvector;
[0044] By performing pooling operations in the X and Y directions, a pair of direction-aware attention maps are obtained, including an output feature z with a height of h and a number of channels c. h and output feature z with width w and number of channels c w ; One-dimensional global pooling operation is used to aggregate features in two spatial directions, so that the attention mechanism CA module can capture the correlation along one spatial direction while preserving the position information along another spatial direction;
[0045] The coordinate generation attention stage concatenates the output features in the X and Y directions, and then uses 1x1 convolution to perform F1 change operation, as shown below:
[0046] f=δ(F1([z h ,z w ]))
[0047] Among them, f is the intermediate feature map encoding spatial information in the horizontal X direction and the vertical Y direction, δ is the nonlinear activation function, F1 is the 1x1 convolution transformation, and z h 、z w is the encoding output;
[0048] Split f into two-dimensional tensors, and use 1x1 convolution to transform the number of channels of the tensors in the two directions to the same as the input features, and then use the Sigmoid activation function to obtain the attention weight matrix g w , g h , the expression is as follows:
[0049] g h =σ(F h (f h ))
[0050] g w =σ(F w (f w ))
[0051] Among them, f h 、f w are the segmentation tensors in the horizontal and vertical directions, respectively, h 、F w They are 1x1 convolution transformation, g h , g w are the attention weight matrices in the horizontal and vertical directions respectively, and σ is the Sigmoid activation function;
[0052] The expression of attention mechanism CA is as follows:
[0053]
[0054] Among them, y c (i,j) is the final output, x c (i,j) is the input feature map, Attention maps in the horizontal and vertical directions respectively.
[0055] Furthermore, in step 3), the loss function of the original YOLOv5 model is replaced by EIOU from CIOU. By separating the length and width of the target box for calculation, the problem of CIOU aspect ratio ambiguity is solved, the sensitivity of the model to the target box is enhanced, and the convergence speed and regression accuracy of the model are improved. The calculation formula is as follows:
[0056]
[0057]
[0058]
[0059]
[0060]
[0061] Among them, IOU is the overlapping area loss, CIOU is the loss function used in the target detection task, which measures the similarity between the predicted box and the real labeled box. A and B are the predicted box and the real box respectively, b p 、b gt are the center coordinates of the predicted box and the center coordinates of the real box, respectively, p 、h p are the width and height of the prediction box, w gt 、h gt are the width and height of the real box, ρ is the Euclidean distance between the center points of the real box and the predicted box, and c d is the diagonal distance of the minimum circumscribed matrix between the predicted box and the real box, c h 、c w are the width and height of the minimum circumscribed matrix of the predicted box and the true box, respectively. α is a positive trade-off parameter, and ν is a parameter for measuring the consistency of aspect ratio. From the above formula, the loss function is divided into IOU loss, distance loss, and side length loss, which reflect the width and height of the predicted box and the true box.
[0062] Furthermore, the step 4) specifically includes:
[0063] Initialize a counter to zero to record the number of consecutive smoke detections;
[0064] When smoke is detected, the counter is incremented by 1, otherwise the counter is cleared to zero;
[0065] After each smoke detection, check whether the number of consecutive smoke detections exceeds the preset threshold. If the number of consecutive smoke detections is greater than or equal to the preset threshold, it is considered that a fire has occurred and a fire warning notification is triggered; if the number of consecutive smoke detections is less than the preset threshold, it is considered to be a false detection and smoke detection continues.
[0066] Beneficial effects of the present invention:
[0067] 1. Based on the improved YOLOv5s video smoke detection algorithm, the present invention uses the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network, which reduces the number of model parameters and the amount of calculation, improves the model's reasoning speed, and effectively improves the speed of fire detection.
[0068] 2. The present invention introduces the attention mechanism CA into the model backbone network. By adjusting the attention weights, the model can focus more on important features and the features that contribute less to the results, which effectively improves the generalization ability of the model and effectively improves the accuracy of fire detection.
[0069] 3. The present invention uses EIOU instead of CIOU as the loss function of the model, which enhances the sensitivity of the model to the target box, improves the convergence speed and regression accuracy of the model, and further improves the detection speed and accuracy of fire. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 is a flow chart of the method of the present invention;
[0071] Figure 2 It is a schematic diagram of the network model of the improved YOLOv5s in the present invention;
[0072] Figure 3 It is a schematic diagram of the structure of the lightweight network ShuffelNetv2 in the present invention;
[0073] Figure 4 This is the structural diagram of the attention mechanism CA in the present invention. DETAILED DESCRIPTION
[0074] In order to facilitate the understanding of those skilled in the art, the present invention is further described below in conjunction with embodiments and drawings. The contents mentioned in the implementation modes are not intended to limit the present invention.
[0075] Reference Figure 1-Figure 4 As shown, a city fire early warning analysis method of the present invention comprises the following steps:
[0076] 1) Collect video images of fire scene monitoring in real time through cameras;
[0077] 2) Preprocessing the collected video image to obtain the image to be detected;
[0078] Among them, the method for preprocessing the collected video images is as follows:
[0079] Calculate the scaling ratios c1 and c2 of the input image;
[0080] c1=s / a
[0081] c2=s / b
[0082] Among them, s is the standard size required for network input; a and b are the width and height of the initial image respectively; select the smaller of c1 and c2 as the scaling ratio; when the scaling ratio is c1, multiply c1 by a and b respectively to get the scaled sizes m and n. At this time, m and s are equal, and there is no need to fill the width on both sides. Use (sn) / 2 to fill the height on both sides to get an input image of size s*s.
[0083] 3) Use the improved YOLOv5s network model to detect the preprocessed image and obtain the image smoke detection result;
[0084] The improved YOLOv5s network model includes:
[0085] Use the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network;
[0086] Introduce attention mechanism CA into the backbone network to optimize feature extraction;
[0087] The loss function CIOU of the original YOLOv5s network model is replaced by EIOU.
[0088] Among them, the improved YOLOv5s network model consists of three parts: backbone network Backbone, neck network Neck and prediction head network Prediction;
[0089] The backbone network Backbone is used to extract features from the input image and use the extracted features as the input of the neck network Neck; the backbone network includes the first Conv module, the Maxpool module, the first ShuffleNetv2_2 module, the first ShuffleNetv2_1 module, the second ShuffleNetv2_2 module, the second ShuffleNetv2_1 module, the third ShuffleNetv2_2 module, the attention mechanism CA module and the third ShuffleNetv2_1 module in sequence;
[0090] The neck network Neck adopts the structure of FPN and PAN, in which FPN generates a top-down feature pyramid; PAN generates a bottom-up feature pyramid. The two structures cooperate with each other to aggregate the parameters of different backbone layers and different prediction layers together; the neck network includes the second Conv module, the first Upsample module, the first C3 module, the third Conv module, the second Upsample module, the second C3 module, the fourth Conv module, the third C3 module, the fifth Conv module and the fourth C3 module in sequence;
[0091] The input image to be detected is subjected to feature extraction by the first Conv module, the Maxpool module and the first ShuffleNetv2_2 module, and then input into the first ShuffleNetv2_1 module to obtain the first feature map P1;
[0092] The first feature map P1 is input into the second ShuffleNetv2_1 module after feature extraction by the second ShuffleNetv2_2 module to obtain the second feature map P2;
[0093] The second feature map P2 is input into the third ShuffleNetv2_1 module after feature extraction by the third ShuffleNetv2_2 module and the attention mechanism CA module to obtain the third feature map P3;
[0094] After the third feature map P3 is subjected to feature extraction by the second Conv module, a fourth feature map P4 is obtained;
[0095] The fourth feature map P4 is processed by the first Upsample module and concatenated with the second feature map P2 processed by the second ShuffleNetv2_1 module of the backbone network, and then processed by the first C3 module and the third Conv module to obtain the fifth feature map P5;
[0096] The fifth feature map P5 processed by the second Upsample module is concatenated with the first feature map P1 processed by the first ShuffleNetv2_1 module of the backbone network to obtain a sixth feature map P6;
[0097] The sixth feature map P6 is processed by the second C3 module to obtain the seventh feature map P7; the seventh feature map P7 is then convolved to obtain the first detection feature map DP1;
[0098] The seventh feature map P7 is processed by the fourth Conv module and then concatenated with the fifth feature map P5 obtained by the third Conv module, and then processed by the third C3 module to obtain the eighth feature map P8, and then the eighth feature map P8 is convolved to obtain the second detection feature map DP2;
[0099] The eighth feature map P8 is processed by the fifth Conv module and concatenated with the fourth feature map P4 obtained by the second Conv module, and then processed by the fourth C3 module to obtain a ninth feature map, and then the ninth feature map P9 is convolved to obtain a third detection feature map DP3;
[0100] The prediction head network Prediction includes three prediction layers of different scales, which are suitable for detecting large, medium and small targets respectively. After the feature map to be detected is input into the prediction layer, the position and size of the prediction box are calculated by the predicted offset and scale, and the probability distribution of the target belonging to each category is predicted. After non-maximum suppression (NMS) processing, the prediction boxes with high overlap are filtered out and the box with the highest confidence is retained as the final detection result.
[0101] Specifically, the backbone network Backbone uses the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network, including the basic unit ShuffleNetv2_1 and the spatial downsampling unit ShuffleNetv2_2:
[0102] The basic unit ShuffleNetv2_1 divides the feature channel into two parts through Channel Split, one part is not processed, and the other part is processed by convolution and batch normalization, and then the two parts are spliced, and feature reorganization and fusion are performed through Channel Shuffle;
[0103] The spatial downsampling unit ShuffleNetv2_2 does not perform channel division. After the feature input, it is spliced after the two-way convolution feature dimensionality reduction, and finally the feature is reorganized and fused through Channel Shuffle.
[0104] Specifically, the attention mechanism CA is introduced in the backbone network, which includes two stages: embedding coordinate information into channel attention and generating coordinate attention:
[0105] The coordinate information embedding stage performs average pooling in the X direction and average pooling in the Y direction on the features with an input feature size of H×W×C to obtain an output of each channel with a height of h and a width of w, where H, W, and C are the height, width, and number of channels of the feature map, respectively;
[0106] Use a pooling kernel of size (H, 1) to pool each channel along the horizontal X direction, as expressed below:
[0107]
[0108] in, is the output of the cth channel with height h, x c (h,i) is the eigenvector of the i-th row;
[0109] Use a pooling kernel of size (1, W) to pool each channel along the vertical Y direction. The expression is as follows:
[0110]
[0111] in, is the output of the cth channel with width w, x c (j,w) is the jth column eigenvector;
[0112] By performing pooling operations in the X and Y directions, a pair of direction-aware attention maps are obtained, including an output feature z with a height of h and a number of channels c. hand output feature z with width w and number of channels c w ; One-dimensional global pooling operation is used to aggregate features in two spatial directions, so that the attention mechanism CA module can capture the correlation along one spatial direction while preserving the position information along another spatial direction;
[0113] The coordinate generation attention stage concatenates the output features in the X and Y directions, and then uses 1x1 convolution to perform F1 change operation, as shown below:
[0114] f=δ(F1([z h ,z w ]))
[0115] Among them, f is the intermediate feature map encoding spatial information in the horizontal X direction and the vertical Y direction, δ is the nonlinear activation function, F1 is the 1x1 convolution transformation, and z h 、z w is the encoding output;
[0116] Split f into two-dimensional tensors, and use 1x1 convolution to transform the number of channels of the tensors in the two directions to the same as the input features, and then use the Sigmoid activation function to obtain the attention weight matrix g w , g h , the expression is as follows:
[0117] g h =σ(F h (f h ))
[0118] g w =σ(F w (f w ))
[0119] Among them, f h 、f w are the segmentation tensors in the horizontal and vertical directions, respectively, h 、F w They are 1x1 convolution transformation, g h , g w are the attention weight matrices in the horizontal and vertical directions respectively, and σ is the Sigmoid activation function;
[0120] The expression of attention mechanism CA is as follows:
[0121]
[0122] Among them, y c (i,j) is the final output, x c (i,j) is the input feature map, Attention maps in the horizontal and vertical directions respectively.
[0123] The loss function of the original YOLOv5 model is replaced by EIOU from CIOU. By separating the length and width of the target box, the problem of CIOU aspect ratio ambiguity is solved, the model's sensitivity to the target box is enhanced, and the model's convergence speed and regression accuracy are improved. The calculation formula is as follows:
[0124]
[0125]
[0126]
[0127]
[0128]
[0129] Among them, IOU is the overlapping area loss, CIOU is the loss function used in the target detection task, which measures the similarity between the predicted box and the real labeled box. A and B are the predicted box and the real box respectively, b p 、b gt are the center coordinates of the predicted box and the center coordinates of the real box, respectively, p 、h p are the width and height of the prediction box, w gt 、h gt are the width and height of the real box, ρ is the Euclidean distance between the center points of the real box and the predicted box, and c d is the diagonal distance of the minimum circumscribed matrix between the predicted box and the real box, c h 、c w are the width and height of the minimum circumscribed matrix of the predicted box and the true box, respectively. α is a positive trade-off parameter, and ν is a parameter for measuring the consistency of aspect ratio. From the above formula, the loss function is divided into IOU loss, distance loss, and side length loss, which reflect the width and height of the predicted box and the true box.
[0130] 4) Determine whether the number of consecutive smoke detections exceeds a threshold. If it exceeds a preset threshold, it is considered that a fire has occurred and an early warning notification is issued; if it does not exceed the threshold, return to step 1);
[0131] Initialize a counter to zero to record the number of consecutive smoke detections;
[0132] When smoke is detected, the counter is incremented by 1, otherwise the counter is cleared to zero;
[0133] After each smoke detection, check whether the number of consecutive smoke detections exceeds the preset threshold. If the number of consecutive smoke detections is greater than or equal to the preset threshold, it is considered that a fire has occurred and a fire warning notification is triggered; if the number of consecutive smoke detections is less than the preset threshold, it is considered to be a false detection and smoke detection continues.
[0134] The present invention has many specific application paths. The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements can be made without departing from the principle of the present invention. These improvements should also be regarded as the protection scope of the present invention.
Claims
1. A method for analyzing urban fire warning. It is characterized in that Here are the steps: 1) Collect video images of fire scene monitoring in real time through cameras; 2) Preprocessing the collected video image to obtain the image to be detected; 3) Use the improved YOLOv5s network model to detect the preprocessed image and obtain the image smoke detection result; 4) Determine whether the number of consecutive smoke detections exceeds a threshold. If it exceeds a preset threshold, it is considered that a fire has occurred and an early warning notification is issued; If the threshold is not exceeded, return to step 1).
2. The urban fire early warning analysis method according to claim 1, It is characterized in that The method for preprocessing the collected video image in step 2) is as follows: Calculate the scaling ratio c of the input image 1 、c 2 ; c 1 =s / a c 2 =s / b Among them, s is the standard size required by the network input; a and b are the width and height of the initial image respectively; select c 1 、c 2 Small and medium are used as the scaling ratio; the scaling ratio is c 1 When c 1 Multiply them by a and b respectively to get the scaled sizes m and n. At this time, m and s are equal, and there is no need to fill the width on both sides. Use (sn) / 2 to fill the height on both sides to get an input image of size s*s.
3. The urban fire early warning analysis method according to claim 1, It is characterized in that The improved YOLOv5s network model in step 3) includes: Use the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network; Introduce attention mechanism CA into the backbone network to optimize feature extraction; The loss function CIOU of the original YOLOv5s network model is replaced by EIOU.
4. The urban fire early warning analysis method according to claim 1, It is characterized in that The improved YOLOv5s network model in step 3) includes three parts: a backbone network Backbone, a neck network Neck and a prediction head network Prediction; The backbone network Backbone is used to extract features from the input image and use the extracted features as the input of the neck network Neck; the backbone network includes the first Conv module, the Maxpool module, the first ShuffleNetv2_2 module, the first ShuffleNetv2_1 module, the second ShuffleNetv2_2 module, the second ShuffleNetv2_1 module, the third ShuffleNetv2_2 module, the attention mechanism CA module and the third ShuffleNetv2_1 module in sequence; The neck network Neck adopts the structure of FPN and PAN, in which FPN generates a top-down feature pyramid; PAN generates a bottom-up feature pyramid. The two structures cooperate with each other to aggregate the parameters of different backbone layers and different prediction layers together; the neck network includes the second Conv module, the first Upsample module, the first C3 module, the third Conv module, the second Upsample module, the second C3 module, the fourth Conv module, the third C3 module, the fifth Conv module and the fourth C3 module in sequence; The input image to be detected is subjected to feature extraction by the first Conv module, the Maxpool module, and the first ShuffleNetv2_2 module, and then input into the first ShuffleNetv2_1 module to obtain the first feature map P 1 ; The first feature map P 1 After feature extraction by the second ShuffleNetv2_2 module, it is input into the second ShuffleNetv2_1 module to obtain the second feature map P 2 ; The second feature map P 2 After feature extraction by the third ShuffleNetv2_2 module and the attention mechanism CA module, it is input into the third ShuffleNetv2_1 module to obtain the third feature map P 3 ; The third feature map P 3 After feature extraction by the second Conv module, the fourth feature map P is obtained 4 ; The fourth feature map P 4 The second feature map P is obtained after being processed by the first Upsample module and the second ShuffleNetv2_1 module of the backbone network. 2 After splicing, it is processed by the first C3 module and the third Conv module to obtain the fifth feature map P 5 ; The fifth feature map P 5 The first feature map P obtained by processing the second Upsample module and the first ShuffleNetv2_1 module of the backbone network 1 Splice and get the sixth feature map P 6 ; The sixth feature map P 6 After being processed by the second C3 module, the seventh feature map P is obtained. 7 ; Then perform a convolution operation on the seventh feature map P7 to obtain the first detection feature map DP 1 ; The seventh feature map P 7 After being processed by the fourth Conv module, the fifth feature map P obtained by the third Conv module 5 After splicing, and then processed by the third C3 module, the eighth feature map P is obtained. 8 , and then the eighth feature map P 8 Perform convolution operation to obtain the second detection feature map DP 2 ; The eighth feature map P 8 After being processed by the fifth Conv module, the fourth feature map P obtained by the second Conv module 4 After splicing, the ninth feature map is obtained after being processed by the fourth C3 module. 9 Perform convolution operation to obtain the third detection feature map DP 3 ; The prediction head network Prediction includes three prediction layers of different scales, which are suitable for detecting large, medium and small targets respectively. After the feature map to be detected is input into the prediction layer, the position and size of the prediction box are calculated by the predicted offset and scale. At the same time, the probability distribution of the predicted target belonging to each category is predicted. After non-maximum suppression processing, the prediction boxes with high overlap are filtered out and the box with the highest confidence is retained as the final detection result.
5. The urban fire early warning analysis method according to claim 1, It is characterized in that The backbone network Backbone uses the lightweight network framework ShuffleNetv2 to replace the Darknet53 framework in the original backbone network, including the basic unit ShuffleNetv2_1 and the spatial downsampling unit ShuffleNetv2_2: The basic unit ShuffleNetv2_1 divides the feature channel into two parts through Channel Split, one part is not processed, and the other part is processed by convolution and batch normalization, and then the two parts are spliced, and feature reorganization and fusion are performed through ChannelShuffle; The spatial downsampling unit ShuffleNetv2_2 does not perform channel division. After the feature input, it is spliced after the two-way convolution feature dimensionality reduction, and finally the feature is reorganized and fused through Channel Shuffle.
6. The urban fire early warning analysis method according to claim 1, It is characterized in that The attention mechanism CA is introduced in the backbone network, which includes two stages: embedding coordinate information into channel attention and generating coordinate attention: The coordinate information embedding stage performs average pooling in the X direction and average pooling in the Y direction on the features with an input feature size of H×W×C to obtain an output of each channel with a height of h and a width of w, where H, W, and C are the height, width, and number of channels of the feature map respectively; Use a pooling kernel of size (H, 1) to pool each channel along the horizontal X direction, as expressed below: in, is the output of the cth channel with height h, x c (h,i) is the eigenvector of the i-th row; Use a pooling kernel of size (1, W) to pool each channel along the vertical Y direction. The expression is as follows: in, is the output of the cth channel with width w, x c (j,w) is the jth column eigenvector; By performing pooling operations in the X and Y directions, a pair of direction-aware attention maps are obtained, including an output feature z with a height of h and a number of channels c. h and output feature z with width w and number of channels c w ; One-dimensional global pooling operation is used to aggregate features in two spatial directions, so that the attention mechanism CA module can capture the correlation along one spatial direction while preserving the position information along another spatial direction; The coordinate generation stage concatenates the output features in the X and Y directions, and then uses 1x1 convolution for F 1 The change operation is expressed as follows: f=δ(F 1 ([z h ,z w ])) Among them, f is the intermediate feature map that encodes spatial information in the horizontal X direction and the vertical Y direction, δ is the nonlinear activation function, and F 1 is a 1x1 convolution transformation, z h 、z w is the encoding output; Split f into two-dimensional tensors, and use 1x1 convolution to transform the number of channels of the tensors in the two directions to the same as the input features, and then use the Sigmoid activation function to obtain the attention weight matrix g w , g h , the expression is as follows: g h =σ(F h (f h )) g w =σ(F w (f w )) Among them, f h 、f w are the segmentation tensors in the horizontal and vertical directions, respectively, h 、F w They are 1x1 convolution transformation, g h , g w are the attention weight matrices in the horizontal and vertical directions respectively, and σ is the Sigmoid activation function; The expression of attention mechanism CA is as follows: Among them, y c (i,j) is the final output, x c (i,j) is the input feature map, Attention maps in the horizontal and vertical directions respectively.
7. The urban fire early warning analysis method according to claim 1, It is characterized in that In the step 3), the loss function of the original YOLOv5 model is replaced by EIOU from CIOU. By separating the length and width of the target box for calculation, the problem of CIOU aspect ratio ambiguity is solved, the sensitivity of the model to the target box is enhanced, and the convergence speed and regression accuracy of the model are improved. The calculation formula is as follows: Among them, IOU is the overlapping area loss, CIOU is the loss function used in the target detection task, which measures the similarity between the predicted box and the real labeled box. A and B are the predicted box and the real box respectively, b p 、b gt are the center coordinates of the predicted box and the center coordinates of the real box, respectively, p 、h p are the width and height of the prediction box, w gt 、h gt are the width and height of the real box, ρ is the Euclidean distance between the center points of the real box and the predicted box, and c d is the diagonal distance of the minimum circumscribed matrix between the predicted box and the real box, c h 、c w are the width and height of the minimum circumscribed matrix of the predicted box and the true box, α is a positive trade-off parameter, and ν is a parameter to measure the consistency of aspect ratio.
8. The urban fire early warning analysis method according to claim 1, It is characterized in that The step 4) specifically includes: Initialize a counter to zero to record the number of consecutive smoke detections; When smoke is detected, the counter is incremented by 1, otherwise the counter is cleared to zero; After each smoke detection, check whether the number of consecutive smoke detections exceeds the preset threshold. If the number of consecutive smoke detections is greater than or equal to the preset threshold, it is considered that a fire has occurred and a fire warning notification is triggered; if the number of consecutive smoke detections is less than the preset threshold, it is considered to be a false detection and smoke detection continues.
Citation Information
Patent Citations
Fire detection alarm method, related system, related equipment and storage medium
CN113012383A
Target detection method based on lightweight target detection convolutional neural network
CN115187994A
Oil and gas station fire detection method, system, medium, equipment and terminal
CN116563762A
Cited By
Intelligent management system for smart factory
CN119558802A
Glass fiber filament flying and breaking early warning and disposal method based on AI visual analysis
CN119599977A
