Model training method and fire detection method
By adding convolutional layer, C2F-MBC module and spatial attention module in the YOLOv8 model, combined with improved loss function, the problems of false alarms and missed reports in complex environments of traditional fire detection methods are solved, and the accuracy of fire detection is improved and robustness ensures construction site safety.
Patent Information
- Application Number
- CN202411149403.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-12-13
AI Technical Summary
Traditional fire detection methods are prone to false alarms or missed reports in complex construction site environments, and have limited generalization capabilities, so they cannot effectively identify flames and smoke burning from different materials, especially under light changes and background interference.
Using YOLOv8 to improve the model, by adding convolutional layer and residual layer, C2F-MBC module and spatial attention module in the feature extraction part, combined with the improved loss function, the model's accuracy and robustness of fire detection are improved and errors are reduced. Rate of return.
In complex environments such as large dynamic changes, frequent visual occlusion, complex lighting conditions and uneven smoke distribution, the accuracy of fire detection is significantly improved, the false alarm rate is reduced, and the performance of the model in construction site safety management is improved.
Smart Images

Figure CN119131348A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of target detection technology, and in particular to a model training method and a fire detection method. Background Art
[0002] With the increase in the number of construction projects and the expansion of engineering scale, higher requirements are placed on construction site safety management capabilities. Fire detection is particularly important in construction site safety management.
[0003] In related technologies, traditional fire detection methods, such as Haar cascades, support vector machines, and simple neural networks, require manually designed feature extractors to identify flames and smoke in images when performing real-time fire detection tasks in complex and dynamic environments such as construction sites. They rely on explicitly programmed features and rules and usually perform well under the specific conditions seen during training.
[0004] However, the handcrafted features used in these methods, such as color, shape, and texture, are highly sensitive to lighting variations, occlusions, and background interference, making them prone to false positives and false negatives in complex construction environments. Furthermore, because they rely on explicitly programmed features and rules, they typically only perform well under the specific conditions seen during training. Their performance typically degrades significantly in new or unseen environments, such as flames from burning materials, smoke, or complex lighting conditions. This results in limited generalization and robustness. Summary of the Invention
[0005] In view of this, this application provides a model training method and a fire detection method to improve the accuracy of fire detection and reduce the false alarm rate in complex environments such as large dynamic changes, frequent line of sight obstructions, complex lighting conditions and uneven smoke distribution, so as to ensure construction site safety.
[0006] In a first aspect, the present application provides a model training method, the method comprising:
[0007] Obtain a sample fire dataset, a sample fire annotation dataset, and a YOLOv8 improved model, wherein the YOLOv8 improved model includes a convolutional layer and a residual layer added between Layer 8 and Layer 9 of the feature extraction part, a C2F-MBC module, and a spatial attention module added before the SPPF module of the feature extraction part;
[0008] Based on the sample fire dataset and the sample fire annotated dataset, a YOLOv8 improved model is trained to obtain a target fire detection model.
[0009] In some embodiments, the training of the YOLOv8 improved model based on the sample fire dataset and the sample fire annotated dataset to obtain a target fire detection model includes:
[0010] Training a YOLOv8 improved model based on the sample fire dataset and the sample fire labeled dataset to obtain an intermediate YOLOv8 improved model;
[0011] In response to the performance of the intermediate YOLOv8 improved model satisfying the training completion condition, the intermediate YOLOv8 improved model satisfying the training completion condition is used as the target fire detection model; in response to the performance of the intermediate YOLOv8 improved model not satisfying the training completion condition, the training weights and training parameters of the intermediate YOLOv8 improved model are adjusted until the performance of the intermediate YOLOv8 improved model satisfies the training completion condition, the training parameters including one or more parameters of an initial learning rate, a number of training iterations, and a hyperparameter.
[0012] In some embodiments, the YOLOv8 improved model is a model obtained by improving the YOLOv8 model, and the improvement process includes:
[0013] Add convolutional layers and residual layers between Layer 8 and Layer 9 in the feature extraction part;
[0014] Add an upsampling layer, a connection layer, and a C2F module between Layer 10 and Layer 19 in the feature fusion part, and derive the detection head from the C2F module;
[0015] The channel attention in the MBConv module is replaced by the ESE module, and the CBS module in the C2F module is replaced by the improved MBConv module to obtain the C2F-MBC module, wherein the improved MBConv module includes a dimensionality increase convolution layer, a depthwise separable convolution layer, an ESE module, a dimensionality reduction convolution layer, and a Dropout layer;
[0016] The spatial attention module is added before the SPPF module in the feature extraction part.
[0017] In some embodiments, the training completion condition is the accuracy, recall, mAP of the intermediate YOLOv8 improved model. 50 and mAP 50-95 No rise for 50 consecutive rounds.
[0018] In some embodiments, the training of the improved YOLOv8 model based on the sample fire dataset and the sample fire annotated dataset to obtain a target fire detection model further includes:
[0019] Verifying the trained intermediate YOLOv8 improved model based on the sample fire dataset and the verification set in the sample fire annotated dataset to obtain a verification result;
[0020] Based on the verification result, the loss function of the intermediate YOLOv8 improved model is improved to obtain an improved loss function.
[0021] In some embodiments, the improved loss function is calculated according to the following formula:
[0022]
[0023] L WIOUV1 =R WIOUV L IOU
[0024]
[0025] L WIOUV3 =rL WIOUV1
[0026]
[0027] Among them, L IOU represents the standard intersection-over-union loss function, IOU represents the ratio of the area of the overlapping part of the predicted flame or smoke bounding box and the true bounding box to the area of the true bounding box, W i 、H i denote the width and height of the overlapped part of the predicted flame or smoke bounding box and the ground-truth bounding box, respectively, S u represents the area of the ground-truth bounding box, L WIOUV1 represents the first intermediate improvement loss function, exp represents the exponential function, (x, y) represents the center point coordinates of the predicted flame or smoke bounding box, (x gt ,y gt ) represents the center point coordinate of the real bounding box, W g and H g denote the width and height of the ground-truth bounding box, L WIOUV3 Represents the improved loss function, β represents the outlier is the ratio of the exponential moving mean of IoU to the simple mean, which is used to describe the quality of the anchor box, δ represents the attenuation factor used to reduce the impact of the loss function, and α represents the characteristic indicator used to adjust the sensitivity of the loss function to specific features.
[0028] In some embodiments, the dimensionality-increasing convolutional layer includes a 1*1Conv, a first BN, and a Swish activation function connected in sequence, the depth-separable convolutional layer includes a k*kConv, a second BN, and a Swish activation function connected in sequence, and the dimensionality-reducing convolutional layer includes a 1*1Conv and a third BN connected in sequence.
[0029] In some embodiments, the ESE module is improved based on the SE attention module, and includes an average pooling layer, a fully connected layer and a Sigmoid activation function connected in sequence, which is used to achieve channel feature recalibration and enhance characterization capabilities.
[0030] In some embodiments, obtaining a sample fire dataset and a sample fire annotated dataset includes:
[0031] Obtaining an original fire dataset, wherein the original fire dataset is pictures of construction site and building fire scenes;
[0032] Performing data cleaning on the original fire data set to obtain a first cleaned data set;
[0033] Encoding the cleaned data set according to a hash method to obtain a digital fingerprint corresponding to the cleaned data set;
[0034] Deduplication processing is performed on the images in the cleaned data set with the same digital fingerprint to obtain a second cleaned data set;
[0035] Deduplication processing is performed on images containing repeated features in the second cleaned data set to obtain a sample fire data set;
[0036] The flames and smoke in the sample fire dataset are labeled, and the label format is converted from JSON format to a format supported by YOLO to obtain a sample fire label dataset, where each label includes the target category, the center point coordinates of the labeled bounding box, and the width of the labeled bounding box.
[0037] In a second aspect, the present application provides a fire detection method, the method comprising:
[0038] Obtaining the target fire detection model in the model training method according to the first aspect;
[0039] The fire data set to be tested is input into the target fire detection model to obtain a fire detection result, which includes a target category, a target bounding box position, a confidence level, and a category probability. The target category includes flame and smoke.
[0040] The beneficial effects of the technical solutions provided by the embodiments of the present application include at least:
[0041] An embodiment of the present application provides a model training method and a fire detection method, which include: first, obtaining a sample fire dataset, a sample fire annotation dataset, and a YOLOv8 improved model, wherein the YOLOv8 improved model includes a convolutional layer and a residual layer added between Layer 8 and Layer 9 of the feature extraction part, a C2F-MBC module, and a spatial attention module added before the SPPF module of the feature extraction part. The added convolutional layer and residual layer enable the model to extract image features of large targets, thereby obtaining more semantic information and improving the large target detection capability. The C2F-MBC module can fully consider the channel characteristics of the feature map, improve the input feature channel capacity, reduce the number of model parameters and the amount of calculation, and extract key features. The spatial attention module can improve the model's sensitivity to spatial position by assigning different importance to different areas of the feature map, allowing the model to focus more on features related to fire, helping the model to distinguish background noise from actual signs of fire, thereby reducing false detections; then, based on the sample fire dataset and the sample fire annotation dataset, the YOLOv8 improved model is trained to obtain a target fire detection model. This method improves the accuracy of fire detection and reduces the false alarm rate in complex environments such as large dynamic changes, frequent line of sight obstructions, complex lighting conditions and uneven smoke distribution, thereby ensuring construction site safety. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0043] Figure 1 A flow chart of the model training method provided in an embodiment of the present application;
[0044] Figure 2 A schematic diagram of the structure of the improved YOLOv8 model in the model training method provided in the embodiment of the present application;
[0045] Figure 3 A schematic diagram of the structure of the C2F-MBC module in the YOLOv8 improved model of the model training method provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of the structure of the MBC module in the YOLOv8 improved model of the model training method provided in an embodiment of the present application;
[0047] Figure 5 A schematic diagram of the structure of the depthwise separable convolutional layer in the improved YOLOv8 model of the model training method provided in an embodiment of the present application;
[0048] Figure 6(a) shows the mAP of the target fire detection model and the YOLOv8 model in the model training method provided in the embodiment of the present application. 50 Comparison effect diagram;
[0049] Figure 6(b) shows the mAP of the target fire detection model and the YOLOv8 model in the model training method provided in the embodiment of the present application. 50-95 Comparison effect diagram;
[0050] Figure 7 This is a detection effect diagram of the fire detection method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0052] In order to make the technical solutions and advantages of the present application clearer, the implementation methods of the present application will be described in further detail below with reference to the accompanying drawings.
[0053] In the first aspect, this application provides a model training method, see Figure 1 , the method comprising:
[0054] Step 101: Obtain a sample fire dataset, a sample fire annotation dataset, and a YOLOv8 improved model. The YOLOv8 improved model includes a convolutional layer and a residual layer added between Layer 8 and Layer 9 of the feature extraction part, a C2F-MBC module, and a spatial attention module added before the SPPF module of the feature extraction part.
[0055] The added convolutional and residual layers enable the model to extract image features of large targets, thereby obtaining more semantic information and improving the ability to detect large targets. The C2F-MBC module can fully consider the channel characteristics of the feature map, improve the input feature channel capacity, reduce the number of model parameters and computational complexity, and extract key features. The spatial attention module can increase the model's sensitivity to spatial position by assigning different importance to different areas of the feature map, allowing the model to focus more on fire-related features, helping the model distinguish between background noise and actual signs of fire, thereby reducing false detections.
[0056] In some embodiments, step 101 specifically includes:
[0057] Step 1011: Acquire an original fire dataset, wherein the original fire dataset is pictures of construction site and building fire scenes.
[0058] The original fire dataset obtained is pictures of construction site and building fire scenes with complex environments, which makes it easier for the model to learn and deal with complex scenarios.
[0059] In some embodiments, the original fire dataset can be a fire dataset downloaded from public dataset websites such as Kaggle and Roboflow, which can be used to filter out pictures of construction site and building fire scenes. It can also be used to download construction site fire videos from search engines such as Baidu and Google, and manually capture fire pictures to supplement the original fire dataset.
[0060] Step 1012: Perform data cleaning on the original fire data set to obtain a first cleaned data set.
[0061] Using a large number of repeated samples in deep learning model training can lead to model overfitting, evaluation bias, and inefficient gradient updates. Therefore, the original fire dataset needs to be cleaned to remove duplicate images.
[0062] Step 1013: Encode the cleaned data set according to the hash method to obtain a digital fingerprint corresponding to the cleaned data set.
[0063] The cleaned data set is encoded to obtain the digital fingerprint corresponding to the cleaned data set, that is, the hash value. In this way, each image can have its own corresponding digital fingerprint. Images with the same digital fingerprint will be considered to have the same content.
[0064] In some embodiments, the cleaned data set may be encoded using a hash function MD5.
[0065] Step 1014 , performing deduplication processing on the images in the cleaned data set with the same digital fingerprint to obtain a second cleaned data set.
[0066] Deduplication can remove duplicate images with the same digital fingerprint, that is, images with the same content, and retain only one, preventing overfitting in model training.
[0067] In some embodiments, pictures with the same content include pictures with the same content but different resolutions, pictures with the same content but different watermarks, and pictures with the same content but different cropping.
[0068] Step 1015 , performing deduplication processing on the images containing repeated features in the second cleaned data set to obtain a sample fire data set.
[0069] After removing images with the same content, the remaining images may contain images with duplicate features. In order to shorten the training time and prevent overfitting, deduplication processing is performed again to remove images with duplicate features.
[0070] In some embodiments, steps 1013, 1014, and 1015 can be implemented as follows: (1) Encode the cleaned dataset using MD5 through a python script and store it in an array. Then, the array is traversed, and only one image with the same hash value is retained. The remaining images are moved to a newly created folder for backup inspection. (2) For images with the same content but different resolutions, the same content but different watermarks, and the same content but different cropping, deduplication is performed based on the deep learning SSIM (Structural Similarity) algorithm. The specific deduplication process is as follows: First, find the key feature points in the image and describe these feature points so that they can be accurately recognized in different images, even under conditions such as image scale, rotation, and brightness changes. Then, define the images with SSIM confidence greater than 0.8 as images containing duplicate features and remove them. At this point, deduplication is completed to obtain a sample fire dataset.
[0071] Step 1026 , annotate the flames and smoke in the sample fire dataset, and convert the label format from JSON format to a format supported by YOLO to obtain a sample fire label dataset, where each label includes the target category, the center point coordinates of the labeled bounding box, and the width of the labeled bounding box.
[0072] The sample fire annotated dataset is the foundation of model learning. It needs to provide the model with an accurate learning template and a label format that the model can recognize. Therefore, it is necessary to annotate the flames and smoke and convert the label format from JSON to a format supported by YOLO.
[0073] In some embodiments, the specific implementation of step 1026 can be: (1) using Labelme software to label the flames and smoke in the sample fire dataset, and using a bounding box that contains the complete flame outline and is as close to the outline edge as possible according to the different fire sources, and indicating that the target category is Fire and the smoke is labeled as Smoke. A .JSON label file will be generated for each image; (2) batch exporting JSON format labels, and then using a script to convert the label format from JSON format to YOLO supported .TXT format. (3) The label includes the target category, the center point coordinates of the labeled bounding box, and the width of the labeled bounding box. The target category "0" represents flame, the target category "1" represents smoke, and the center point coordinates of the labeled bounding box are (x, y).
[0074] In some embodiments, the sample fire annotation dataset and the corresponding sample fire annotation dataset can be 5,000 images in total. The sample fire dataset and the corresponding sample fire annotation dataset are divided into a training set and a validation set in a ratio of 4:1. The training set is used to train the YOLOv8 improved model, and the validation set is used to test the training effect of the YOLOv8 improved model.
[0075] Step 102: Based on the sample fire dataset and the sample fire annotation dataset, train the YOLOv8 improved model to obtain a target fire detection model.
[0076] This target fire detection model improves the accuracy of fire detection and reduces the false alarm rate in complex environments such as large dynamic changes, frequent line of sight obstructions, complex lighting conditions, and uneven smoke distribution, thereby ensuring construction site safety.
[0077] In some embodiments, as Figure 2 As shown in the figure, the YOLOv8 improved model is a model improved on the basis of the YOLOv8 model. The improvement process includes:
[0078] (1) Add convolutional layers and residual layers between Layer 8 and Layer 9 in the feature extraction part.
[0079] Adding convolutional layers and residual layers is used to extract deep feature information from the 10*10 feature map, enhance semantic information, reduce background information interference, and meet the feature extraction requirements of larger-scale targets. The feature map is fused through the neck network and then input into the large target detection head, thereby improving the detection scale of the YOLOv8 improved model from three scales to four scales, expanding the scale range of the detection object, enhancing the model's recognition ability and flexibility at various distances and angles, and more complex multi-scale detection of construction site fires in complex scenarios.
[0080] (3) An upsampling layer, a connection layer, and a C2F module are added between Layer 10 and Layer 19 of the feature fusion part, and the detection head is derived from the C2F module.
[0081] Upsampling layers, connection layers, and C2F modules are added to fuse feature maps of newly added scales. A new detection head is derived from C2F to detect large targets. This allows the feature fusion part of the improved YOLOv8 model to work in conjunction with the improvements in the feature extraction part, integrating features from more scales, effectively reducing the missed detection rate of large-scale targets, and improving the reliability of the algorithm.
[0082] (4) The channel attention in the MBConv module is replaced by the ESE module, and the CBS module in the C2F module is replaced by the improved MBConv module to obtain the C2F-MBC module, wherein the improved MBConv module comprises a dimensionality-increasing convolution layer, a depthwise separable convolution layer, an ESE module, a dimensionality-reducing convolution layer, and a Dropout layer.
[0083] like Figure 3 As shown in the figure, the C2F-MBC module can fully consider the channel characteristics of the feature map, improve the input feature channel capacity, reduce the number of model parameters and calculations, and extract key features.
[0084] In some embodiments, see Figure 4 , the dimensionality-raising convolution layer includes 1*1Conv, the first BN and Swish activation functions connected in sequence. Figure 5 The depthwise separable convolutional layer includes sequentially connected k*kConv, the second BN and the Swish activation function, and the dimensionality reduction convolutional layer includes sequentially connected 1*1Conv and the third BN.
[0085] In some embodiments, see Figure 4 ,ESE module is improved based on SE attention module.,ESE module includes average pooling layer, fully connected layer and Sigmoid activation,function connected in sequence, which is used to realize channel feature recalibration and enhance,representation ability.
[0086] It should be noted that the original SE module uses two fully connected layers. The first fully connected layer compresses the number of feature channels, and the second fully connected layer restores them to their original size. Although this strategy reduces computational complexity, it may result in information loss. The ESE module, on the other hand, uses only one fully connected layer that maintains the channel dimension. By avoiding dimensionality reduction, it better preserves the information of the input features.
[0087] In the C2F-MBC module, if Figures 2 to 5As shown in the figure, a dimensionality-raising convolutional layer is first used to perform point-by-point convolution to increase the number of output channels and expand the dimension of the features. Then, a depthwise separable convolutional layer is applied to reduce the number of model parameters while extracting key features. This convolution method can independently apply a convolution kernel to each input channel, and each convolution kernel only performs a convolution operation on the corresponding channel. Because depthwise separable convolution no longer combines features between channels, but focuses on feature extraction within a single channel, it greatly reduces the number of parameters and computational complexity compared to traditional convolution operations. Finally, the ESE module, or channel attention module, is used to enhance the model's ability to process channel feature information. The number of output channels is then reduced through dimensionality-reduced point-by-point convolution. The Dropout layer is introduced to randomly discard a certain proportion of neurons to reduce the complex co-adaptation relationship between neurons, thereby enhancing the model's generalization ability. The output of the Dropout layer is residually connected to the input of this module.
[0088] It should be noted that in traditional convolution, if there is D in input channels and D out output channels, using a K*K convolution kernel, then the number of traditional convolution parameters is D in *D out *K*K. In the depthwise separable convolution layer, the parameter of the depthwise convolution is D in *K*K, the parameter of point-by-point convolution is D in *D out , total D in *(K*K+D out ), which is usually much smaller than traditional convolution, thus reducing the number of model parameters and computational complexity.
[0089] (5) A spatial attention module is added before the SPPF module in the feature extraction part.
[0090] In a complex construction site environment, there are many visual interference elements, such as piles of building materials, mechanical equipment, etc. The introduction of the spatial attention module can help the model distinguish between background noise and actual signs of fire. Figure 2 As shown in the figure, the spatial attention module (CBAM) added before the SPPF module in the feature extraction section improves the YOLOv8 model's sensitivity to spatial location, making it more sensitive to key areas in the image, such as where flames or smoke are concentrated. This attention mechanism weights the input feature map, strengthening the model's ability to identify important spatial locations in the image, allowing the model to more effectively locate the specific location of the fire. This improves the model's fire detection accuracy in complex environments such as those with large dynamic changes, frequent line of sight obstructions, complex lighting conditions, and uneven smoke distribution, reducing false alarm rates.
[0091] In some embodiments, step 102 specifically includes:
[0092] Step 1021: Based on the sample fire dataset and the sample fire annotation dataset, train the YOLOv8 improved model to obtain an intermediate YOLOv8 improved model.
[0093] Step 1022: In response to the performance of the intermediate YOLOv8 improved model meeting the training completion condition, the intermediate YOLOv8 improved model meeting the training completion condition is used as the target fire detection model; in response to the performance of the intermediate YOLOv8 improved model not meeting the training completion condition, the training weights and training parameters of the intermediate YOLOv8 improved model are adjusted until the performance of the intermediate YOLOv8 improved model meets the training completion condition, where the training parameters include one or more parameters of the initial learning rate, the number of training iterations, and hyperparameters.
[0094] In some embodiments, the training completion condition is the accuracy, recall, and mAP of the intermediate YOLOv8 improved model. 50 and mAP 50-95 No rise for 50 consecutive rounds.
[0095] It should be noted that precision (Precision) indicates the proportion of correct results predicted by the model to all predicted results. Recall (Recall) indicates the proportion of correct results predicted by the model to all correct results. mAP 50 、mAP 50-95 They represent the average precision under the 50% IoU threshold and the average precision in the range of 50%-95% IoU threshold, respectively.
[0096] In some embodiments, step 102 may further include the following verification steps: (1) verifying the trained intermediate YOLOv8 improved model based on the sample fire dataset and the validation set in the sample fire annotated dataset to obtain a verification result, thereby ensuring the accuracy of the training result. (2) based on the verification result, improving the loss function of the intermediate YOLOv8 improved model to obtain an improved loss function, thereby ensuring the accuracy of the model fire detection result.
[0097] In some embodiments, the improved loss function is calculated according to the following formula:
[0098]
[0099] L WIOUV1 =R WIOUV L IOU
[0100]
[0101] L WIOUV3 =rL WIOUV1
[0102]
[0103] Among them, L IOU represents the standard intersection-over-union loss function, IOU represents the ratio of the area of the overlapping part of the predicted flame or smoke bounding box and the true bounding box to the area of the true bounding box, W i 、H i denote the width and height of the overlapped part of the predicted flame or smoke bounding box and the ground-truth bounding box, respectively, S u represents the area of the ground-truth bounding box, L WIOUV1 represents the first intermediate improvement loss function, exp represents the exponential function, (x, y) represents the center point coordinates of the predicted flame or smoke bounding box, (x gt ,y gt ) represents the center point coordinate of the real bounding box, W g and H g denote the width and height of the ground-truth bounding box, L WIOUV3 Denotes the improved loss function, δ and α are hyperparameters that can be adjusted to suit different models. β represents the outlier score, which is the ratio of the exponential moving mean to the simple mean of the IoU, and is used to describe the quality of the anchor box. δ represents the attenuation factor used to reduce the impact of the loss function, and α represents the characteristic metric used to adjust the sensitivity of the loss function to specific features. Model performance is optimized by assigning smaller gradient gains to sample anchor boxes with high and low outliers, making the algorithm focus more on learning anchor boxes of average quality.
[0104] The first formula is the calculation formula of the traditional standard intersection-over-union loss function, and the second formula is the calculation formula of the WIoU loss function of the first formula. WIOUV1 is determined by a weighting factor R WIOUV (Calculated by the third formula) multiplied by the standard intersection-over-union loss function. The fourth formula is the improved loss function provided by the embodiment of this application, which is obtained by L WIOUV1 Multiplying by a scaling factor r (calculated by the fourth formula), β can adjust the amplification factor of the loss function scaling ratio, δ can reduce the attenuation factor of the impact of the loss function, and α can adjust the characteristic index of the loss function's sensitivity to specific features.
[0105] The improved loss function optimizes model performance by assigning different gradient gains to samples with different outlier scores. Specifically, it assigns lower gradient gains to samples with lower outlier scores (higher quality), allowing the loss function to focus more on anchor boxes of medium quality. Furthermore, it assigns lower gradient gains to samples with higher outlier scores, thereby reducing the potential negative impact of low-quality samples. This mechanism helps the model more effectively focus resources on key samples, thereby improving overall detection effectiveness.
[0106] In some embodiments, the training weights of the yolov8s.pt file in the MS COCO dataset are introduced as pre-training weights, the YOLOv8 model is used to train the self-made dataset, and the best model parameters after training are used as pre-training weights for subsequent improved models.
[0107] In some embodiments, the optimal model weight file best.pt generated during the training of the improved YOLOv8 model is retained. The optimal parameters of the YOLOv8 model trained on the dataset are used as pre-trained weights for training the improved model. By loading the pre-trained weights, the improved YOLOv8 model can begin training under reasonable parameters, thereby accelerating model convergence and reducing training time. After training is completed, the optimal model weight file best.pt generated during the training of the improved YOLOv8 model is retained.
[0108] In some embodiments, the parameter value of patience for early stopping can be set to 50. After 50 rounds of training, if the improved YOLOv8 model does not obtain better performance results, training is stopped.
[0109] like Figure 6(a) to Figure 6(b) As shown in Table 1, the performance indicators of the target fire detection model (YOLO-Fire in the figure) obtained by the model training method provided by the embodiment of the present application are compared with the YOLOv8 model (YOLOv8-s in the figure). The comparison results are as follows: the target fire detection model has an accuracy improvement of 2.4%, a recall rate improvement of 3.5%, and a mAP improvement of 1.0%. 50 Improved mAP by 2.6% 50-95 All four important performance indicators have been improved, indicating that the target fire detection model obtained by the model training method provided in the embodiment of the present application has indeed improved the performance of the model in construction site fire scenarios.
[0110] Table 1 Performance comparison of target fire detection model and YOLOv8 model
[0111]
[0112]
[0113] In summary, the model training method provided in the embodiment of the present application improves the accuracy of fire detection and reduces the false alarm rate in complex environments such as large dynamic changes, frequent visual obstructions, complex lighting conditions, and uneven smoke distribution, thereby ensuring construction site safety.
[0114] In a second aspect, the present application provides a fire detection method, the method comprising:
[0115] Obtaining a target fire detection model in the model training method of the first aspect;
[0116] Input the fire data set to be tested into the target fire detection model to obtain the fire detection results. Figure 7 ,The fire detection results include target category, target bounding box location, ,confidence and category probability, and the target categories include flame and smoke.
[0117] In summary, the fire detection method provided in the embodiments of the present application improves the accuracy of fire detection and reduces the false alarm rate in complex environments such as large dynamic changes, frequent line of sight obstructions, complex lighting conditions, and uneven smoke distribution, thereby ensuring construction site safety.
[0118] In this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The term "plurality" refers to two or more than two, unless expressly limited otherwise.
[0119] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the present invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only.
[0120] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. Model training method, It is characterized in that The method comprises: Obtain a sample fire data set, a sample fire annotation data set, and a YOLOv8 improved model, wherein the YOLOv8 improved model includes a convolutional layer and a residual layer added between Layer8 and Layer9 of the feature extraction part, a C2F-MBC module, and a spatial attention module added before the SPPF module of the feature extraction part; Based on the sample fire data set and the sample fire annotation data set, the YOLOv8 improved model is trained to obtain a target fire detection model.
2. The model training method according to claim 1, It is characterized in that The method of training the YOLOv8 improved model based on the sample fire data set and the sample fire annotated data set to obtain a target fire detection model includes: Based on the sample fire data set and the sample fire annotation data set, training a YOLOv8 improved model to obtain an intermediate YOLOv8 improved model; In response to the performance of the intermediate YOLOv8 improved model satisfying the training completion condition, the intermediate YOLOv8 improved model satisfying the training completion condition is used as the target fire detection model; in response to the performance of the intermediate YOLOv8 improved model not satisfying the training completion condition, the training weights and training parameters of the intermediate YOLOv8 improved model are adjusted until the performance of the intermediate YOLOv8 improved model satisfies the training completion condition, and the training parameters include one or more parameters of the initial learning rate, the number of training iterations and the hyperparameters.
3. The model training method according to claim 1, It is characterized in that The YOLOv8 improved model is a model improved on the basis of the YOLOv8 model, and the improvement process includes: Add convolutional layers and residual layers between Layer 8 and Layer 9 in the feature extraction part; Add an upsampling layer, a connection layer, and a C2F module between Layer 10 and Layer 19 of the feature fusion part, and derive the detection head from the C2F module; The channel attention in the MBConv module is replaced by the ESE module, and the CBS module in the C2F module is replaced by the improved MBConv module to obtain the C2F-MBC module, wherein the improved MBConv module includes a dimensionality increase convolution layer, a depthwise separable convolution layer, an ESE module, a dimensionality reduction convolution layer, and a Dropout layer; The spatial attention module is added before the SPPF module in the feature extraction part.
4. The model training method according to claim 2, It is characterized in that The training completion conditions are the accuracy, recall rate, and mAP of the intermediate YOLOv8 improved model. 50 and mAP 50-95 No rise for 50 consecutive rounds.
5. The model training method according to claim 2, It is characterized in that The training of the YOLOv8 improved model based on the sample fire data set and the sample fire annotated data set to obtain a target fire detection model further includes: Verifying the trained intermediate YOLOv8 improved model based on the sample fire data set and the verification set in the sample fire annotation data set to obtain a verification result; Based on the verification result, the loss function of the intermediate YOLOv8 improved model is improved to obtain an improved loss function.
6. The model training method according to claim 5, It is characterized in that According to the following formula, the improved loss function is calculated: L WIOUV1 =R WIOUV L IOU L WIOUV3 =rL WIOUV1 Among them, L IOU represents the standard intersection-over-union loss function, IOU represents the ratio of the area of the overlap between the predicted flame or smoke bounding box and the true bounding box to the area of the true bounding box, W i , H i denotes the width and height of the overlapped part of the predicted flame or smoke bounding box and the true bounding box, respectively, and S u represents the area of the true bounding box, L WIOUV1 represents the first intermediate improvement loss function, exp represents the exponential function, (x, y) represents the center point coordinates of the predicted flame or smoke bounding box, (x gt ,y gt ) represents the center point coordinates of the real bounding box, W g and H g Represent the width and height of the real bounding box, L WIOUV3 represents the improved loss function, β represents the outlier degree, which is the ratio of the exponential moving mean of IoU to the simple mean, which is used to describe the quality of the anchor box, δ represents the attenuation factor used to reduce the impact of the loss function, and α represents the characteristic indicator used to adjust the sensitivity of the loss function to specific features.
7. The model training method according to claim 3, It is characterized in that The dimension-increasing convolution layer includes 1*1Conv, the first BN and the Swish activation function connected in sequence, the depth-separable convolution layer includes k*kConv, the second BN and the Swish activation function connected in sequence, and the dimension-reducing convolution layer includes 1*1Conv and the third BN connected in sequence.
8. The model training method according to claim 3 or 7, It is characterized in that The ESE module is improved based on the SE attention module, including an average pooling layer, a fully connected layer that keeps the number of channels unchanged, and a Sigmoid activation function.
9. A model training method according to any one of claims 1 to 8, It is characterized in that The obtaining of the sample fire data set and the sample fire annotation data set comprises: Acquire an original fire data set, wherein the original fire data set is pictures of construction site and building fire scenes; Performing data cleaning on the original fire data set to obtain a first cleaned data set; Encoding the cleaned data set according to a hash method to obtain a digital fingerprint corresponding to the cleaned data set; Deduplication processing is performed on the images in the cleaned data set with the same digital fingerprint to obtain a second cleaned data set; Deduplication processing is performed on the images containing repeated features in the second cleaned data set to obtain a sample fire data set; The flames and smoke in the sample fire dataset are labeled, and the label format of the label is converted from JSON format to a format supported by YOLO to obtain a sample fire label dataset, wherein each label includes a target category, a center point coordinate of a labeled bounding box, and a width of the labeled bounding box.
10. Fire detection methods, It is characterized in that The method comprises: Obtaining a target fire detection model in the model training method as described in any one of claims 1 to 9; The fire data set to be tested is input into the target fire detection model to obtain a fire detection result, which includes a target category, a target bounding box position, a confidence level and a category probability, and the target category includes flame and smoke.
Citation Information
Cited By
Intelligent edge calculation method for fire target detection
CN119478382A
Flame smoke detection method and system based on improved YOLOv8s
CN120997967A
