An infrared imaging gas leakage detection method based on YOLOV8
By improving the YOLOv8 model, using StarBlock and CAA to improve the C2f module, and combining HS-FPN and Vibe algorithms, the problems of inaccurate multi-scale target detection and lack of temporal information in YOLOv8 were solved, and efficient, real-time gas leak detection was achieved in complex pipeline backgrounds.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HEFEI UNIV OF TECH
- Filing Date
- 2024-08-28
- Publication Date
- 2026-07-14
AI Technical Summary
The existing YOLOv8 model is not accurate enough in multi-scale target detection, and the lack of temporal information between video frames leads to a high false alarm rate, making it difficult to perform accurate and real-time gas leak detection in complex industrial pipeline backgrounds.
By improving the YOLOv8 model, using StarBlock and CAA to improve the C2f module, replacing the SFPN network with HS-FPN, and combining it with the Vibe algorithm, a SCH-YOLO model is constructed for infrared gas leak detection.
It improves the ability to extract multi-scale features, reduces the false alarm rate, and achieves efficient, real-time gas leak detection in complex scenarios.
Smart Images

Figure CN119169305B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology in special scenarios, specifically to an infrared imaging gas leak detection method based on an improved YOLOv8 model. Background Technology
[0002] Leaked gases in the petrochemical industry mainly consist of volatile organic compounds (VOCs) such as alkanes, alkenes, and cyclic hydrocarbons. These not only harm human health but also cause air pollution and can even trigger major safety accidents such as fires and explosions. Gas leak detection can promptly identify leak points and reduce the likelihood of these accidents. Therefore, how to quickly and accurately detect gas leaks is a current research focus.
[0003] Cooled infrared thermal imagers can effectively identify VOCs gases, and can be mounted on mobile robots to replace manual inspections in industrial parks. Compared to traditional gas sensors for leak detection, infrared thermal imaging-based gas leak detection offers advantages such as fast response, long range, wide coverage, and dynamic visualization. Compared to traditional infrared gas identification algorithms, deep learning methods automatically extract features through end-to-end learning, capturing the contextual relationships between targets to improve detection accuracy. Furthermore, hardware acceleration using GPUs and other methods achieves real-time performance, enabling accurate and rapid detection and location of leak sources for early warning.
[0004] YOLO (You Only Look Once) is a mainstream object detection algorithm in deep learning, balancing detection accuracy and time. YOLOv8 uses a C2f module with richer gradient flow and employs an anchor-free method in its head, making it more suitable for detecting irregularly changing gas leaks. However, YOLOv8 still has the following drawbacks: 1) Inaccurate multi-scale object detection; 2) High false alarm rate due to lack of temporal information between video frames.
[0005] To address this, an infrared imaging gas leak detection method based on an improved YOLOv8 model is proposed. Summary of the Invention
[0006] The purpose of this invention is to provide infrared imaging gas leak detection based on an improved YOLOv8 model, thereby solving the problem of accurate and real-time detection of leaking gas in complex industrial pipeline environments. To achieve the above objective, the technical solution adopted by this invention is as follows:
[0007] A YOLO-based infrared imaging gas leak detection method includes the following steps:
[0008] S1: Dataset Construction: Based on the public dataset GasVid, images with more diverse gas cloud shapes and richer pipe scenes were obtained through simulated scene shooting and image fusion, resulting in a dataset consisting of 4873 infrared gas images.
[0009] S2: Establish and improve the YOLOv8 neural network model:
[0010] Build a YOLOv8 neural network model, configure the required environment, and adjust the corresponding parameters of the model;
[0011] Improve the YOLOv8 neural network model to enhance its ability to extract multi-scale features:
[0012] The C2f module was improved using StarBlock and CAA (Context Anchor Attention), the original SFPN network was replaced with HS-FPN (Hierarchical Scale-based Feature Pyramid Network), and the improved YOLOv8 model was named SCH-YOLO.
[0013] S3: Train the SCH-YOLO network model on the dataset constructed in S1:
[0014] The constructed dataset is input into the SCH-YOLO network model and trained to obtain the weight file best.pt that has the best effect on infrared gas leak identification.
[0015] S4: Overall algorithm for infrared gas target recognition:
[0016] The SCH-YOLO model outputs the target prediction bounding box and confidence score for a single frame image, while the Vibe algorithm outputs the foreground pixel distribution for the same frame. Combining these two methods, infrared gas target recognition is performed by determining the proportion of foreground pixels within the prediction bounding box according to a threshold. This reduces the false alarm rate and enables more accurate detection of gas leaks in infrared scenes.
[0017] Step S1 specifically includes the following steps:
[0018] S11: The dataset GasVid is a dataset for target detection of methane gas leaks captured under infrared thermal imaging. GasVid captured images of different scenarios with a leak flow rate range of 5.3-2051.6 gCH4 / h and a distance of 4.6-15.6 m, and collected a total of 31 videos.
[0019] The IOD dataset is an infrared gas dataset consisting of 600 videos;
[0020] S12: Search for authentic videos taken by humans during factory inspections using infrared thermal imagers;
[0021] S13: Independently build a pipeline model to simulate a real pipeline gas leak and take photos. Methane and propane are used as leaking gases. The shooting scheme includes: different distances of 1M, 3M, 7M, and 10M, different lighting conditions, different shooting angles, and pedestrian interference.
[0022] S14: Use the CycleGAN network to transfer the style of the visible light pipeline scene to generate an infrared pipeline scene, and use OpenCV to fuse the real air mass with the infrared scene to obtain the final image;
[0023] S15: The video was cropped into video frames, and a dataset consisting of 4873 infrared VOCs gas leakage images was finally obtained. The dataset was divided into training and testing sets in an 8:2 ratio.
[0024] Step S2 specifically includes the following steps:
[0025] Build a YOLOv8 neural network model, configure the required environment, and adjust the corresponding parameters of the model;
[0026] The YOLOv8 neural network model was improved by using StarBlock and CAA to improve the C2f module, replacing the original SFPN network with HS-FPN, and naming the improved YOLOv8 model SCH-YOLO, as follows:
[0027] S21: Improve the Bottleneck part in C2f using StarBlock from StarNet, and enhance the concatenated features using CAA from PKINet.
[0028] S22: StarBlock is used for multi-scale feature extraction:
[0029] StarBlock extracts features by replacing the original bottleneck layer convolution with parallel convolution kernels of different scales: 3x3, 5x5, and 7x7.
[0030] Multi-scale convolution:
[0031] Y1 = Conv 3×3 (X),Y2=Conv 5×5 (X),Y3=Conv 7×7 (X)
[0032] Conv 3×3 (),Conv 5×5 (),Conv 7×7 () represent 3x3, 5x5, and 7x7 convolutions respectively;
[0033] Fusing convolution results at different scales:
[0034] X star =Concat(Y1,Y2,Y3)
[0035] Concat() represents concat feature fusion;
[0036] S23: Feature enhancement portion after CAA improved stitching:
[0037] The CAA module further improves the C2f module by capturing long-range dependencies. It uses global average pooling and one-dimensional bar convolution to capture relationships between distant pixels and enhance features in the central region.
[0038] Global average pooling:
[0039] X global =GlobalAveragePooling(X concat )
[0040] GlobalAveragePooling() represents global average pooling;
[0041] One-dimensional strip convolution:
[0042] X strip =Conv 1×k (X global )+Conv k×1 (X global )
[0043] Conv 1×k (),Conv k×1 () denote one-dimensional strip convolutions in the depth and width directions, respectively;
[0044] The CAA module uses an attention mechanism to dynamically adjust important information in the feature map, enhancing the feature representation of key regions:
[0045] X attn =σ(Conv 1×1 (X strip ))⊙X star +X star
[0046] σ represents the Sigmoid activation function, and ⊙ represents element-wise multiplication;
[0047] S24: The HS-FPN network principle consists of two parts: a feature selection module and a feature fusion module.
[0048] S25: Feature Selection Module:
[0049] The feature selection module uses channel attention (CA) and dimension matching (DM) mechanisms to filter feature maps at different scales, dividing them into low-level features and high-level features. Through pooling operations and weight calculations, it extracts important information from each channel.
[0050] S26: Feature Fusion Module:
[0051] The feature fusion module combines the selected low-level features and high-level features through the Selective Feature Fusion (SFF) mechanism. After the high-level features are expanded, they are scaled by bilinear interpolation and transposed convolution, and then fused with the low-level features to enhance the model's ability to express features.
[0052] S27: Selective feature fusion is the fusion of feature maps at different scales, and the process is as follows:
[0053] Given an input high-level feature:
[0054] X high ⊙R C*H*W
[0055] C represents the number of channels in the feature map, H represents the height of the feature map, and W represents the width of the feature map;
[0056] One input low-scale feature:
[0057]
[0058] W1 represents the width of the low-scale feature map;
[0059] The high-level features are first expanded using a transposed convolution T-Conv with a size of 2 and a kernel size of 3x3 to obtain the feature size:
[0060] X high ∈R C*2H*2W
[0061] To unify the dimensionality of high-level and low-scale features, bilinear interpolation is used to upsample or downsample high-level features, resulting in the following features:
[0062]
[0063] H1 represents the height of the low-scale feature map;
[0064] The CA module is used to convert high-level features into corresponding attention weights to filter low-scale features. The filtered low-scale features are then fused with the high-level features to enhance the model's feature representation.
[0065]
[0066] Equations (1) and (2) illustrate the fusion process of feature selection:
[0067] X att =BL(T-Conv(X) high )) (1)
[0068] X att =X low *CA(X att )+X att (2)
[0069] S3 specifically includes:
[0070] The SCH-YOLO model was trained for 200 epochs on the training set to obtain the trained weight file best.pt.
[0071] S4 specifically includes:
[0072] S41: Vibe foreground extraction algorithm:
[0073] The background model is established by selecting a background sample set of pixels from the first frame image. The foreground pixels are determined by calculating the Euclidean distance between the pixels of the next frame image and each pixel in the sample set. The background sample model is updated using a random strategy.
[0074] S411: First, establish background samples. In the first frame image, randomly select N pixels from the S*S neighborhood of each pixel as the background sample set for that pixel.
[0075] S412: Based on the background samples, perform foreground pixel detection, calculate the Euclidean distance between the pixel of the next frame image and each pixel in the sample set. If it is less than the radius R, it is an approximate sample point. If the number of approximate sample points in the sample set is greater than the threshold P, then this pixel point is classified as a background pixel point; otherwise, it is a foreground pixel point.
[0076] Let P = 2, and R be the adaptive threshold, whose formula is:
[0077] R(x) is the radius threshold of the newly read pixel; R′(x) is the radius threshold of the previous pixel; S2(x) is the variance of the newly read pixel and the pixels in the sample set; θ is a measurement factor. When the variance is greater than the measurement factor, it means that the scene has changed significantly, so increase the R threshold; otherwise, decrease the R threshold.
[0078] S413: The background model will be updated accordingly as the scene changes. The background may change in the next video frame, so the sample set needs to be updated continuously. Each background pixel has a probability of 1 / σ to update its own sample set, where σ is the update factor.
[0079] S42: The SCH-YOLO model and the Vibe algorithm are executed in parallel. A single frame image is processed by the SCH-YOLO model based on step S3, and the output of the judgment on the single frame image includes the predicted box and confidence score.
[0080] S43: At the same time, the Vibe algorithm obtains the foreground pixel distribution of the same single frame image through step S41.
[0081] S44: Make a judgment based on the predicted bounding box, confidence level, and foreground pixel distribution;
[0082] If the confidence level of a single frame image is >0.4, it is identified as gas;
[0083] If the confidence level of a single frame image is ≤0.4 and the proportion of foreground pixels in the predicted bounding box is >0.35, then it is identified as gas;
[0084] If the confidence level of a single frame image is ≤0.4 and the proportion of foreground pixels in the prediction box is ≤0.35, it is considered a misidentification.
[0085] The final algorithm combines time-series information to reduce the false alarm rate and more accurately detect infrared gas leaks.
[0086] This invention proposes an infrared imaging gas leak detection method based on an improved YOLOv8 model. The method improves YOLOv8 by using StarBlock and CAA to improve C2f and HS-FPN to replace the SFPN network. Then, it is combined with Vibe for leak detection, which ensures high efficiency and real-time detection.
[0087] The advantages of this invention are:
[0088] 1) To address the need for global feature capture, StarBlock was used to improve the Bottleneck part, performing multi-scale convolution and feature fusion to enhance the ability to extract multi-scale features. CAA feature enhancement was also performed, making the global feature capture capability even more outstanding.
[0089] 2) For multi-level feature fusion in complex scenarios, this invention uses HS-FPN instead of the original SFPN network, dividing feature selection into high-level and low-level features, effectively filtering out irrelevant or redundant features. Furthermore, the SFF mechanism is used for fusion, with features from different levels complementing each other. This further enhances the multi-scale feature extraction capability.
[0090] 3) To address the issue that SCH-YOLO detects targets based on video frames, lacking temporal information between frames, this invention combines SCH-YOLO with the Vibe algorithm. SCH-YOLO can detect targets in a single frame with high accuracy, while Vibe can detect moving targets. Feeding the single-frame recognition results output by SCH-YOLO to Vibe to determine motion attributes reduces the false alarm rate of SCH-YOLO. Simultaneously, Vibe consumes very little memory and computing power, ensuring real-time detection while enhancing the robustness of the entire algorithm. Attached Figure Description
[0091] Figure 1 This is the overall process of the present invention;
[0092] Figure 2 This is the dataset for the present invention;
[0093] Figure 3 This invention is SCH-YOLO;
[0094] Figure 4 This is the overall algorithm flow of the present invention. Detailed Implementation
[0095] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0096] like Figure 1 As shown, this embodiment of the invention provides an infrared imaging gas leak detection method based on an improved YOLOv8 model, comprising the following steps:
[0097] S1: Since the publicly available datasets GasVid and IOD mainly consist of VOCs gas leak videos with simple backgrounds and cannot realistically reflect the complex pipeline scenarios in factories, we expanded the images based on the publicly available datasets using methods such as simulation experiments to obtain a dataset consisting of 4873 infrared gas leak images, such as... Figure 2 As shown;
[0098] S11: For the publicly available datasets GasVid and IOD in S1;
[0099] In 2019, Jingfan Wang, Lyne P. Tchapmi, Arvind P. Ravikumar, and others published a paper in the journal Applied Energy titled "Machine vision for natural gas methane emissions detection using an infrared camera," and released their dataset, GasVid. This dataset is specifically designed for target detection of methane gas leaks using infrared thermal imaging. GasVid captured images of leaks with flow rates ranging from 5.3 to 2051.6 g CH4 / h and distances from 4.6 to 15.6 m in different scenarios, collecting a total of 31 videos.
[0100] In 2022, Kailai Zhou, Yibo Wang, Tao Lv, and others published the paper "Explore Spatio-temporal Aggregation for Insubstantial Object Detection: Benchmark Dataset and Baseline" in the journal Computer Vision and Pattern Recognition, and released their dataset IOD. This dataset is an infrared gas dataset consisting of 600 videos, covering various distances, sizes, visibility, and spectral ranges of different shooting scenes;
[0101] S12: Search for real videos taken by humans using infrared thermal imagers to conduct factory inspections through the internet and manufacturer promotional videos;
[0102] S13: Independently build a pipeline model to simulate a real pipeline gas leak and conduct independent filming. Methane and propane are used as the leaking gases. The design scheme includes: different distances of 1M, 3M, 7M, and 10M, different lighting conditions, different shooting angles, and interference from pedestrians, etc.
[0103] S14: To enrich scene diversity, a CycleGAN network was used to transfer the style of the visible light pipeline scene to generate an infrared pipeline scene. OpenCV was then used to fuse the realistic air mass with the infrared scene to obtain the final image.
[0104] S15: The video was cropped into video frames, resulting in a dataset consisting of 4873 infrared VOCs gas leakage images. The dataset was then divided into training and testing sets in an 8:2 ratio.
[0105] S2: Due to the insufficient multi-scale feature extraction capability of YOLOv8, StarBlock and CAA were used to improve the C2f module, and HS-FPN was used to replace the original SFPN network to enhance the multi-scale feature extraction capability of YOLOv8. The improved model was named SCH-YOLO, and its network structure is as follows. Figure 3 As shown.
[0106] S21: C2f can retain more feature information while reducing computational cost. However, C2f's feature representation is not rich enough, and its ability to capture global contextual information is still insufficient. We improve the Bottleneck part of C2f using StarBlock from StarNet and enhance the concatenated features using CAA from PKINet. This enhances the ability to extract multi-scale features and capture global contextual information.
[0107] S22: StarBlock is used for multi-scale feature extraction:
[0108] StarBlock extracts features by replacing the original bottleneck convolutional layer with parallel convolutional kernels of different scales (3x3, 5x5, 7x7), thereby enhancing the model's ability to recognize targets of different sizes. This makes it not only reliant on local convolutions but also introduces larger convolutional kernels, improving its ability to extract multi-scale features.
[0109] Multi-scale convolution:
[0110] Y1 = Conv 3×3 (X),Y2=Conv 5×5 (X),Y3=Conv 7×7 (X)
[0111] By fusing convolution results at different scales, the expressive power and richness of features can be improved.
[0112] X star =Concat(Y1,Y2,Y3)
[0113] S23: Feature enhancement portion after CAA improved stitching:
[0114] The CAA module further improves upon the C2f module by capturing long-range dependencies. It uses global average pooling and one-dimensional bar convolution to capture relationships between distant pixels and enhance features in the central region. This design effectively complements C2f's shortcomings in capturing global information.
[0115] Global average pooling:
[0116] X global =GlobalAveragePooling(X concat)
[0117] One-dimensional strip convolution:
[0118] X strip =Conv 1×k (X global )+Conv k×1 (X global )
[0119] The CAA module uses an attention mechanism to dynamically adjust important information in the feature map, enhancing the feature representation of key regions:
[0120] X attn =σ(Conv 1×1 (X strip ))⊙X star +X star
[0121] S24: Because HS-FPN uses advanced feature selection and multi-level feature fusion, it is more accurate and efficient in feature extraction and fusion in complex backgrounds. Therefore, HS-FPN replaces the original SFPN network to improve recognition accuracy in complex scenes. The HS-FPN network principle consists of two parts: a feature selection module and a feature fusion module.
[0122] S25: Feature Selection Module:
[0123] This module utilizes channel attention (CA) and dimension matching (DM) mechanisms to filter feature maps at different scales, categorizing them into low-level and high-level features. Through pooling operations and weight calculations, it extracts important information from each channel.
[0124] S26: Feature Fusion Module:
[0125] This module combines selected low-level and high-level features through a selective feature fusion mechanism. After expansion, the high-level features are scaled using bilinear interpolation and transposed convolution, and then fused with the low-level features, thereby enhancing the model's ability to express features.
[0126] S27: SFF is a key component in the HS-FPN network. Its main function is to fuse feature maps of different scales. The process is as follows:
[0127] Given an input high-level feature:
[0128] X high ∈R C*H*W
[0129] One input low-scale feature:
[0130]
[0131] The high-level features are first expanded using a transposed convolution (T-Conv) with a size of 2 and a kernel size of 3x3 to obtain the feature size:
[0132] X high ∈R C*2H*2W
[0133] To unify the dimensionality of high-level and low-scale features, bilinear interpolation is used to upsample or downsample high-level features, resulting in the following features:
[0134]
[0135] The CA module is used to convert high-level features into corresponding attention weights to filter low-scale features. The filtered low-scale features are then fused with the high-level features to enhance the model's feature representation.
[0136]
[0137] Equations (1) and (2) illustrate the fusion process of feature selection:
[0138] X att =BL(T-Conv(X) high )) (1)
[0139] X att =X low *CA(X att )+X att (2)
[0140] S3: Train the SCH-YOLO model on the training set for 200 rounds to obtain the trained weight file best.pt;
[0141] The recognition model was tested and evaluated using metrics such as accuracy, recall, and mAP@0.5.
[0142] Accuracy refers to the proportion of detected targets that truly belong to their respective categories. It is the ratio of the amount of correctly classified data in the test set to the total amount of data in the test set. The following is the formula for calculating accuracy:
[0143]
[0144] Recall is the probability that a sample that was actually positive will be predicted as positive. The following is the formula for calculating recall:
[0145]
[0146] AP is the area under the precision-recall curve. The average AP across all categories is used to obtain mAP.
[0147] S4: Since SCH-YOLO only performs target recognition based on a single video frame and lacks temporal information between video frames, and because methods such as 3DCNN significantly increase the number of parameters and computational requirements, a parallel approach combined with Vibe is adopted. The algorithm flow is as follows: Figure 4 By combining SCH-YOLO and Vibe, the accuracy of SCH-YOLO is maintained while adding time-series information to reduce the false alarm rate.
[0148] S41: Vibe can perform dynamic foreground extraction, identifying foreground pixels with motion attributes. It is more robust than inter-frame difference methods and simpler in complexity than optical flow methods.
[0149] S41 specifically includes:
[0150] S411: First, establish background samples. Randomly select N pixels from the S*S neighborhood of each pixel in the first frame image as the background sample set for that pixel.
[0151] S412: Foreground pixel detection is performed based on the background samples. Calculate the Euclidean distance between the pixel in the next frame and each pixel in the sample set. If the distance is less than the radius R, it is an approximate sample point. If the number of approximate sample points in the sample set is greater than the threshold P, the pixel is classified as a background pixel; otherwise, it is a foreground pixel.
[0152] Let P = 2, and R be the adaptive threshold, whose formula is:
[0153] R(x) is the radius threshold for the newly read pixel; R′(x) is the radius threshold for the previous pixel; S2(x) is the variance between the newly read pixel and the pixels in the sample set; θ is a measurement factor, set to θ = 2. When the variance is greater than the measurement factor, it indicates that the scene has changed significantly, so the R threshold is increased; otherwise, the R threshold is decreased.
[0154] S413: The background model will be updated accordingly as the scene changes. The background may change in the next video frame, requiring continuous updates to the sample set. Each background pixel has a probability of 1 / σ to update its own sample set. σ is the update factor, taken as σ = 16;
[0155] S42: The SCH-YOLO and Vibe algorithms are executed in parallel. A single frame image is processed by the SCH-YOLO model based on S3, and the output of the judgment of the single frame image includes the predicted box and confidence score.
[0156] S43: At the same time, the Vibe algorithm obtains the foreground pixel distribution of the same single frame image through S41;
[0157] S44: Make a judgment based on the predicted bounding box, confidence level, and foreground pixel distribution;
[0158] If the confidence level of a single frame image is >0.4, it is identified as gas;
[0159] If the confidence level of a single frame image is ≤0.4 and the proportion of foreground pixels in the predicted bounding box is >0.35, then it is identified as gas;
[0160] If the confidence level of a single frame image is ≤0.4 and the proportion of foreground pixels in the prediction box is ≤0.35, it is considered a misidentification.
[0161] The infrared imaging gas leak detection method proposed in this invention improves YOLOv8 by using StarBlock and CAA to improve the C2f module and replacing the original SFPN network with HS-FPN to obtain SCH-YOLO. SCH-YOLO is combined with the Vibe algorithm for parallel computation and judgment to solve the problem of missing temporal information between video frames, thereby reducing the false alarm rate of the algorithm.
[0162] The preferred embodiments of the present invention have been described in detail above with reference to the accompanying drawings. These embodiments are merely descriptions of preferred embodiments and are not intended to limit the scope or concept of the invention. The specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. Such combinations, as long as they do not violate the spirit of the present invention, should also be considered as part of this disclosure. To avoid unnecessary repetition, the present invention will not further describe the various possible combinations.
[0163] This invention is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this invention and without departing from the design idea of this invention, all modifications and improvements made by those skilled in the art to the technical solutions of this invention should fall within the protection scope of this invention. The technical content for which protection is sought in this invention has been fully described in the claims.
Claims
1. A gas leak detection method based on YOLOv8 infrared imaging, characterized in that, Specifically, the following steps are included: S1: Dataset Construction: Based on the public datasets GasVid and IOD, a dataset consisting of 4873 infrared gas images was obtained through simulated scene shooting and image fusion. S2: Establish and improve the neural network model of YOLOv8, and name the improved YOLOv8 model SCH-YOLO; The improved YOLOv8 neural network model uses StarBlock and CAA to improve the C2f module, uses HS-FPN to replace the original SFPN network, and names the improved YOLOv8 model SCH-YOLO. S3: Train the SCH-YOLO network model on the dataset constructed in step S1: The constructed dataset is input into the SCH-YOLO network model and trained to obtain the weight file best.pt, which can identify infrared gas leaks. S4: Overall algorithm for infrared gas target recognition: The SCH-YOLO model outputs the target prediction box and confidence score of a single frame image, while the Vibe algorithm outputs the foreground pixel distribution of a single frame image. The two are combined, and infrared gas target recognition is performed by judging the threshold of the proportion of foreground pixels in the prediction box. Step S4 specifically includes the following steps: S41: The Vibe algorithm is used for dynamic foreground extraction to extract foreground pixels with motion attributes. S42: The SCH-YOLO model and the Vibe algorithm are executed in parallel. A single frame image is processed by the SCH-YOLO model based on step S3, and the output of the judgment on the single frame image includes the predicted box and confidence score. S43: At the same time, the Vibe algorithm obtains the foreground pixel distribution of the same single frame image through step S41. S44: Make a judgment based on the predicted bounding box, confidence level, and foreground pixel distribution; If the confidence level of a single frame image is >0.4, it is identified as gas; If the confidence level of a single frame image is ≤0.4 and the proportion of foreground pixels in the predicted bounding box is >0.35, then it is identified as gas; If the confidence level of a single frame image is ≤0.4 and the proportion of foreground pixels in the prediction box is ≤0.35, it is considered a misidentification.
2. The method for detecting gas leaks using infrared imaging based on YOLOv8 according to claim 1, characterized in that, Step S1 specifically includes the following steps: S11: The dataset GasVid is a dataset for target detection of methane gas leaks captured by infrared thermal imaging. GasVid captured images of different scenarios with a leak flow rate range of 5.3-2051.6 gCH4 / h and a distance of 4.6-15.6 m, and collected a total of 31 videos. The IOD dataset is an infrared gas dataset consisting of 600 videos; S12: Search for authentic videos taken by humans during factory inspections using infrared thermal imagers; S13: Independently build a pipeline model to simulate a real pipeline gas leak and take photos. Methane and propane are used as leaking gases. The shooting scheme includes: different distances of 1M, 3M, 7M, and 10M, different lighting conditions, different shooting angles, and pedestrian interference. S14: Use the CycleGAN network to transfer the style of the visible light pipeline scene to generate an infrared pipeline scene, and use OpenCV to fuse the real air mass with the infrared scene to obtain the final image; S15: The video was cropped into video frames, and a dataset consisting of 4873 infrared VOCs gas leakage images was finally obtained. The dataset was divided into training and testing sets in an 8:2 ratio.
3. The infrared imaging gas leak detection method based on YOLOv8 according to claim 1, characterized in that, Step S2 specifically includes the following steps: Build a YOLOv8 neural network model, configure the required environment, and adjust the corresponding parameters of the model; S21: Improve the Bottleneck part in C2f using StarBlock from StarNet, and improve the feature enhancement after splicing using CAA from PKINet network; S22: StarBlock is used for multi-scale feature extraction: StarBlock extracts features by replacing the original bottleneck layer convolution with parallel convolution kernels of different scales: 3x3, 5x5, and 7x7. Multi-scale convolution: , , , These represent 3x3, 5x5, and 7x7 convolutions, respectively. Fusing convolution results at different scales: ; express Feature fusion; S23: Feature enhancement portion after CAA improved stitching: The CAA module further improves the C2f module by capturing long-range dependencies. It uses global average pooling and one-dimensional bar convolution to capture relationships between distant pixels and enhance features in the central region. Global average pooling: , Indicates global average pooling; One-dimensional strip convolution: , , These represent one-dimensional strip convolutions in the depth and width directions, respectively. The CAA module uses an attention mechanism to dynamically adjust important information in the feature map, enhancing the feature representation of key regions: , This represents the Sigmoid activation function. This indicates element-wise multiplication; S24: The HS-FPN network principle consists of two parts: a feature selection module and a feature fusion module. S25: Feature Selection Module: The feature selection module uses channel attention (CA) and dimension matching (DM) mechanisms to filter feature maps at different scales, dividing them into low-level features and high-level features. Through pooling operations and weight calculations, it extracts important information from each channel. S26: Feature Fusion Module: The feature fusion module combines the selected low-level features and high-level features through the Selective Feature Fusion (SFF) mechanism. After the high-level features are expanded, they are scaled by bilinear interpolation and transposed convolution, and then fused with the low-level features to enhance the model's ability to express features. S27: Selective feature fusion is the fusion of feature maps at different scales, and the process is as follows: Given an input high-level feature: , C represents the number of channels in the feature map, H represents the height of the feature map, and W represents the width of the feature map; One input low-scale feature: , W1 represents the width of the low-scale feature map; The high-level features are first expanded using a transposed convolution T-Conv with a size of 2 and a kernel size of 3x3 to obtain the feature size: , To unify the dimensionality of high-level and low-scale features, bilinear interpolation is used to upsample or downsample high-level features, resulting in the following features: , H1 represents the height of the low-scale feature map; The CA module is used to convert high-level features into corresponding attention weights to filter low-scale features. The filtered low-scale features are then fused with the high-level features to enhance the model's feature representation. , Equations (1) and (2) illustrate the feature selection fusion process: (1), (2)。 4. The infrared imaging gas leak detection method based on YOLOv8 according to claim 1, characterized in that, Step S3 specifically includes the following steps: The SCH-YOLO model was trained for 200 epochs on the training set to obtain the trained weight file best.pt.
5. The infrared imaging gas leak detection method based on YOLOv8 according to claim 1, characterized in that, Step S41 specifically includes the following steps: S411: First, establish background samples. In the first frame image, randomly select N pixels in the S*S neighborhood of each pixel as the background sample set for that pixel. S412: Based on the background samples, perform foreground pixel detection, calculate the Euclidean distance between the pixel of the next frame image and each pixel in the sample set. If it is less than the radius R, it is an approximate sample point. If the number of approximate sample points in the sample set is greater than the threshold P, the pixel of the next frame image is classified as a background pixel point; otherwise, it is a foreground pixel point. Let P=2, and R be the adaptive threshold, whose formula is: , R(x) is the radius threshold of the newly read pixel; R (x) is the radius threshold of the previous pixel, S²(x) is the variance of the newly read pixel and the pixels in the sample set, and θ is the measurement factor. When the variance is greater than the measurement factor, it means that the scene has changed significantly. Increase the R threshold, and vice versa. S413: The background model will be updated accordingly as the scene changes. The background may change in the next video frame, so the sample set needs to be updated continuously. Each background pixel has a probability of 1 / σ to update its own sample set, where σ is the update factor.