Highway agglomerate fog detection method based on improved YOLO11n
By introducing the C3K2-Mamba module, GSConv structure, and physical verification module PYV into the YOLO11n model, the problem of insufficient fog detection accuracy was solved, and high-precision fog detection was achieved.
Patent Information
- Application Number
- CN202511817934.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-04
- Publication Date
- 2026-03-03
AI Technical Summary
The existing YOLO11n model has relatively weak accuracy in detecting fog patches and is prone to misjudging objects with similar characteristics, such as smoke, making it difficult to achieve high-precision fog patch detection.
The C3K2-Mamba module is introduced into the Backbone layer of the YOLO11n model, the GSConv structure is introduced into the Neck layer, and the Physical Validation Module PYV is added to the output layer to detect the fog by combining the physical and optical properties of the fog.
It significantly improves the accuracy and reliability of fog detection, and enhances the detection capability of fog by integrating a dual discrimination system of visual perception and physical mechanism.
Smart Images

Figure CN121600370A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision, specifically relating to a method for detecting fog on highways based on an improved YOLO11n. Background Technology
[0002] Fog patches on highways, due to their sudden formation, extremely high concentration, localized impact, and unpredictability, pose a serious threat to road traffic safety. Current research on real-time monitoring of highway fog patches mainly includes meteorological detection methods and image-based deep learning methods. Meteorological detection methods rely on limited meteorological station data, exhibiting significant limitations in accuracy, real-time performance, and localized area capture capabilities. They struggle to accurately depict localized micro-meteorological changes on highway sections, failing to meet real-time early warning requirements. Deep learning methods, through end-to-end learning of fog visual representations using models such as convolutional neural networks, demonstrate stronger feature extraction and generalization capabilities. Their significant advantages include non-contact, wide-coverage, and high spatiotemporal resolution monitoring; easy reuse of existing monitoring facilities; and fast response speed, making them suitable for integration into real-time early warning systems. YOLO (You Only Look Once) is a representative single-stage detection method in deep learning detection. YOLO11n, a lightweight model in the YOLOv11 series, provides high-precision detection while offering the lowest computational complexity and fastest inference speed, making it an ideal choice for real-time target detection on resource-constrained edge devices.
[0003] However, due to the characteristics of fog patches, such as blurred boundaries and irregular shapes, the basic YOLO11n model has relatively weak accuracy in detecting fog patches. It is prone to misjudging smoke with similar characteristics to fog patches, and there is still room for improvement in the detection accuracy and reliability of the model.
[0004] In view of this, the present invention is hereby proposed. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and propose a highway fog detection method based on an improved YOLO11n. This method improves the YOLO11n model and innovatively adds a physical verification module to the output layer, achieving high-precision fog detection. This method is not a general target detection framework, but a specialized model that deeply couples the unique physical and optical characteristics and visual representation of highway fog.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: See Figure 1 This invention provides a method for detecting fog patches on highways based on an improved YOLO11n, comprising the following steps: Step 1: Collect images of fog generated on highways, build a fog dataset and preprocess it, then divide it into training set, validation set and test set; Step 2: Construct an MGP-YOLO network model for patch fog detection based on the improved YOLO11n. The MGP-YOLO network model includes an improved Backbone layer, an improved Neck layer, and a physical verification layer connected to the Head layer. Step 3: Put the training set into the MGP-YOLO network model for training, and then put the validation set into the trained model for testing to obtain the optimal fog detection model; Step 4: Put the test set into the optimal fog detection model for testing and evaluation to obtain the target location and target category in the image, thus obtaining the final detection result.
[0007] Furthermore, in step 1, the preprocessing involves marking the image with fog, and then performing random flipping, random cropping, image scaling, horizontal flipping, brightness adjustment, and saturation adjustment operations.
[0008] Furthermore, in step 2, the improved Backbone layer, based on the YOLO11n Backbone, replaces the original C3k2 module with the C3k2-Mamba module; The specific structure consists of the following modules connected in sequence: Conv module, Conv module, C3k2-Mamba module 1, Conv module, C3k2-Mamba module 2, Conv module, C3k2-Mamba module 3, Conv module, C3k2-Mamba module 4, SPPF module, and C2PSA module.
[0009] Furthermore, the C3k2-Mamba module includes a Conv submodule and a Split submodule. The Split submodule splits the feature map output by the Conv submodule into parallel and independent direct connection branches, local feature branches, and global feature branches in the channel dimension. The outputs of the direct connection branches and local feature branches are processed by a multi-branch parallel feature extraction and processing module. The output of the global feature branch is processed sequentially by the Conv submodule and the Mamba submodule. The Concat submodule receives the outputs of the multi-branch parallel feature extraction and processing module and the Mamba submodule as input, and then processes them by the Conv submodule.
[0010] Furthermore, in step 2, the improved Neck layer, based on the YOLO11n Neck, replaces the original convolutional structure Conv module with a GSConv module of hybrid convolutional structure. The specific structure includes Unsample module 1, Concat module 1, Concat module 2, Concat module 3, and Unsample module 2. The output of the C2PSA module serves as the input of Unsample module 1. Concat module 1 receives the outputs of Unsample module 1 and C3k2-Mamba module 3 as inputs, and then passes through C3k2 module 1 and Unsample module 2 in sequence. Concat module 2 receives the outputs of C3k2-Mamba module 2 and Unsample module 2 as inputs, and then passes through C3k2 module 2 and GSConv module 1 in sequence. Concat module 3 receives the outputs of GSConv module 1 and C3k2 module 1 as inputs, and then passes through C3k2 module 3 and GSConv module 2 in sequence. Concat module 4 receives the outputs of GSConv module 2 and C2PSA module as inputs, and then outputs to C3k2 module 4.
[0011] Furthermore, the GSConv module includes a Conv submodule. The output of 1 / 2 channels of the Conv submodule is used to perform feature downsampling and channel adjustment using standard convolution. Then, the output of the remaining 1 / 2 channels is introduced into a depthwise separable convolution to extract features. The results of the two convolutions are then used as inputs to the Concat submodule and concatenated in the channel dimension. Finally, a channel shuffling operation is used to promote cross-channel information fusion.
[0012] Further, in step 2, the Head layer includes Detect module 1, Detect module 2 and Detect module 3. Detect module 1 receives the feature map output by C3k2 module 2, Detect module 2 receives the feature map output by C3k2 module 3, and Detect module 3 receives the feature map output by C3k2 module 4. The Detect module 1, Detect module 2 and Detect module 3 all output detection results containing bounding box coordinates, confidence scores and class probabilities to the physical verification layer.
[0013] Furthermore, the physical verification layer includes a Region Extraction Module (REM), a Feature Calculation Module (DMM), and a Verification Module (VMM); the Region Extraction Module (REM) includes a Target Region Extraction Submodule (ROI) and a Background Region Extraction Submodule (BG). The feature calculation module DMM includes a submodule MID for calculating the average gray level difference and a submodule SDR for calculating the standard deviation ratio. The target region submodule ROI outputs its extracted target region R to the corresponding submodules MID and SDR. The background region submodule BG outputs its proposed background region B to the corresponding submodules MID and SDR. The verification module VMM includes a parameter comparison module NCM and a discrimination mechanism module VEM. The parameter comparison module NCM receives the outputs of all sub-modules MID and SDR as input, and the discrimination mechanism module VEM receives the outputs of the parameter comparison module NCM and the threshold adjustment module THR as input.
[0014] Furthermore, the average grayscale difference of the submodule MID is calculated using the following formula: ,in, This represents the arithmetic mean of the grayscale values of all pixels within the target region R. This represents the arithmetic mean of the grayscale values of all pixels within the background region B. The standard deviation ratio submodule SDR is calculated using the following formula: ,in, It represents the standard deviation of pixel grayscale values in the target region R and the background region B.
[0015] Furthermore, the parameter comparison module NCM includes calculating the area of the target region R. S R ,Will S R Area of the original image S A Substitution In the middle, when When the target region R is selected as the center, the region is expanded outward by a factor of 1.5 to obtain a new feature map. The MID and SDR values of the background region B are calculated and input into the discrimination mechanism module VEM, along with the threshold. and The comparison is shown in the following formula: ; ; If the above formulas are true at the same time, then the target area R is determined to be a fog region; otherwise, it is a non-fog region. when When the target region R is R, the arithmetic mean of the pixel grayscale values is calculated. and standard deviation , with threshold μ and σ The comparison is shown in the following formula: ; ; If the above formulas are true at the same time, then the target area R is determined to be a fog region; otherwise, it is a non-fog region.
[0016] Compared with the prior art, the present invention has the following beneficial effects: This invention provides a highway fog detection method based on an improved YOLO11n. This method achieves accurate fog detection based on the improved YOLO11n network model, which incorporates a C3K2-Mamba module. This C3K2-Mamba module is the first to combine the C3K2 and Mamba models. Specifically, the Mamba model is a State Space Model (SSM). Its core advantage lies in leveraging the SSM's strength in modeling long-range dependencies to enhance the model's ability to perceive "fuzzy boundaries" and "unstructured features." Local information from the input features is then extracted through a C3K2 branch module. Finally, the local features extracted by the C3K2 branch module are fused with the global features modeled by the Mamba branch module. This is one of the fundamental characteristics that distinguishes this algorithm from general object detectors. In the Neck layer of the YOLO 11n model, a GSConv structure is introduced. The GSConv structure is a hybrid convolutional structure, which is specifically designed for fog. This is because the image texture details are lost and the gradient information is weakened in the fog-covered area. Introducing the hybrid convolutional structure GSConv can preserve the subtle texture and contrast differences between the fog area and the normal area to the maximum extent, and optimize the "detail decay" effect caused by fog. One of the core innovations of this patent is the Physical Verification (PYV) mechanism based on the physical characteristics of fog at the output layer. As a post-processing filter, it receives the detection bounding boxes of the target detection region initially generated by the YOLO model. By quantitatively calculating the differences in the underlying image physical properties of the region within the bounding box and the surrounding normal region, including contrast and grayscale statistical features, it utilizes the optical mechanism of fog to perform secondary verification of the YOLO detection results. This increases the detection accuracy and reliability of the model.
[0017] In summary, this patent constructs a dual discrimination system based on the characteristics of fog, namely "visual perception (C3k2-Mamba + GSConv) + physical mechanism (PYV)," which improves the detection accuracy of fog from three levels: algorithm structure (for blurred boundaries), feature fusion strategy (for texture details), and decision logic (for optical physical properties). Attached Figure Description
[0018] The accompanying drawings are incorporated in and form part of this specification, and together with the description serve to explain the principles of the invention.
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of the highway fog detection method based on the improved YOLO11n of the present invention; Figure 2 The overall structure diagram of the MGP-YOLO network model for patch fog detection based on the improved YOLO11n is shown below; In this module, Backbone represents the main body, Neck represents the neck, Head represents the head, Input represents the input, Conv represents convolution, C3k2-Mamba represents the state-space model optimization C3k2 convolutional block (i.e., C3k2-Mamba module 1, C3k2-Mamba module 2, C3k2-Mamba module 3 or C3k2-Mamba module 4), SPPF represents spatial pyramid fast pooling, Upsample represents downsampling, Concat represents concatenation (i.e., Concat module 1, Concat module 1, Concat module 1, Concat module 2, Concat module 3 or Concat module 4), GSConv represents hybrid convolution (GSConv module 1 or GSConv module 2), and PYV represents physical verification module.
[0021] Figure 3 This is a structural diagram of the C3k2-Mamba module of the present invention; Where Input represents input, Mamba represents state space module, Conv represents convolution, Split represents splitting, Concat represents concatenation, Bott represents bottleneck module, and C3k represents multi-scale convolution kernel.
[0022] Figure 4 This is a structural diagram of the GSConv module of the present invention; Where Input represents the input, Conv represents convolution, DWC represents depthwise separable convolution, Concat represents concatenation, Shuffle represents channel rearrangement, and Output (C2 channels) represents the final output feature map with 2 channels.
[0023] Figure 5 This is a diagram of the Physical Verification System (PYV) architecture of the present invention; In this module, YOLO Input represents the input to the YOLO model, ROI represents the target region, BG represents the background region, REM represents the region extraction module, MID represents the overall brightness difference between the target region and the background region, SDR represents the flatness of the texture within the target region relative to the background region, DMM represents the feature calculation module, VEM represents the discrimination mechanism module, NCM represents the parameter comparison module, THR represents the threshold adjustment module, VMM represents the validation module, and Output represents the output.
[0024] Figure 6 This is a detection result image of a fog patch in the embodiment; Figure 7 This is a detection result image of another fog patch in the embodiment. Detailed Implementation
[0025] Exemplary embodiments will now be described in detail. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples consistent with some aspects of the invention as detailed in the appended claims. Example
[0026] Please see Figures 2-5 This embodiment provides a method for detecting fog patches on highways based on the improved YOLO11n, including the following steps: Step 1: Collect 6,000 images of fog patches from Sichuan highway side monitoring and self-built data, establish a fog patch dataset and preprocess it, and then divide it into training set, validation set and test set; The specific process is as follows: Step 101: Mark the image with fog, and then perform random flipping, random cropping, image scaling, horizontal flipping, brightness adjustment, and saturation adjustment operations; adjust the input image to 640×640 pixels, and then divide the processed dataset into training set, validation set, and test set in a ratio of 7:2:1.
[0027] Step 2: Construct an MGP-YOLO network model for patch fog detection based on the improved YOLO11n. The MGP-YOLO network model includes an improved Backbone layer, an improved Neck layer, and a physical verification layer connected to the Head layer. The improved Backbone layer is based on YOLO11n Backbone, and replaces the original C3k2 module with the C3k2-Mamba module; like Figure 2As shown, the specific structure consists of the following modules connected in sequence: Conv module, Conv module, C3k2-Mamba module 1, Conv module, C3k2-Mamba module 2, Conv module, C3k2-Mamba module 3, Conv module, C3k2-Mamba module 4, SPPF module, and C2PSA module.
[0028] Because fog has no fixed shape, its boundaries are diffuse and gradual, blending into the background, making it difficult for general detectors to accurately define the fog area. Therefore, this invention designs the C3k2-Mamba module to address the "boundary ambiguity" and "morphological irregularity" of fog. Replacing the C3k2 module in the Backbone module of the YOLO 11n network model with the C3k2-Mamba module retains the original module's efficient local feature extraction advantage. Leveraging the advantages of the State Space Model (SSM) in modeling long-range dependencies, the model can transcend the local receptive field and infer the blurred boundaries of fog from the global image context, significantly improving the model's ability to model long-range dependencies and extract blurred boundary features of fog. For targets with clear boundaries, this powerful global modeling capability is not necessary and may even introduce irrelevant noise; however, it significantly enhances perception capabilities for "ambiguous boundaries" and "unstructured features" like fog, which is one of the fundamental characteristics that distinguishes this algorithm from general object detectors.
[0029] The C3k2-Mamba module includes a Conv submodule and a Split submodule. The Split submodule splits the feature map output by the Conv submodule into parallel and independent direct connection branches, local feature branches, and global feature branches along the channel dimension. The outputs of the direct connection branches and local feature branches are processed by a multi-branch parallel feature extraction and processing module (a lightweight convolution module based on CSPNet and a bottleneck module Bott, using multi-scale convolutional kernels C3k). The output of the global feature branch is processed sequentially by the Conv submodule and the Mamba submodule. The Concat submodule receives the outputs of the multi-branch parallel feature extraction and processing module and the Mamba submodule as input, and then processes them through the Conv submodule.
[0030] Specifically, the workflow of the C3k2-Mamba module is as follows: Step 201: The direct connection branch is responsible for maintaining the integrity of the original features. An optional 1×1 convolutional layer is used to achieve channel dimension matching between the input and output to ensure stable gradient flow propagation, outputting Y. Ide .
[0031] when At that time, ;otherwise C inC is the number of input channels; out X represents the number of output channels; X represents the feature map. Step 202: The local feature branch continues the classic structure of the C3k2 module. It compresses the number of channels using a 1×1 convolution, then performs efficient local feature extraction through two consecutive 3×3 depthwise separable convolutions. Finally, it uses another 1×1 convolution to restore the number of channels and outputs Y. Loc .
[0032] Here, DC represents depthwise separable convolution operation.
[0033] Step 203: The global feature branch is a newly added branch. First, the number of channels is reduced by 1×1 convolution to control computational complexity. Then, the two-dimensional feature map is... Serialization into a one-dimensional data stream Where L = H×W and D are the projection dimensions. Then, the sequence is input into the Mamba module for global context modeling. Finally, the processed sequence is restored to feature map format and the output channel dimensions are adjusted using a 1×1 convolution to output Y. Glo .
[0034] Step 204: The outputs of the three branches are concatenated to perform feature fusion. .
[0035] To address the "loss of texture detail" in foggy areas, a GSConv hybrid convolutional structure is designed. Fog, composed of suspended water droplets, produces strong Mie scattering of light, leading to the loss of texture detail and weakened gradient information in the areas it covers. General detectors, employing structures like depthwise separable convolutions for speed, exacerbate the loss of spatial information, hindering the capture of these subtle texture variations. This algorithm introduces a GSConv structure into the Neck layer of the YOLO 11n model to balance channel information and spatial detail. This structure concatenates the results of standard convolutions (preserving rich spatial information) and depthwise separable convolutions (ensuring efficiency) and performs channel shuffling to maximize the preservation of subtle texture and contrast differences between foggy and normal regions.
[0036] The improved Neck layer, based on the YOLO11n Neck, replaces the original Conv module with a GSConv module of hybrid convolutional structure. like Figure 2As shown, the specific structure includes Unsample module 1, Concat module 1, Concat module 2, Concat module 3, and Unsample module 2. The output of the C2PSA module serves as the input of Unsample module 1. Concat module 1 receives the outputs of Unsample module 1 and C3k2-Mamba module 3 as inputs, and then passes through C3k2 module 1 and Unsample module 2 in sequence. Concat module 2 receives the outputs of C3k2-Mamba module 2 and Unsample module 2 as inputs, and then passes through C3k2 module 2 and GSConv module 1 in sequence. Concat module 3 receives the outputs of GSConv module 1 and C3k2 module 1 as inputs, and then passes through C3k2 module 3 and GSConv module 2 in sequence. Concat module 4 receives the outputs of GSConv module 2 and C2PSA module as inputs, and then outputs to C3k2 module 4.
[0037] The C3k2-Mamba module 2, C3k2-Mamba module 3, and C2PSA module output feature information at three different scales.
[0038] Specifically, the workflow of the GSConv module is as follows: The GSConv module includes a Conv submodule. The output of half a channel of the Conv submodule is downsampled and adjusted using standard convolution (SC). The output of the remaining half channel is then fed into depthwise separable convolution (DWC) to extract features. The results of the two convolutions are then concatenated along the channel dimension as input to the Concat submodule. Finally, a channel shuffle operation promotes cross-channel information fusion. This method reduces computational complexity while maximizing the preservation of implicit correlations between channels and enhancing the reusability of non-redundant features.
[0039] like Figure 2 As shown, the Head layer includes Detect module 1, Detect module 2 and Detect module 3. Detect module 1 receives the feature map output by C3k2 module 2, Detect module 2 receives the feature map output by C3k2 module 3 and Detect module 3 receives the feature map output by C3k2 module 4. The Detect module 1, Detect module 2 and Detect module 3 all output detection results containing bounding box coordinates, confidence scores and class probabilities to the physical verification layer.
[0040] This patented patent designs a Physical Validation Layer (PYV) based on the physical characteristics of images to address the "optical scattering properties" of fog. The most fundamental physical manifestation of fog in an image is that its scattering effect alters the average grayscale of the covered area (abnormal brightness), and the internal grayscale distribution tends to be more uniform (smaller standard deviation). This is a combined characteristic not found in common interfering elements such as water stains, shadows, and clouds. The PYV module designed in this patent is not a general post-processing logic (such as non-maximum suppression), but rather an expert judgment system embedding prior physical knowledge. It utilizes the optical mechanism of fog to define two physical parameters: the Mean Gray Difference (MID) and the Standard Deviation Ratio (SDR), to perform secondary verification of the initial detection results.
[0041] The physical verification layer includes a Region Extraction Module (REM), a Feature Calculation Module (DMM), and a Verification Module (VMM); the Region Extraction Module (REM) includes a Target Region Extraction Submodule (ROI) and a Background Region Extraction Submodule (BG). The feature calculation module DMM includes a submodule MID for calculating the average gray level difference and a submodule SDR for calculating the standard deviation ratio. The target region submodule ROI outputs its extracted target region R to the corresponding submodules MID and SDR. The background region submodule BG outputs its extracted background region B to the corresponding submodules MID and SDR. The verification module VMM includes a parameter comparison module NCM and a discrimination mechanism module VEM. The parameter comparison module NCM receives the outputs of all sub-modules MID and SDR as input, and the discrimination mechanism module VEM receives the outputs of the parameter comparison module NCM and the threshold adjustment module THR as input.
[0042] Specifically, the Mean Intensity Difference (MID) is used to quantify the overall brightness deviation between the target area and the background area. It is calculated using the following formula: ,in, This represents the arithmetic mean of the grayscale values of all pixels within the target region R. The MID value represents the arithmetic mean of the grayscale values of all pixels within the background region B; the larger the MID value, the stronger the overall brightness contrast between the two regions.
[0043] The Standard Deviation Ratio (SDR) is used to characterize the rate attenuation of texture complexity or detail richness of a target area relative to the background area. It is calculated using the following formula: ,in, This represents the standard deviation of pixel grayscale values in the target region R and the background region B. For a realistic fog region, it should exhibit significantly lower characteristics, so its SDR value should be less than 1. This parameter can capture the "homogenization" effect caused by fog and can eliminate interference that causes brightness changes but does not change the texture characteristics within the region.
[0044] Specifically, the parameter comparison module NCM includes, for each target region R output by the YOLO model, calculating the coordinates (x, y) of the target region R. min , y min , x max , y max ), and calculate its area. S R ,Will S R Area of the original image S A Substitution In the middle, when When the target region R is selected, the region is expanded outward by a factor of 1.5 to obtain a new feature map. The R portion is then removed to obtain the background region B. The MID and SDR values of the background region B are calculated and input into the discrimination mechanism module VEM, along with a threshold. and The comparison is shown in the following formula: ; ; If the above formulas are true at the same time, the target area R is determined to be a fog region and the result is output through output; otherwise, it is a non-fog region. when When the target region R is R, the arithmetic mean of the pixel grayscale values is calculated. and standard deviation , with threshold μ and σ The comparison is shown in the following formula: ; ; If the above formulas are true, then the target region R is determined to be a fog region and the result is output via output; otherwise, it is a non-fog region.
[0045] Step 3: Put the training set into the MGP-YOLO network model (i.e., use the training set as input to the improved Backbone layer) for training, and then put the validation set into the trained model for testing to obtain the optimal fog detection model. Step 4: Feed the test set into the optimal fog detection model for testing and evaluation to obtain the target location and target category in the image, thus obtaining the final detection result (e.g., ...). Figure 6 ).
[0046] It should be noted that the threshold is based on the statistics of the experimental labeled dataset in this embodiment. The average values of μ, σ, MID and SDR feature values of the fog samples in the labeled dataset are calculated, and the average values of these statistics are used as the discrimination threshold to determine the threshold combination that can maximize the detection performance.
[0047] At the code level, the threshold obtained from statistical experiments is passed in as a constructor parameter and stored in an internal variable of the THR module. If the threshold needs to be changed, it can be modified directly in the function.
[0048] The model setup and training configuration are shown below: The virtual environment used to set up the training model on the Windows operating system is explained below: A conda virtual environment with Python 3.10 was created, and then the PyTorch neural network architecture, version 1.8.1, was installed. The GPU used in the experiment was an NVIDIA GeForce RTX 3090, the CPU was a Cintel Core i9-12900K, and the CUDA version was 11.4. The same hyperparameters were used throughout the training process.
[0049] The model was evaluated using several metrics, including Precision (Pr), Recall (Re), Harmonic Mean F1 Score, and Mean Average Precision (mAP).
[0050] Pr measures the accuracy of predictions, and Re represents the model's ability to capture all relevant instances. The F1 score is the harmonic mean of precision and recall, providing a balanced metric for accuracy and coverage. mAP calculates the average precision across all classes, reflecting overall model performance. The definitions of Pr, Re, F1, and mAP are as follows: Tp represents the number of predicted positive examples in positive samples, Fp represents the number of predicted negative examples in negative samples, FN represents the number of predicted negative examples in positive samples, N is the total number of samples in this class, and the mean precision mAP is the average AP value for each detected object category. In this embodiment, mAP50 and mAP50-95 are selected. Here, mAP50 represents the average precision of all object detection categories when the Intersection over Union (IoU) threshold is 50%, and mAP50-95 represents the average precision of all object detection categories at various IoU thresholds (from 50% to 95%, with a step size of 5%). IoU is an important indicator for judging the overlap between predicted bounding boxes and labeled bounding boxes in object prediction tasks, as shown in the formula.
[0051] In the formula: Bp is the area of the predicted bounding box; B G To label the area of the bounding box.
[0052] To gain a more intuitive understanding of the gains of each module on the YOLO 11n network structure, ablation experiments were conducted on the same dataset under the same configuration environment. Using YOLO 11n as the base network, C3k2 was replaced with C3k2-Mamba in the Backbone layer, the Conv convolutional structure was replaced with GSConv in the Neck layer, and a Physical Validation (PYV) mechanism was added to the output layer. The validation results are shown in Table 5, where “√” indicates that the improvement method was adopted, and “×” indicates that the improvement method was not adopted.
[0053] The ablation experiment results are shown in Table 1. The three improvement strategies proposed in this study all positively impacted model performance. Specifically, introducing the C3k2-Mamba module into the Backbone layer improved mAP@0.5 by 0.5 percentage points, demonstrating its effectiveness in long sequence modeling; replacing standard convolution with GSConv improved mAP@0.5 by 0.3 percentage points, showing its advantage in cross-channel information fusion; and the introduction of the Physical Validation (PYV) mechanism improved mAP@0.5 by 0.6 percentage points, validating its role in enhancing detection reliability by introducing physical priors. Notably, when the three improvement strategies worked synergistically, the model achieved optimal overall performance while maintaining a high inference speed (350.1 FPS): mAP@0.5 reached 91.3%, mAP@0.5:0.95 reached 84.7%, and the F1 score improved to 91.9%. This result fully demonstrates the good complementary effect among the various improvement modules.
[0054] Table 1 Ablation Experiment To verify the effectiveness of the improved YOLO11n model in this embodiment, the inventors conducted the following comparative experiment: To objectively evaluate the performance of different models on this task, YOLO v5n, YOLO v7n, YOLO v8n, YOLO v10n, YOLO 11n, YOLO v12n, SSD, and the improved model YOLO 11n were tested on the dataset presented in this paper using the same experimental platform. The recognition results of each model are shown in Table 2. The improved model demonstrates superiority in multiple key metrics. Compared with current mainstream lightweight detection models, this model achieves the best results in core metrics such as precision (93.3%), recall (90.5%), and mAP@0.5 (91.3%). It maintains a computational complexity comparable to the baseline model (6.5 × 10⁻⁶). 10 While maintaining the same FLOPs and inference speed (350.1 FPS), this model significantly outperforms YOLO v12n (0.2 percentage points improvement in mAP@0.5) and YOLO v8n (1.6 percentage points improvement in mAP@0.5). Compared to the two-stage detector Faster R-CNN, this model achieves a 27.2 percentage point improvement in mAP@0.5 while maintaining higher detection speed. These experimental results fully demonstrate that the proposed improvement scheme achieves a better balance between accuracy and speed, making it suitable for real-time detection scenarios.
[0055] Table 2 Comparative Experiments In summary, this embodiment utilizes YOLO 11n to build a fog detection model. A State-Space Model (SSM) is used to optimize the C3k2 convolutional block in the Backbone layer, a hybrid convolutional structure GSConv is added to the Neck layer, and a Physical Validation (PYV) mechanism is introduced in the output layer. This effectively improves the fog detection accuracy of the YOLO model and significantly enhances its fog detection capability.
[0056] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention.
[0057] It should be understood that the present invention is not limited to the content already described above, and various modifications and changes can be made without departing from its scope. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for detecting fog patches on highways based on an improved YOLO11n, characterized in that, Includes the following steps: Step 1: Collect images of fog generated on highways, build a fog dataset and preprocess it, then divide it into training set, validation set and test set; Step 2: Construct an MGP-YOLO network model for patch fog detection based on the improved YOLO11n. The MGP-YOLO network model includes an improved Backbone layer, an improved Neck layer, and a physical verification layer connected to the Head layer. Step 3: Put the training set into the MGP-YOLO network model for training, and then put the validation set into the trained model for testing to obtain the optimal fog detection model; Step 4: Put the test set into the optimal fog detection model for testing and evaluation to obtain the target location and target category in the image, thus obtaining the final detection result.
2. The method for detecting fog patches on highways according to claim 1, characterized in that, In step 1, the preprocessing involves marking the image with fog, and then performing random flipping, random cropping, image scaling, horizontal flipping, brightness adjustment, and saturation adjustment operations.
3. The method for detecting fog patches on highways according to claim 1, characterized in that, In step 2, the improved Backbone layer is based on the YOLO11n Backbone, and the original C3k2 module is replaced with the C3k2-Mamba module. The specific structure consists of the following modules connected in sequence: Conv module, Conv module, C3k2-Mamba module 1, Conv module, C3k2-Mamba module 2, Conv module, C3k2-Mamba module 3, Conv module, C3k2-Mamba module 4, SPPF module, and C2PSA module.
4. The method for detecting fog patches on highways according to claim 3, characterized in that, The C3k2-Mamba module includes a Conv submodule and a Split submodule. The Split submodule splits the feature map output by the Conv submodule into parallel and independent direct connection branches, local feature branches, and global feature branches in the channel dimension. The outputs of the direct connection branches and local feature branches are processed by a multi-branch parallel feature extraction and processing module. The output of the global feature branch is processed sequentially by the Conv submodule and the Mamba submodule. The Concat submodule receives the outputs of the multi-branch parallel feature extraction and processing module and the Mamba submodule as input, and then processes them by the Conv submodule.
5. The method for detecting fog patches on highways according to claim 3, characterized in that, In step 2, the improved Neck layer, based on the YOLO11n Neck, replaces the original convolutional structure Conv module with a GSConv module of hybrid convolutional structure. The specific structure includes Unsample module 1, Concat module 1, Concat module 2, Concat module 3, and Unsample module 2. The output of the C2PSA module serves as the input of Unsample module 1. Concat module 1 receives the outputs of Unsample module 1 and C3k2-Mamba module 3 as inputs, and then passes through C3k2 module 1 and Unsample module 2 in sequence. Concat module 2 receives the outputs of C3k2-Mamba module 2 and Unsample module 2 as inputs, and then passes through C3k2 module 2 and GSConv module 1 in sequence. Concat module 3 receives the outputs of GSConv module 1 and C3k2 module 1 as inputs, and then passes through C3k2 module 3 and GSConv module 2 in sequence. Concat module 4 receives the outputs of GSConv module 2 and C2PSA module as inputs, and then outputs to C3k2 module 4.
6. The method for detecting fog patches on highways according to claim 5, characterized in that, The GSConv module includes a Conv submodule. The output of 1 / 2 channels of the Conv submodule is used to perform feature downsampling and channel adjustment using standard convolution. Then, the output of the remaining 1 / 2 channels is introduced into a depthwise separable convolution to extract features. The results of the two convolutions are then used as inputs to the Concat submodule and concatenated in the channel dimension. Finally, a channel shuffling operation is used to promote cross-channel information fusion.
7. The method for detecting fog patches on highways according to claim 5, characterized in that, In step 2, the Head layer includes Detect module 1, Detect module 2 and Detect module 3. Detect module 1 receives the feature map output by C3k2 module 2, Detect module 2 receives the feature map output by C3k2 module 3 and Detect module 3 receives the feature map output by C3k2 module 4. The Detect module 1, Detect module 2 and Detect module 3 all output detection results containing bounding box coordinates, confidence scores and class probabilities to the physical verification layer.
8. The method for detecting fog patches on highways according to claim 1, characterized in that, The physical verification layer includes a Region Extraction Module (REM), a Feature Calculation Module (DMM), and a Verification Module (VMM); the Region Extraction Module (REM) includes a Target Region Extraction Submodule (ROI) and a Background Region Extraction Submodule (BG). The feature calculation module DMM includes a submodule MID for calculating the average gray level difference and a submodule SDR for calculating the standard deviation ratio. The target region submodule ROI outputs its extracted target region R to the corresponding submodules MID and SDR. The background region submodule BG outputs its proposed background region B to the corresponding submodules MID and SDR. The verification module VMM includes a parameter comparison module NCM and a discrimination mechanism module VEM. The parameter comparison module NCM receives the outputs of all sub-modules MID and SDR as input, and the discrimination mechanism module VEM receives the outputs of the parameter comparison module NCM and the threshold adjustment module THR as input.
9. The method for detecting fog patches on highways according to claim 8, characterized in that, The average grayscale difference of the submodule MID is calculated using the following formula: ,in, This represents the arithmetic mean of the grayscale values of all pixels within the target region R. This represents the arithmetic mean of the grayscale values of all pixels within the background region B. The standard deviation ratio submodule SDR is calculated using the following formula: ,in, It represents the standard deviation of pixel grayscale values in the target region R and the background region B.
10. The method for detecting fog patches on highways according to claim 8, characterized in that, The parameter comparison module NCM includes calculating the area of the target region R. S R ,Will S R Area of the original image S A Substitution In the middle, when When the target region R is selected as the center, the region is expanded outward by a factor of 1.5 to obtain a new feature map. The MID and SDR values of the background region B are calculated and input into the discrimination mechanism module VEM, along with the threshold. and The comparison is shown in the following formula: ; ; If the above formulas are true at the same time, then the target area R is determined to be a fog region; otherwise, it is a non-fog region. when When the target region R is R, the arithmetic mean of the pixel grayscale values is calculated. and standard deviation , with threshold μ and σ The comparison is shown in the following formula: ; ; If the above formulas are true at the same time, then the target area R is determined to be a fog region; otherwise, it is a non-fog region.