A model and algorithm for target detection in haze images
By introducing self-attention and co-occurrence relationship branches and edge-aware loss functions into the object detection model, the accuracy and robustness of object detection in haze weather are solved, and higher detection accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202510740470.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The existing target detection algorithm has significantly reduced performance under complex weather conditions such as haze, making it difficult to accurately identify and locate targets in images, and is not robust enough.
A haze image object detection model is constructed, a relational attention module of self-attention and co-occurrence relationship branches is introduced, and an edge-aware loss function is designed, combining local and global feature relationships to optimize the detection process.
The target detection accuracy and robustness of the model in smog weather are improved, and the detection performance of the model is enhanced by utilizing the target co-occurrence relationship and edge information.
Smart Images

Figure CN120259638B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of target detection and relates to a haze image target detection model and algorithm. Background Art
[0002] Object detection is a fundamental task in computer vision, aiming to identify and locate one or more objects within an image or video frame. Object detection models must not only identify the category (e.g., person, car, cat, etc.) of an object in an image but also determine its exact location within the image, typically by drawing bounding boxes. Currently, there are two main types of object detection algorithms within the deep learning field. One type involves two-stage object detection algorithms, which first generate a series of candidate sample boxes and then classify them using convolutional neural networks (CNNs), such as the R-CNN series and DetNe. The other type involves one-stage object detection algorithms, which directly transform the object bounding box localization problem into a regression problem, such as the SSD and YOLO series algorithms.
[0003] With the continuous emergence of new technologies and ongoing algorithm optimization, object detection technology is developing towards smarter and more accurate results. However, these algorithms often experience significant performance degradation in complex weather conditions, such as haze, rain, snow, and low light conditions. These adverse weather conditions not only reduce image visibility but also increase background noise, making it difficult to extract target features, thus severely impacting the accuracy and robustness of object detection. While the performance of object detection has significantly improved with the development of deep learning technology, its application in complex weather conditions remains a significant challenge.
[0004] Currently, there are two main approaches to object detection under visually degraded conditions. The first category involves object detection algorithms based on transfer learning. These methods study the alignment mechanism of source and target domain features, transferring features learned in the source domain to the target domain for detection. The second category involves object detection algorithms based on image restoration and feature enhancement. These typically combine an image enhancement module or network with an object detection network to improve the quality of degraded images. Summary of the Invention
[0005] The technical problem solved by the present invention is to provide a haze image target detection model and algorithm, construct an edge loss function and introduce a target co-occurrence attention module to achieve higher model accuracy.
[0006] The present invention is achieved through the following technical solutions:
[0007] A haze image object detection model includes a backbone network, a neck network, and a detection head. The model also has a relational attention module, which includes a self-attention branch and a co-occurrence relation branch. The loss function inside the detection head is updated to an edge-aware loss function.
[0008] The self-attention branch calculates lightweight multi-head self-attention through a local window to capture local feature relationships; the co-occurrence relationship branch generates global co-occurrence features based on the detection results of the co-occurrence detection head to provide scene-level context; the output of the relationship attention module is a weighted addition of the output feature maps of the self-attention branch and the co-occurrence branch;
[0009] The edge-aware loss function includes:
[0010] ;
[0011] ;
[0012] Among them, formula (5) is the expression of edge intersection-over-union ratio, and formula (6) is the edge perception loss function;
[0013] is the mask of the ground-truth target bounding box, M To predict the mask of the target bounding box, It is the edge feature map obtained after deep Sobel convolution and square root;
[0014] is the edge intersection-over-union loss, represents the Euclidean distance, b, w, and h represent the center point coordinates, width, and height of the bounding box, respectively. 、 、 Represent the center point coordinates, width and height of the predicted bounding box respectively, 、 、 Represent the diagonal length, width and height of the minimum circumscribed rectangle respectively, is the distance loss between the center point of the real box and the target box, is the width loss between the real box and the target box, is the height loss between the true box and the target box.
[0015] Furthermore, the self-attention branch first adds position encoding to the feature map, and then performs operations including convolution, partitioning by channel dimension, partitioning by window, and expansion by window on it in sequence to obtain the three elements of query, index, and content used to calculate self-attention; the three elements obtained are calculated by multi-head self-attention and then the output feature map is merged, and finally a residual connection is performed with the input feature map to capture local feature relationships.
[0016] Furthermore, the self-attention branch is implemented based on equations (1) and (2):
[0017] ;
[0018] in, Input feature map for co-occurrence attention X The output after position encoding is represents 1×1 convolution, Represents operations that partition by channel dimension and partition by window, Represents the operation of expanding by window;
[0019] ;
[0020] in, 、 、 From formula (1), represents the number of attention heads, is the activation function, T represents transpose, It represents the transformation of the outputs of different heads to achieve uniformity. Indicates that the calculation results previously divided by channel dimension and by window are folded and restored.
[0021] Furthermore, the co-occurrence branch first uses a co-occurrence detection head to extract the object categories in the scene, then maps the categories into high-dimensional embedding vectors to encode the co-occurrence relationships between embedding vectors of different categories; it then average pools to generate a global scene representation and propagates the global features to all locations to provide scene-level context;
[0022] The co-occurrence branch also learns the relationship between embedding vectors of different categories through co-occurrence patterns in training data to achieve higher prediction accuracy.
[0023] Furthermore, the output of the co-occurrence branch is:
[0024] ;
[0025] in, for After average pooling and expansion to the spatial dimension, the co-occurrence features are obtained. represents the i-th category, N is the total number of categories, Extract the feature vector after mapping the category ID from the detection result D; [ B, C, H, W ] is the standard dimensional format for deep learning models to process image data, where B represents the batch size, CRepresents the number of channels, H and W Represents the height and width of the image respectively.
[0026] Furthermore, the output of the relation attention module is expressed as:
[0027] ;
[0028] is the output of the co-occurrence attention module, where Adjust the parameters for the branches to balance the output of the self-attention branch With collinear branch output The degree of contribution to the output feature map.
[0029] Furthermore, the backbone network, neck network and detection head adopt the baseline network of yolov8, and add a co-occurrence relationship attention module after the convolution at the end of the c2f module of the baseline network yolov8;
[0030] In the constructed model, the input image first enters the backbone network, and then alternates through multiple convolutional layers and C2f modules to gradually extract deep semantic features and generate feature maps of multiple different resolutions from P1 to P5; in the neck network, feature maps of different levels are fused through a top-down path and a bottom-up path to obtain the P3 layer, P4 layer, and P5 layer after feature fusion; finally, the detection head performs detection, and the loss function inside the detection head evaluates the quality of the detection.
[0031] Furthermore, the edge-aware loss function requires three inputs:
[0032] The first input is the ground truth bounding box annotated in the dataset. The mask extraction module extracts the mask from the ground truth bounding box and inputs it into the edge intersection-over-union loss function for calculation.
[0033] The second input is the original image of the dataset. After the shallow convolution processing of the model, the feature map of the middle layer is extracted and subjected to deep Sobel convolution processing. Then, the square root operation is performed to obtain the edge feature map, which is then input into the edge intersection-to-union loss function.
[0034] The third input is the output prediction result of the model. The mask of the predicted target bounding box is extracted from the prediction result through the mask extraction module and input into the loss function.
[0035] The present invention also provides a detection algorithm based on the haze image target detection model, comprising the following operations:
[0036] 1) Construct a haze image object detection model based on edge-aware loss and co-occurrence relationship; and update the loss function to the edge-aware loss function;
[0037] 2) Training the network model and selecting model evaluation metrics. During training, the model optimizes the loss through backpropagation, gradually approximating the predicted box to the position and size of the ground-truth box. A smaller output loss value indicates a higher degree of edge overlap between the predicted box and the ground-truth box, a closer center point, and a more consistent aspect ratio.
[0038] 3) Obtain the trained model for target detection.
[0039] Compared with the prior art, the present invention has the following beneficial technical effects:
[0040] The proposed haze image object detection model uses the YOLOv8 network as its baseline, introduces a target co-occurrence attention module, and designs a new edge-aware loss function. This target co-occurrence attention module is based on the observation that certain objects can easily appear in the same scene in the real world. Therefore, the target detection model can exploit this symbiotic relationship to compensate for the lack of visual features extracted by the target detection model from haze weather images, thereby improving the model's accuracy.
[0041] The proposed loss function, Edges-Aware IoU loss (EAIoU), takes into account the alignment of object edges within a bounding box, while existing loss functions only consider the geometric relationship of the bounding box. By combining traditional IoU calculations with edge information, EAIoU can more accurately assess the similarity between the model's predicted bounding box and the ground-truth bounding box.
[0042] The present invention achieves more efficient use of existing information and mining of more available information, effectively improving the accuracy of the target detection model under complex weather backgrounds, with better performance and stronger robustness; compared with the baseline network, it achieves higher model accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Schematic diagram of the co-occurrence attention module of the present invention;
[0044] Figure 2 This is a schematic diagram of the c2f_CRA module of the present invention;
[0045] Figure 3 Schematic diagram of the target detection network model of the present invention;
[0046] Figure 4 Schematic diagram of the edge loss function of the present invention;
[0047] Figure 5 Heat map of the baseline model;
[0048] Figure 6 Heatmap of the model generated for this invention. DETAILED DESCRIPTION
[0049] The present invention is further described in detail below with reference to the embodiments, which are intended to explain the present invention rather than to limit it.
[0050] A haze image object detection model consists of a backbone network, a neck network, and a detection head. The backbone network is the main feature extraction part of the model and is composed of a deep convolutional neural network (CNN) to extract high-level, semantically rich features from the input image.
[0051] The neck network is an intermediate layer between the backbone network and the head. It performs operations such as feature fusion and context enhancement based on the features extracted by the backbone network. The neck network typically includes convolutional layers, pooling layers, and an attention mechanism. The design of the neck helps the network perceive objects at different scales and provides more contextual information.
[0052] The detection head can also be called the head network. The head network is the output part of the model, which is responsible for the final task prediction and outputs the category label of each predicted target and the predicted value of each category.
[0053] The model also has a relational attention module, which contains two branches: self-attention and co-occurrence relationship; and updates the loss function inside the detection head to an edge-aware loss function;
[0054] The self-attention branch calculates lightweight multi-head self-attention through a local window to capture local feature relationships; the co-occurrence relationship branch generates global co-occurrence features through the detection results of the co-occurrence detection head to provide scene-level context; the output of the relationship attention module performs weighted addition of the output feature maps of the self-attention branch and the co-occurrence branch.
[0055] The detection algorithm based on the haze image target detection model includes the following operations:
[0056] a. Build a haze image target detection model based on edge-aware loss and co-occurrence relationship; and update the loss function to the edge-aware loss function;
[0057] b. Training the network model, selecting the dataset and model evaluation metrics. During training, the model optimizes the loss through backpropagation, gradually approximating the predicted box to the position and size of the ground-truth box. The smaller the output loss value, the higher the edge overlap between the predicted box and the ground-truth box, the closer the center point, and the more consistent the aspect ratio.
[0058] c. Obtain the trained model for target detection.
[0059] The following is a detailed description of each part.
[0060] 1) Constructing a haze image target detection model based on edge-aware loss and co-occurrence relationship
[0061] Design of the backbone and neck networks. Currently, traditional object detection models primarily rely on visual features to identify and locate objects. However, fully extracting visual features from images under complex weather conditions is a challenge for object detectors. In real-world scenarios, certain objects tend to co-occur in the same scene. For example, bicycles and pedestrians are more likely to appear in the same scene, while bicycles and airplanes rarely appear together. Therefore, object detectors can exploit this symbiotic relationship to compensate for the shortcomings of visual features.
[0062] To achieve this goal, the present invention constructs a co-occurrence relationship attention module CRA (Co-occurrence relationship attention); the embodiment given in the present invention combines this module with the c2f in the baseline network yolov8 to arrive at an improved baseline network.
[0063] This module consists of two branches: self-attention and co-occurrence relationship. The self-attention branch calculates lightweight multi-head self-attention through a local window to capture local feature relationships.
[0064] The co-occurrence relationship branch generates global co-occurrence features based on the detection results of the co-occurrence detection head, providing scene-level context. The global co-occurrence feature is the average representation of all detected categories, rather than explicitly modeling the relationship between categories.
[0065] The output of the CRA module is a weighted feature fusion of the two: the output feature maps of the self-attention branch and the co-occurrence branch are weightedly added; this combines local details and global semantics to pass the preliminary detection results;
[0066] For the self-attention branch, since traditional convolutional neural networks (CNNs) mainly rely on local receptive fields and have difficulty capturing the dependencies between distant targets, such as the relationship between cars and pedestrians in traffic scenes, it is necessary to introduce a self-attention branch to calculate the dependencies between all positions in the feature map and directly model the global context information, thereby better understanding the relationship between targets in the scene.
[0067] See also Figure 1, the self-attention branch first adds position encoding to the feature map, and then performs 1×1 convolution, channel dimension partitioning, and window partitioning on it in turn to obtain the query used to calculate the self-attention ,index ,content The three elements are obtained through multi-head self-attention calculation and then merged into the output feature map, which is finally connected to the input feature map through residual connection. This prevents gradient vanishing in deep neural networks while helping the model retain the original input information.
[0068] Specifically, the self-attention branch is implemented based on formula (1) and formula (2):
[0069] ;
[0070] in, Input feature map for co-occurrence attention X The output after position encoding is represents 1×1 convolution, Represents operations that partition by channel dimension and partition by window, Represents an operation to expand by window.
[0071] ;
[0072] in, 、 、 From formula (1), X The initial input image is processed layer by layer by the network and transmitted to the input feature map of the co-occurrence relationship attention. represents the number of attention heads, is the activation function, T represents transpose, It represents the transformation of the outputs of different heads to achieve uniformity. The table folds and restores the calculation results previously divided by channel dimension and by window.
[0073] The specific operation of the self-attention branch is given below:
[0074] use The operation divides the input feature map into multiple local windows, and the features in each window will be processed separately. Next, after generating Q, K, and V, The operation is divided into three parts: q, k, and v. Then, each part is window expanded to limit the query, key, and value of each position to the local window. For example, for a 7×7 window, each position can only focus on other positions in the surrounding 7×7 area, thereby capturing local relationships. In the multi-head processing part, the expanded window is converted into a multi-head structure, and each head processes a different subspace. The attention score is calculated within each window, so that each head can focus on different local feature combinations within the window. One head may focus on horizontal edges, and another head on vertical edges, thereby jointly capturing local feature relationships.
[0075] The co-occurrence branch leverages the initial predictions from the co-occurrence detection head to dynamically adjust feature weights, allowing the model to focus more on areas relevant to the current scene. For example, in an indoor scene, after detecting an object of the "table" category, the model can enhance feature responses to categories such as "chair" or "computer."
[0076] The model learns the relationship between the embedding vectors of different categories by using co-occurrence patterns in the training data. If "table" and "chair" frequently co-occur in the training data, the model may make their embedding vectors highly similar in space. When "table" is detected, the co-occurrence feature is the embedding vector of "table" (averaged for a single category). The model learns to make the embedding vectors of "table" and "chair" close in vector space. After fusion, the feature response of the "chair" related region is indirectly enhanced, thereby achieving higher prediction accuracy.
[0077] The specific operations of the co-occurrence branch are given below:
[0078] First, a co-occurrence detection head (with the same structure as the detection head and serving as a supervisory signal source for the early feature layers) is used to extract the object categories in the scene. The categories are then mapped into high-dimensional embedding vectors to encode co-occurrence relationships, specifically the relationships between embedding vectors of different categories. Finally, average pooling is performed to generate a global scene representation, and the global features are transferred to all locations to provide scene-level context.
[0079] Specifically, the output of the co-occurrence branch is:
[0080] ;
[0081] Formula (3) is the output of the collinear branch, where It means traversing each category and taking the feature vector of this category Expanded to [B, C, H, W] format; for After average pooling and expansion to the spatial dimension, the co-occurrence features are obtained. represents the i-th category, Nis the total number of categories, Extract the feature vector after mapping the category ID from the detection result D; [ B, C, H, W ] is the standard dimensional format for deep learning models to process image data, where B represents the batch size, C Represents the number of channels, H and W Represents the height and width of the image respectively.
[0082] The output of the relation attention module is expressed as:
[0083] ;
[0084] is the output of the co-occurrence attention module, where Adjust parameters for branches to balance self-attention branches With collinear branches The degree of contribution to the output feature map.
[0085] See also Figure 2 , add a co-occurrence relationship attention module to the baseline network yolov8, where n represents the number of repeated bottleneck residuals; specifically, add a co-occurrence relationship attention module after the convolution at the end of the c2f module of the baseline network yolov8, and the value of n is 1, forming a c2f_CRA module.
[0086] The network model built based on the c2f_CRA module is as follows Figure 3 As shown in the figure, the input image first enters the backbone network, and gradually extracts deep semantic features through multiple convolutional layers alternating with C2f modules to generate feature maps of multiple resolutions from P1 to P5; in the neck network, feature maps of different levels are fused through a top-down path and a bottom-up path to obtain the P3 layer, P4 layer, and P5 layer after feature fusion; finally, the detection head detects it, and the loss function inside the detection head evaluates the quality of the detection.
[0087] 2) Design the marginal loss function of the model
[0088] Existing loss functions are primarily designed for datasets under normal, clear conditions. When applied to datasets under complex weather conditions, the model's performance significantly degrades. Analysis reveals that the design of existing loss functions is based on the assumption that the detector can fully extract the visual features of the image. However, in adverse weather conditions such as haze, the target's visual features, especially high-level features, are often obscured by ambient noise, preventing the detector from extracting sufficient visual features for accurate judgment. Therefore, this paper proposes a new loss function that fully utilizes the information extracted by existing detectors.
[0089] like Figure 4 As shown in the figure, the calculation flow chart of the edge-aware loss function (Edges Awear-IoU) proposed in this invention describes in detail the input and processing process of the loss function. The loss function requires three inputs:
[0090] The first input is the ground truth, which is the ground truth bounding box annotated in the dataset. This information is usually provided by public datasets. The mask extraction module extracts the mask from the ground truth bounding box and inputs it into the edge intersection-over-union loss function for calculation.
[0091] The second input is the original image of the dataset. After the shallow convolution processing of the model, the feature map of the middle layer is extracted and subjected to deep Sobel convolution processing (the Sobel convolution kernel designed according to the Sobel operator, and the convolution operation using it is called deep Sobel convolution); then the square root operation is performed to obtain the edge feature map, which is then input into the edge intersection-union ratio loss function.
[0092] The third input is the model’s final output prediction, or prediction. The mask extraction module extracts the mask of the predicted target bounding box from the prediction result and feeds it into the loss function.
[0093] The calculation formula of the edge intersection loss function is as follows:
[0094] ;
[0095] ;
[0096] Formula 5 is the expression of edge intersection and union ratio, is the mask of the ground-truth target bounding box, M To predict the mask of the target bounding box, This is the edge feature map obtained after deep Sobel convolution and square root. The intersection-over-union loss function calculates the ratio of the intersection and union of the true target bounding box and the predicted target bounding box. The edge intersection-over-union loss function calculates the overlap of the edge information within the true and predicted target bounding boxes on the edge feature map. Compared to the intersection-over-union loss function, it places greater emphasis on the role of edges in the loss function.
[0097] Formula 6 is the formula of edge perception loss function, where is the edge intersection-over-union loss, represents the Euclidean distance, b, w, and h represent the center point coordinates, width, and height of the bounding box, respectively. 、 、 Represent the center point coordinates, width and height of the predicted bounding box respectively, 、 、 Represent the diagonal length, width and height of the minimum circumscribed rectangle respectively, is the distance loss between the center point of the real box and the target box, is the width loss between the real box and the target box, is the height loss between the true box and the target box.
[0098] The edge-aware loss function leverages the advantages of the Efficient Intersection over Union (EIoU) loss function, taking into account the true difference in overlap area, center point distance, and length, width, and side length. By explicitly measuring the differences in three geometric factors within the bounding box—overlap area, center point, and side length—it optimizes the bounding box regression model. Furthermore, it increases the weight of edge information in the model's decision-making for complex weather conditions, achieving even higher performance.
[0099] The edge-aware loss function calculates a scalar value representing the average loss between all predicted boxes and the ground-truth boxes in the current batch. For example, if the batch size is 64, the loss takes a weighted average of the differences between the predicted boxes and the ground-truth boxes for these 64 samples, ultimately outputting a single value. Lower loss values indicate greater edge overlap, closer center points, and more consistent aspect ratios between the predicted and ground-truth boxes. During training, the model optimizes the loss through backpropagation, gradually bringing the predicted boxes closer to the position and size of the ground-truth boxes.
[0100] 3) Network model training
[0101] (1) Dataset selection: The dataset used by the network is the RTTS dataset, which includes 4,322 target detection data in real-world foggy scenes, including five categories: "person", "bus", "car", "motorbike", and "bike". Among them, 5,311 images were selected as the training set and 3,457 images were selected as the verification set for network training and testing.
[0102] (2) Select model evaluation indicators. In order to quantify the effect of the model and compare the advantages and disadvantages of different models, a reasonable evaluation indicator is needed. mAP is one of the most important evaluation indicators in the target detection algorithm. It measures the average performance of the model on different categories. It is obtained by calculating the average precision (AP) for each category and then averaging it. AP is the area under the Precision-Recall curve, which represents the classification effect of the model for each category. mAP takes into account the performance of the model on all categories and is therefore a comprehensive evaluation indicator. FPS, or frames per second, is an indicator used to measure the processing speed of the algorithm. It indicates how many frames of images the network can process (detect) per second, that is, the number of images that can be processed per second or the time required to process an image. The higher the FPS, the faster the model's inference speed, which is especially important for application scenarios that require real-time processing.
[0103] During the training process, the model optimizes the loss through backpropagation, so that the predicted box gradually approaches the position and size of the real box. The smaller the output loss value, the higher the edge overlap between the predicted box and the real box, the closer the center point, and the more consistent the aspect ratio.
[0104] (3) Conduct comparative experiments. Train both the basic model and the improved model on the RTTS dataset and record the experimental results.
[0105] Get the trained model for target detection.
[0106] The improved model heat map comparison Figure 5 、 Figure 6 As shown, Figure 5 is the visual saliency heatmap of the baseline model, Figure 6 The corresponding visualization results of the improved model presented in this paper are shown. Color-coded visual saliency analysis (warm colors represent high-attention areas) shows that while both the baseline and improved models can locate pedestrians and electric vehicles, their attention distribution differs significantly. The baseline model's salient regions exhibit significant spatial dispersion, with some high response values abnormally distributed in background areas unrelated to the target semantics (such as ground texture and building edges).
[0107] In contrast, the present invention achieves more precise attention focus through architectural optimization, concentrating saliency responses on key feature areas of the target, such as the wheels and front of electric vehicles. This physically interpretable thermal distribution demonstrates that the improved model, by enhancing feature selection capabilities, effectively suppresses background noise interference, thereby improving the reliability and robustness of target detection tasks.
[0108] We added our proposed edge-aware loss function and co-occurrence attention module (CRA) to the baseline YOLOv8 network and conducted a comparative evaluation against the baseline. We trained each model for 300 iterations on the RTTS dataset using an early stopping strategy. We selected map0.5, map0.5-0.95, and FPS as evaluation metrics. Table 1 shows the comparative test results.
[0109] Table 1 Comparison of experimental results
[0110]
[0111] It can be seen from the experimental results that adding EAIoU and co-occurrence attention separately improves the accuracy of the model, and adding EAIoU and co-occurrence attention at the same time also improves the accuracy of the model, proving that both modules play a certain role. This result also proves the effectiveness and advancement of the method designed by the present invention.
[0112] The above embodiments are preferred examples for implementing the present invention, and the present invention is not limited to the above embodiments. Any non-essential additions or replacements made by those skilled in the art based on the technical features of the present invention fall within the scope of protection of the present invention.
Claims
1. A detection method based on a haze image target detection model, characterized in that: The following operations are included: 1) Build an edge-aware loss and co-occurrence object detection model for haze images. This model includes a backbone network, a neck network, and a detection head. The neck network also has a relational attention module, which includes a self-attention branch and a co-occurrence branch. The loss function within the detection head is replaced with an edge-aware loss function. The self-attention branch calculates lightweight multi-head self-attention through a local window to capture local feature relationships; the co-occurrence relationship branch generates global co-occurrence features based on the detection results of the auxiliary detection head to provide scene-level context; the output of the relation attention module performs weighted addition of the output feature maps of the self-attention branch and the co-occurrence relationship branch; The co-occurrence relationship branch first uses an auxiliary detection head to extract the object categories in the scene, then maps the categories into high-dimensional embedding vectors to encode the co-occurrence relationships between the embedding vectors of different categories; then average pooling is performed to generate a global scene representation, and the global features are transferred to all locations to provide scene-level context; The edge-aware loss function includes: ; ; Among them, formula (5) is the expression of edge intersection-over-union ratio, and formula (6) is the edge perception loss function; is the mask of the ground-truth target bounding box, M To predict the mask of the target bounding box, It is the edge feature map obtained after deep Sobel convolution and square root; is the edge intersection-union loss, represents the Euclidean distance, Represent the center point coordinates, width and height of the bounding box respectively, Represent the center point coordinates, width and height of the predicted bounding box respectively, Represent the diagonal length, width and height of the minimum circumscribed rectangle respectively, is the distance loss between the center point of the real box and the target box, is the width loss between the real box and the target box, is the height loss between the real box and the target box; 2) Training the network model, selecting a dataset and model evaluation metrics. During training, the model optimizes the loss through backpropagation, gradually approximating the predicted box to the position and size of the ground-truth box. A smaller output loss value indicates a higher degree of edge overlap between the predicted box and the ground-truth box, a closer center point, and a more consistent aspect ratio. 3) Obtain the trained model for target detection.
2. The detection method based on the haze image target detection model according to claim 1, characterized in that: The self-attention branch first adds position encoding to the feature map, and then performs operations including convolution, partitioning by channel dimension, partitioning by window, and expansion by window on it in sequence to obtain the three elements of query, index, and content used to calculate self-attention; the three elements obtained are calculated through multi-head self-attention and then the output feature map is merged, and finally a residual connection is performed with the input feature map to capture local feature relationships.
3. The detection method based on the haze image target detection model according to claim 2, characterized in that: The self-attention branch is implemented based on equations (1) and (2): ; in, Input feature map for co-occurrence attention X The output after position encoding is represents 1×1 convolution, Represents operations that partition by channel dimension and partition by window, Represents the operation of expanding by window; ; in, From formula (1), represents the number of attention heads, is the activation function, T represents transpose, It represents the transformation of the outputs of different heads to achieve uniformity. Indicates that the calculation results previously divided by channel dimension and by window are folded and restored.
4. The detection method based on the haze image target detection model according to claim 1, characterized in that: The co-occurrence relationship branch also learns the relationship between embedding vectors of different categories through co-occurrence patterns in training data to achieve higher prediction accuracy.
5. The detection method based on the haze image target detection model according to claim 4, characterized in that: The output of the co-occurrence relationship branch is: ; in, for After average pooling and expansion to the spatial dimension, the co-occurrence features are obtained. represents the i-th category, N is the total number of categories, Extract the feature vector after mapping the category ID from the detection result D; [ B, C, H, W ] is the standard dimensional format for deep learning models to process image data, where B represents the batch size, C Represents the number of channels, H and W Represents the height and width of the image respectively.
6. The detection method based on the haze image target detection model according to claim 4, characterized in that: The output of the relation attention module is expressed as: ; is the output of the co-occurrence attention module, where Adjust the parameters for the branches to balance the output of the self-attention branch With collinear branch output The degree of contribution to the output feature map.
7. The detection method based on the haze image target detection model according to claim 1, characterized in that: The backbone network, neck network and detection head adopt the baseline network yolov8, and the co-occurrence relationship attention module is added after the convolution at the end of the c2f module of the baseline network yolov8; In the constructed model, the input image first enters the backbone network, and then gradually extracts deep semantic features through multiple convolutional layers alternating with C2f modules to generate feature maps of different resolutions from P1 to P5. In the neck network, feature maps at different levels are fused through a top-down path and a bottom-up path to obtain the P3, P4, and P5 layers after feature fusion; finally, the detection head detects them, and the loss function inside the detection head evaluates the quality of the detection.
8. The detection method based on the haze image target detection model according to claim 1, characterized in that: The edge-aware loss function requires three inputs: The first input is the ground truth bounding box annotated in the dataset. The mask extraction module extracts the mask from the ground truth bounding box and inputs it into the edge intersection-over-union loss function for calculation. The second input is the original image of the dataset. After the shallow convolution processing of the model, the feature map of the middle layer is extracted and subjected to deep Sobel convolution processing. Then, the square root operation is performed to obtain the edge feature map, which is then input into the edge intersection-to-union loss function. The third input is the output prediction result of the model. The mask of the predicted target bounding box is extracted from the prediction result through the mask extraction module and input into the loss function.
Citation Information
Patent Citations
Edge-guided multi-attention RGBD underwater salient target detection method
CN117095277A
Pixel-level mask assisted camouflage target detection method based on edge prior guidance
CN119251812A