Improved Yolov10-oriented target detection fusion method
By introducing the context fusion CFM module into the neck network of YOLOv10, the limitations of YOLOv10 in complex scenarios and multi-object detection are solved, and more efficient feature fusion and adaptive adjustment are achieved, which significantly improves the accuracy and robustness of object detection.
Patent Information
- Application Number
- CN202510198951.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2045-02-24
AI Technical Summary
YOLOv10 has limitations in dealing with the detection of complex scenarios, different scales and multiple targets, resulting in poor detection performance of small or low-contrast targets, and lacks a mechanism for dynamically adjusting feature contributions, making it impossible to effectively integrate global and local information.
Four context fusion CFM modules are introduced into the neck network. The CFM module includes a channel adjustment convolution module, a feature splicing module, a CBAM attention module, a weighted feature recombination module and an output feature generation module. Through the combination of these modules, the fusion weight of each scale feature is dynamically generated, and the contribution of the feature is adjusted adaptively.
It significantly improves the accuracy of object detection, enhances the robustness of the model, suppresses the influence of redundant features, and can better handle object detection tasks of different scales and complex backgrounds.
Smart Images

Figure CN119723272A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of computer vision and target detection, and in particular to a target detection fusion method for improving Yolov10. Background Art
[0002] Feature fusion is an important part of the target detection algorithm. It improves the performance of target detection by integrating feature information from different levels and scales. Most target detection algorithms use simple weighted summation, splicing or layer-by-layer superposition to perform feature fusion. These methods cannot fully capture the complex relationship between multiple layers of features, resulting in limited feature fusion effects.
[0003] Existing feature fusion methods, such as feature pyramid network (FPN) and path aggregation network (PANet), can effectively fuse multi-scale features, but there are still some shortcomings: simple feature fusion may lead to information redundancy or conflict between features of different scales, reducing the discriminative ability of features. Traditional fusion methods are usually susceptible to complex background interference, especially when the contrast between the target and the background is low, the target edge is blurred, or the background texture is complex. In the target detection task, the location and category of the target often depend on contextual information. The effective fusion of contextual information can help the model better understand the background, but many feature fusion methods fail to fully integrate global contextual information and only focus on local features. However, the design of YOLOv10 is biased towards local feature extraction, lacks an effective contextual information integration strategy, cannot be adaptively adjusted according to the characteristics of the input image, fails to effectively integrate global and local information, and limits the generalization ability of the model. Moreover, the feature fusion strategy of YOLOv10 is usually static and fails to dynamically adjust the contribution of different features. YOLOv10 lacks this dynamic adaptation mechanism and cannot flexibly respond to changes in different scenes.
[0004] The existing Yolov10 algorithm still has certain limitations when dealing with complex scenes, different scales and multiple targets, resulting in unsatisfactory detection performance for small targets or low-contrast targets. In complex scenes, especially when the target scale varies greatly and is severely occluded, its detection performance still has room for improvement.
[0005] Therefore, the present invention provides a target detection fusion method for improving Yolov10 to solve the above problems. Summary of the invention
[0006] In view of the shortcomings of the prior art, the present invention develops a target detection fusion method for improving Yolov10. The main purpose of the present invention is to better handle targets of different scales and diversity, thereby improving the robustness of the model to complex backgrounds and further improving the detection effect of Yolov10.
[0007] The technical solution of the present invention to solve the technical problem is a target detection fusion method for improving Yolov10, comprising the following steps: S1. Select the data in the DeepPCB dataset in the public intelligent manufacturing workshop to construct a dataset, and then preprocess the data in the dataset to obtain a preprocessed dataset; S2. Enhance the preprocessed data set, build a target recognition network model based on the lightweight Yolov10n network, and improve the Yolov10n network. The improved Yolov10n network includes an input end, a backbone network, a neck network, and an output end. The neck network introduces four context fusion CFM modules. The CFM module includes a channel adjustment convolution module, a feature concatenation Concat module, an attention module CBAM, a weighted feature reorganization module and an output feature generation module; S3. Input the image data in the preprocessed data set into the improved target recognition network model to obtain the final detection result.
[0008] S1 is as follows: S1.1. Constructing the dataset: The DeepPCB dataset is an existing PCB circuit board defect dataset. The DeepPCB dataset contains 1,500 sets of DeepPCB images. Each set of images contains a defect-free template image and a corresponding test image. The dataset is constructed based on the existing DeepPCB dataset. S1.2. Preprocess the data in the dataset, remove redundant information in the dataset, verify the accuracy of the original image data in the dataset, and then perform image enhancement and bounding box enhancement on the image data, and flip it to obtain the preprocessed dataset. , , dataset Included images, Representation dataset Middle A preprocessed DeepPCB image. ; Specifically, the getRectSubPix function in the OpenCV library in Python is used for cropping, the GaussianBlur function in the OpenCV library in Python is used for smoothing the image, and the flip function in the OpenCV library in Python is used for vertical flipping with the coordinate axis set to 0.
[0009] S2 is as follows: Build a target recognition network model. The target recognition network model is essentially a YOLOv10 network. When training the target recognition network model, set the number of iterations to 300, the learning rate to 0.0001, the learning speed to decay to half of the original speed every 20 iterations, and the initial learning rate to , the batch size is set to 16; Improve the lightweight network Yolov10n. The improved lightweight network Yolov10n is divided into four parts: input end, backbone network, neck network and output end; The input includes Mosaic data enhancement, adaptive anchor boxes, and adaptive image scaling; The backbone network includes four convolution modules Conv, four feature extraction layer modules C2f, two downsampling modules SCDown and one adaptive information fusion integration module AIFI; The neck network is located between the backbone network and the output end, and includes two upsampling modules Upsample, four context fusion modules CFM, three feature extraction layer modules C2f, a convolution module Conv, a context perception module C2fCIB and a downsampling module SCDown; The output end includes a detection head module v10Detect; Among them, the convolution module Conv includes a 3 3 convolution kernels of two-dimensional convolution Conv2d, a batch normalization layer BatchNormal and activation function SiLU, the padding of the convolution kernel is 1, and the stride is 1; The context fusion CFM module, which includes a channel adjustment convolution module, a feature concatenation Concat module, a CBAM attention module, a weighted feature reorganization module and an output feature generation module.
[0010] S3 is as follows: According to the improved Yolov10n target detection network model, the preprocessed dataset Process the data in the dataset Image data in Input into the target detection network model after improving Yolov10n, passing through the input end, backbone network, neck network and output end in sequence; S3.1. Operation process at the input end: Dataset The data is input to the input end, and the data set is successively enhanced by the Mosaic data enhancement module, the adaptive anchor frame module, and the adaptive image scaling module. Adjust the data in the , Representation dataset Middle Adjusted DeepPCB image; The specific steps are as follows: The data first enters the Mosaic data enhancement module, which extracts For each image Randomly select 3 images and stitch them together to make the images The selected 3 images are cropped and scaled to fit The stitching operation stitches the 4 processed images into a complete image in a 2×2 layout, updates the information of the complete image according to the stitching position and scaling ratio, and obtains a complete image dataset. The updated information includes the target box and category label. Then, the images in the complete image dataset are input into the adaptive anchor box module, and the width and height distribution of the annotation boxes of all complete images are counted to generate a histogram of the aspect ratio. Then, the aspect ratio of the target box is adjusted based on the aspect ratio of the target box. Clustering, generation Anchor frames, each of which has a size of cluster center, represent the main size distribution of the target in the complete image dataset. The anchor frame parameters are updated according to the clustering results, and the updated anchor frame size is aligned with the target frame. Finally, the complete image with updated information enters the adaptive image scaling module to obtain the image The original width and height , adjust the complete image and generate the adjusted DeepPCB image , and then get the adjusted data set , Representation dataset Middle The adjusted DeepPCB image.
[0011] S3.2, Operation process in the backbone network: The backbone network includes four convolution modules Conv, four feature extraction layer modules C2f, two downsampling modules SCDown and one module AIFI; The four convolution modules Conv are the first convolution module , the second convolutional module , the third convolution module And the fourth convolution module , the four feature extraction layers C2f are the first feature extraction layer , the second feature extraction layer , the third feature extraction layer and the fourth feature extraction layer , the two downsampling SCDown modules include the first downsampling layer and the second downsampling layer ; The dataset The image data is input into the backbone network. First, the image is read through the imread function in the OpenCV library in Python, and then the read image is Input to the first convolution module In the example, the number of output channels increases from 3 to 64, and the feature map is obtained. , feature map After the second convolution module , the number of output channels increases from 64 to 128, and the feature map is obtained , then the feature map After the first feature extraction layer , get the feature map , feature map After the third convolution module , the number of output channels increases from 128 to 256, and the feature map is obtained , feature map After the second feature extraction layer , get the feature map , feature map After the first downsampling layer , the number of output channels increases from 256 to 512, and the feature map is obtained , feature map After the third feature extraction layer , and get a feature map with an output channel number of 512 ,Feature map After the second downsampling layer , the number of output channels increases from 512 to 1024, and the feature map is obtained , feature map After the fourth feature extraction layer , and get a feature map with an output channel number of 1024 , feature map Then through the fourth convolution module Feature extraction is performed, and the output channels are reduced from 1024 to 512. The extracted features are input into the AIFI module, and the high-level semantic features are interacted within the scale through the AIFI module to obtain a feature map with an output channel number of 512 .
[0012] S3.3. Operation process in the network: The neck network is located between the backbone network and the output end, and includes two upsampling modules Upsample, four context fusion modules CFM, three feature extraction layer modules C2f, one convolution module Conv, one context perception module C2fCIB, and one downsampling module SCDown; Among them, the two upsampling modules Upsample are the first upsampling module and the second upsampling module The four context fusion modules CFM are the first context fusion module , Second context fusion module , the third context fusion module and the fourth context fusion module , the three feature extraction layer modules C2f include the fifth feature extraction layer , the sixth feature extraction layer and the seventh feature extraction layer , the convolution module Conv includes the fifth convolution module , the context-aware module C2fCIB includes the first context-aware module The downsampling module SCDown includes the third downsampling layer ; The final output feature map of the Backbone network Input to the Neck network, feature map First, through the first upsampling module Upsampling is performed, the feature map size is doubled, and the output channel number is 512. , the feature map With feature map Through the first context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , feature map After the fifth feature extraction layer , the output channel number is 512 feature map , feature map After the second upsampling module , the output channel number is 512 feature map , feature map With feature map Through the second context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , the feature map After the sixth feature extraction layer , the output channel number is 256 feature maps , the feature map Input to the fifth convolution module , the output channel is 256 feature maps , the feature map and feature map Through the third context fusion module Fusion splicing is performed to output a feature map with 768 channels , feature map After the seventh feature extraction layer , the output channel number is 768 feature map , feature map After the third downsampling layer , the output channel number is 512 feature map , the feature map and feature map Through the fourth context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , feature map Through the first context-aware module , the output channel number is 1024 feature map .
[0013] S3.4, the operation process in the output end; Feature Map After the v10Detect detection module performs target detection at three different spatial resolutions, the feature map The spatial resolution of each scale is processed independently and then input into a dedicated convolutional layer for further feature extraction. Using a convolution with a kernel size of 1×1, the feature map of each scale is mapped to the number of channels required for detection. , ,in and Represents the coordinates of the target box, and represents the width and height of each scale feature map, Indicates confidence, Represents the number of categories. Before prediction, the features of each scale are fused in pairs. After each scale feature map is processed, two branches are formed, namely the classification branch and the regression branch. The classification branch represents the category prediction of the target and outputs the confidence of the category. The regression branch represents the regression of the coordinates of the target box, predicts the position and size of the target box, and outputs each scale feature map. The output resolution of the three scales is , and , and Represents the feature maps The height and width of the grid are calculated, and finally the feature maps of the three scales are merged to generate a complete detection result. The output of each feature map includes the target box position, confidence, and category probability.
[0014] The CFM module workflow is as follows: (1) The CFM module receives two feature maps, which are low-resolution and high-semantic feature maps. and high-resolution, low-semantic feature maps , , , represents the batch size, , and Represents the feature maps The number of channels, height and width, , and Represents the feature maps The number of channels, height and width are then adjusted by the channel convolution module Adjusting feature maps The number of channels of the feature map The consistency of the channel alignment feature map and feature map The concatenation is performed along the channel dimension through the feature concatenation module Concat. , get the splicing features , before performing the splicing operation, determine whether there is and ,like or , then the feature map is interpolated or down-sampled Adjust the resolution; (2) Then the splicing features Input to the CBAM module, and the concatenated features are processed by the channel attention module of the CBAM module. Perform a global pooling operation in the spatial dimension. The global pooling operation in the spatial dimension includes the global average pooling operation GAP and the global maximum pooling operation GMP. The calculation formula is as follows: , , in, and Respectively represent the splicing features The height and width of Indicates height The index of Indicates width The index of Indicates the maximum height and width. Represents splicing features The result of the global average pooling operation GAP is: Represents splicing features The result of performing the global maximum pooling operation GMP; Then input the results of GAP and GMP into the shared two-layer fully connected layer MLP to generate channel attention weights , the calculation formula is as follows: , in, represents the Sigmoid activation function used for normalization, represents a fully connected layer; Then the concatenated features are processed by the spatial attention module of the CBAM module. Perform the maximum pooling operation on the channel dimension and average pooling operation , the calculation formula is as follows: , , in, Represents splicing features The number of channels, Indicates the number of channels The index of Represents splicing features Perform the maximum pooling operation As a result, Represents splicing features Perform average pooling operation Result; Then The results and The results are concatenated, and after two-dimensional convolution and normalization operations, the spatial attention weight is obtained. , the calculation formula is as follows: , According to the spatial attention weight and channel attention weights Calculate the enhanced attention feature map of the final output of the CBAM module , the calculation formula is as follows: ; (3) Enhanced attention feature map Input to the weighted feature reorganization module for weighted feature reorganization. The weighted feature reorganization module is based on the feature map. and feature map The weights will enhance the attention feature map Split into feature maps and feature map , and then the feature map With feature map Add item by item to get the feature map , the feature map With feature map Add item by item to get the feature map ; (4) Feature map and feature map Input to the output feature generation module, concatenate the two features, and obtain the feature map of the final output of the CFM module , the calculation formula is as follows: , in, Represents a concatenation operation.
[0015] The effects provided in the content of the invention are only the effects of the embodiments, rather than all the effects of the invention. The above technical solution has the following advantages or beneficial effects: The present invention uses the multi-scale feature map extracted by Yolov10n as input, and dynamically generates the fusion weight of each scale feature through operations such as convolution, activation function and attention mechanism, so as to adaptively adjust the multi-scale target and complex background according to the content of the input image. Finally, the weighted fused feature map is input to the detection head of Yolov10n for target detection, which can significantly improve the accuracy of target detection, enhance the robustness of the model, and suppress the influence of redundant features. The present invention solves the problem that Yolov10n cannot effectively distinguish between targets and backgrounds and cannot dynamically adjust context information in some scenes, and proposes improvements and enhancements to the context fusion module CFM. The core goal of the CFM module is to fuse feature maps from multiple resolutions and achieve efficient feature enhancement through the guidance of context information. This fusion mechanism can integrate high-semantic low-resolution features and high-resolution low-semantic features. The low-resolution feature map contains more extensive context and semantic information, which is suitable for extracting the category and global relationship of the target. The high-resolution feature map contains more details and local feature information, which is suitable for capturing local features such as the boundary, details, and shape of the target. The low-resolution high-level feature map emphasizes the global position, category, and large-scale background information of the target in the image, which helps to provide contextual understanding of the scene. The high-resolution low-level feature map contains fine local information of the image, such as edges, textures, etc., which helps to more accurately locate small targets and targets with complex shapes, so that the model has both spatial detail information and global semantic information in the target detection task, thereby improving the detection accuracy. The CFM module guides the fusion so that the high-semantic features supplement the semantic information of the low-semantic features, and the low-resolution features absorb the detail information of the high-resolution features. The CFM module also introduces the CBAM attention mechanism to achieve efficient fusion. Through the CBAM attention mechanism, the module can capture and utilize important contextual information in the feature fusion process, thereby enhancing the effectiveness of feature representation and effectively guiding the model to learn the information of the detection target, thereby improving the detection accuracy of the model. Through the weighted feature reorganization operation, the module can enhance important features while suppressing unimportant features, thereby improving the discriminative ability of feature maps.
[0016] In summary, the present invention effectively improves the target detection effect, the model can more accurately locate information, and enhance the flow of information. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0018] Figure 1 It is a schematic diagram of the method flow of the present invention.
[0019] Figure 2 It is the detection result diagram of the present invention. DETAILED DESCRIPTION
[0020] In order to clearly illustrate the technical features of the present invention, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings. The following disclosure provides many different embodiments or examples for implementing different structures of the present invention. In order to simplify the disclosure of the present invention, the components and settings of specific examples are described below.
[0021] Example 1 A target detection fusion method for improving Yolov10 includes the following steps: S1. Select the data in the DeepPCB dataset in the public intelligent manufacturing workshop to construct a dataset, and then preprocess the data in the dataset to obtain a preprocessed dataset; S2. Enhance the preprocessed data set, build a target recognition network model based on the lightweight Yolov10n network, and improve the Yolov10n network. The improved Yolov10n network includes an input end, a backbone network, a neck network, and an output end. The neck network introduces four context fusion CFM modules. The CFM module includes a channel adjustment convolution module, a feature concatenation Concat module, an attention module CBAM, a weighted feature reorganization module and an output feature generation module; The Yolov10n network is a variant of the Yolov10 network; S3. Input the image data in the preprocessed data set into the improved target recognition network model to obtain the final detection result.
[0022] S1 is as follows: S1.1. Constructing the dataset: The DeepPCB dataset is an existing PCB circuit board defect dataset. The DeepPCB dataset contains 1,500 sets of DeepPCB images. Each set of images contains a defect-free template image and a corresponding test image. The dataset is constructed based on the existing DeepPCB dataset. S1.2. Preprocess the data in the dataset, remove redundant information in the dataset, verify the accuracy of the original image data in the dataset, and then perform image enhancement and bounding box enhancement on the image data, and flip it to obtain the preprocessed dataset. , , dataset Included images, Representation dataset Middle A preprocessed DeepPCB image. ; Specifically, the getRectSubPix function in the OpenCV library in Python is used for cropping, the GaussianBlur function in the OpenCV library in Python is used for smoothing the image, and the flip function in the OpenCV library in Python is used for vertical flipping with the coordinate axis set to 0.
[0023] S2 is as follows: Build a target recognition network model. The target recognition network model is essentially a YOLOv10 network. When training the target recognition network model, set the number of iterations to 300, the learning rate to 0.0001, the learning speed to decay to half of the original speed every 20 iterations, and the initial learning rate to , the batch size is set to 16; Improve the lightweight network Yolov10n. The improved lightweight network Yolov10n is divided into four parts: input end, backbone network, neck network and output end; The input includes Mosaic data enhancement, adaptive anchor boxes, and adaptive image scaling; The backbone network includes four convolution modules Conv, four feature extraction layer modules C2f, two downsampling modules SCDown and one adaptive information fusion integration module AIFI; The neck network is located between the backbone network and the output end, and includes two upsampling modules Upsample, four context fusion modules CFM, three feature extraction layer modules C2f, a convolution module Conv, a context perception module C2fCIB and a downsampling module SCDown; The output end includes a detection head module v10Detect; Among them, the convolution module Conv includes a 3 3 convolution kernels of two-dimensional convolution Conv2d, a batch normalization layer BatchNormal and activation function SiLU, the padding of the convolution kernel is 1, and the stride is 1; The context fusion CFM module, which includes a channel adjustment convolution module, a feature concatenation Concat module, a CBAM attention module, a weighted feature reorganization module and an output feature generation module.
[0024] S3 is as follows: According to the improved Yolov10n target detection network model, the preprocessed dataset Process the data in the dataset Image data in Input into the target detection network model after improving Yolov10n, passing through the input end, backbone network, neck network and output end in sequence; S3.1. Operation process at the input end: Dataset The data is input to the input end, and the data set is successively enhanced by the Mosaic data enhancement module, the adaptive anchor frame module, and the adaptive image scaling module. Adjust the data in the , Representation dataset Middle Adjusted DeepPCB image; The specific steps are as follows: The data first enters the Mosaic data enhancement module, which extracts For each image Randomly select 3 images and stitch them together to make the images The selected 3 images are cropped and scaled to fit The stitching operation stitches the 4 processed images into a complete image in a 2×2 layout, updates the information of the complete image according to the stitching position and scaling ratio, and obtains a complete image dataset. The updated information includes the target box and category label. Then, the images in the complete image dataset are input into the adaptive anchor box module, and the width and height distribution of the annotation boxes of all complete images are counted to generate a histogram of the aspect ratio. Then, the aspect ratio of the target box is adjusted based on the aspect ratio of the target box. Clustering, generation Anchor frames, each of which has a size of cluster center, represent the main size distribution of the target in the complete image dataset. The anchor frame parameters are updated according to the clustering results, and the updated anchor frame size is aligned with the target frame. Finally, the complete image with updated information enters the adaptive image scaling module to obtain the image The original width and height , adjust the complete image and generate the adjusted DeepPCB image , and then get the adjusted data set , Representation dataset Middle The adjusted DeepPCB image.
[0025] S3.2, Operation process in the backbone network: The backbone network includes four convolution modules Conv, four feature extraction layer modules C2f, two downsampling modules SCDown and one module AIFI; The four convolution modules Conv are the first convolution module , the second convolutional module , the third convolution module And the fourth convolution module , the four feature extraction layers C2f are the first feature extraction layer , the second feature extraction layer , the third feature extraction layer and the fourth feature extraction layer , the two downsampling SCDown modules include the first downsampling layer and the second downsampling layer ; The dataset The image data is input into the backbone network. First, the image is read through the imread function in the OpenCV library in Python, and then the read image is Input to the first convolution module In the example, the number of output channels increases from 3 to 64, and the feature map is obtained. , feature map After the second convolution module , the number of output channels increases from 64 to 128, and the feature map is obtained , then the feature map After the first feature extraction layer , get the feature map , feature map After the third convolution module , the number of output channels increases from 128 to 256, and the feature map is obtained , feature map After the second feature extraction layer , get the feature map , feature map After the first downsampling layer , the number of output channels increases from 256 to 512, and the feature map is obtained , feature map After the third feature extraction layer , and get a feature map with an output channel number of 512 ,Feature map After the second downsampling layer , the number of output channels increases from 512 to 1024, and the feature map is obtained , feature map After the fourth feature extraction layer , and get a feature map with an output channel number of 1024 , feature map Then through the fourth convolution module Feature extraction is performed, and the output channels are reduced from 1024 to 512. The extracted features are input into the AIFI module, and the high-level semantic features are interacted within the scale through the AIFI module to obtain a feature map with an output channel number of 512 .
[0026] S3.3. Operation process in the network: The neck network is located between the backbone network and the output end, and includes two upsampling modules Upsample, four context fusion modules CFM, three feature extraction layer modules C2f, one convolution module Conv, one context perception module C2fCIB, and one downsampling module SCDown; Among them, the two upsampling modules Upsample are the first upsampling module and the second upsampling module The four context fusion modules CFM are the first context fusion module , Second context fusion module , the third context fusion module and the fourth context fusion module , the three feature extraction layer modules C2f include the fifth feature extraction layer , the sixth feature extraction layer and the seventh feature extraction layer , the convolution module Conv includes the fifth convolution module , the context-aware module C2fCIB includes the first context-aware module The downsampling module SCDown includes the third downsampling layer ; The final output feature map of the Backbone network Input to the Neck network, feature map First, through the first upsampling module Upsampling is performed, the feature map size is doubled, and the output channel number is 512. , the feature map With feature map Through the first context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , feature map After the fifth feature extraction layer , the output channel number is 512 feature map , feature map After the second upsampling module , the output channel number is 512 feature map , feature map With feature map Through the second context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , the feature map After the sixth feature extraction layer , the output channel number is 256 feature maps , the feature map Input to the fifth convolution module , the output channel is 256 feature maps , the feature map and feature map Through the third context fusion module Fusion splicing is performed to output a feature map with 768 channels , feature map After the seventh feature extraction layer , the output channel number is 768 feature map , feature map After the third downsampling layer , the output channel number is 512 feature map , the feature map and feature map Through the fourth context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , feature map Through the first context-aware module , the output channel number is 1024 feature map .
[0027] S3.4, the operation process in the output end; Feature Map After the v10Detect detection module performs target detection at three different spatial resolutions, the feature map The spatial resolution of each scale is processed independently and then input into a dedicated convolutional layer for further feature extraction. Using a convolution with a kernel size of 1×1, the feature map of each scale is mapped to the number of channels required for detection. , ,in and Represents the coordinates of the target box, and represents the width and height of each scale feature map, Indicates confidence, Represents the number of categories. Before prediction, the features of each scale are fused in pairs. After each scale feature map is processed, two branches are formed, namely the classification branch and the regression branch. The classification branch represents the category prediction of the target and outputs the confidence of the category. The regression branch represents the regression of the coordinates of the target box, predicts the position and size of the target box, and outputs each scale feature map. The output resolution of the three scales is , and , and Represents the feature maps The height and width of the grid are calculated, and finally the feature maps of the three scales are merged to generate a complete detection result. The output of each feature map includes the target box position, confidence, and category probability.
[0028] The CFM module workflow is as follows: (1) The CFM module receives two feature maps, which are low-resolution and high-semantic feature maps. and high-resolution, low-semantic feature maps , , , represents the batch size, , and Represents the feature maps The number of channels, height and width, , and Represents the feature maps The number of channels, height and width are then adjusted by the channel convolution module Adjusting feature maps The number of channels of the feature map The consistency of the channel alignment feature map and feature map The concatenation is performed along the channel dimension through the feature concatenation module Concat. , get the splicing features , before performing the splicing operation, determine whether there is and ,like or , then the feature map is interpolated or down-sampled Adjust the resolution; By and By fusing the semantic information of high-level features and the detailed information of low-level features, the model can be improved in terms of target detection performance. It provides semantic information to help understand the category and background environment of the target, and also provides semantic support for the background context. It provides detailed information to help accurately locate the boundaries and contours of the target. At the same time, it enhances the ability to detect small targets. By fusing the upper and lower layer features, the model can more comprehensively understand the environment where the target is located and improve its robustness to complex scenes. In complex backgrounds, semantic information helps separate the target from the background. When detecting small targets with blurred edges or low resolution, detail information helps improve accuracy. Its significance lies in the comprehensive use of the complementary advantages of the two types of feature maps, thereby improving the accuracy and robustness of target detection. High semantic, low resolution feature map ( ) Role: After deep convolution processing, it contains global context information and higher-level semantic features, which can enrich the semantic information and is more suitable for identifying complex backgrounds of scenes. At the same time, low resolution is selected because the receptive field of each pixel is large, which can capture a larger range of global information, which is very important for detecting large targets or providing an overall semantic understanding of the scene background; Low semantic, high-resolution feature maps ( ) Role: Rich in detail information, including more spatial details and edge information, able to capture low-level features such as the shape and contour of the target, more conducive to the detection of small and fine-grained targets. High resolution is selected because the receptive field of each pixel is small, but it can represent more refined local features, and is more suitable for detecting small targets and complex detail structures; (2) Then the splicing features Input to the CBAM module, and the concatenated features are processed by the channel attention module of the CBAM module. Perform a global pooling operation in the spatial dimension. The global pooling operation in the spatial dimension includes the global average pooling operation GAP and the global maximum pooling operation GMP. The calculation formula is as follows: , , in, and Respectively represent the splicing features The height and width of Indicates height The index of Indicates width The index of Indicates the maximum height and width. Represents splicing features The result of the global average pooling operation GAP is: Represents splicing features The result of performing the global maximum pooling operation GMP; Then input the results of GAP and GMP into the shared two-layer fully connected layer MLP to generate channel attention weights , the calculation formula is as follows: , in, represents the Sigmoid activation function used for normalization, represents a fully connected layer; Then the concatenated features are processed by the spatial attention module of the CBAM module. Perform the maximum pooling operation on the channel dimension and average pooling operation , the calculation formula is as follows: , , in, Represents splicing features The number of channels, Indicates the number of channels The index of Represents splicing features Perform the maximum pooling operation As a result, Represents splicing features Perform average pooling operation Result; Then The results and The results are concatenated, and after two-dimensional convolution and normalization operations, the spatial attention weight is obtained. , the calculation formula is as follows: , According to the spatial attention weight and channel attention weights Calculate the enhanced attention feature map of the final output of the CBAM module , the calculation formula is as follows: ; (3) Enhanced attention feature map Input to the weighted feature reorganization module for weighted feature reorganization. The weighted feature reorganization module is based on the feature map. and feature map The weights will enhance the attention feature map Split into feature maps and feature map , and then the feature map With feature map Add item by item to get the feature map , the feature map With feature map Add item by item to get the feature map ; (4) Feature map and feature map Input to the output feature generation module, concatenate the two features, and obtain the feature map of the final output of the CFM module , the calculation formula is as follows: , in, Represents a concatenation operation.
[0029] The principle of feature map fusion is: In terms of the complementarity between semantic information and detail information, high semantic features and low-resolution feature maps Provides a wide range of semantic information and background information of the image, low semantic features, high-resolution feature maps It provides detailed information and boundary information in the image. By fusing these two types of information, the model can not only understand the global background and target classification of the image, but also locate the specific boundaries and details of the target. This enables the model to accurately identify and locate the target under the guidance of the global context. In terms of fusion at feature scale, low-resolution feature maps The global information captured by the larger receptive field needs to be combined with the high-resolution feature map Combine the local information of the low-resolution feature map Due to the coarser sampling, there is usually a stronger global semantic perception, while the high-resolution feature map It can capture local details of the image. In cross-scale feature fusion, the fusion of low-resolution and high-resolution features can combine global semantics and local fine structures, so that the model can take into account both the global background and local details of the target when performing target detection; In terms of the balance of information flow, by introducing the fusion of upper and lower layer features in the network and effectively fusing feature maps of different scales together, the flow of global information and local information can be made more balanced. The advantages of this balance are: providing strong global understanding capabilities for large targets and backgrounds, and more accurate local detection capabilities for small targets and details.
[0030] Selecting low-resolution, high-semantic feature maps and high-resolution, low-semantic feature maps for fusion is actually fusing two different levels of feature information, which represent global semantic information and local detail information respectively. One is from the low-resolution feature map. Usually, it can capture a wide range of contextual information of the image. These feature maps have strong semantic abstraction capabilities after passing through deeper network layers, and can recognize and understand the relationship between large objects, background information, and objects. Low-resolution feature maps Covering a wider area in the receptive field of each pixel, which makes it more sensitive to large objects, environmental information and context in the image. Another is from high-resolution feature maps Contains more details and local information, such as the edges, textures, shapes, and small features of the target. These feature maps are sparse and capture local details, but the semantic information is weak. The receptive field of each pixel only covers a small area. It is more sensitive to the detailed structure of the image and is suitable for capturing small targets or slight differences in the image.
[0031] The significance of choosing to combine these two feature maps is that the low-resolution feature map provides a strong global understanding and can identify the relationship between large targets, background environment and targets in the image, while the high-resolution feature map can capture small targets and local details, helping the model to accurately locate target boundaries and subtle features. By combining these two types of feature maps, the model can understand the global context and local details of the image at the same time, providing a more comprehensive and accurate target detection capability. More compatible with large and small targets: Low-resolution feature maps can help identify and process a wide range of target information, so they are suitable for detecting large targets. High-resolution feature maps can better capture small targets, especially when the background is complex or the small target is partially occluded, providing finer details.
[0032] Advantages of this: First, it can enhance the accuracy of target detection. By combining low-resolution semantic feature maps and high-resolution detail feature maps, the model can integrate information at multiple levels and avoid the information loss that may be caused by relying solely on features at a certain level. For example, low-resolution feature maps help locate large targets, while high-resolution feature maps ensure the precise positioning of small targets. Second, it can improve the detection capability of small and fine-grained targets. High-resolution feature maps have an advantage in small target detection because they can capture more detail information and avoid detail loss when processing complex scenes. By combining this small target detection capability with global semantic information, the CFM module can improve the positioning accuracy of small targets and enhance the robustness of the model. Low-resolution feature maps It can help the model better understand the background information and distinguish the difference between the target and the background, thereby improving the ability to handle complex backgrounds; high-resolution feature maps It can effectively preserve the details in the image, help the model avoid occlusion problems or the influence of blurred targets, and increase the robustness of the model to complex scenes; finally, it can improve the efficiency of training and reasoning, and the low-resolution feature map The computational complexity is relatively small, and it can provide rich semantic information without increasing the computational burden; by combining with high-resolution feature maps The model can balance computational efficiency and accuracy. Feature map fusion can maintain computational efficiency through weighted and splicing operations, and effectively utilize the advantages of low-resolution and high-resolution feature maps.
[0033] Implementation of the fusion process: First, for the feature map input, the input feature map and They are low-resolution, high-semantic feature maps and high-resolution, low-semantic feature maps, and then feature map fusion is performed. Usually, the low-resolution feature map and high-resolution feature maps The fusion will be performed through weighted fusion operation. First, the feature map is upsampled or downsampled as needed to ensure that the spatial resolution of the two is consistent. After aligning the spatial dimensions, the two types of features are combined using weighted fusion operation to obtain a richer feature representation. Secondly, a convolution operation is performed to perform a 1×1 convolution operation on the fused feature map, adjust the number of channels of the feature map, and further extract more refined features. This step usually helps to reduce redundant information. The 1×1 convolution can reduce the number of channels of the feature map, avoid information redundancy, and enhance the feature expression ability. More representative features are extracted through convolution, so that the model can better perform target detection. Then a branch operation is performed. Specifically, the classification head outputs the category and category confidence of the target, and the regression head outputs the coordinates x, y, w, h of the target box. Finally, the fusion is output. After all scales are processed, the output results are finally integrated through multi-scale fusion to obtain the final target detection result.
[0034] Example 2 In order to demonstrate the beneficial effects of the present invention, the method of the present invention is compared with the existing method. First, an image to be detected is selected, and an image containing annotation information is selected from the existing DeepPCB dataset as the image to be detected. Then, these annotation files are parsed and converted into annotations in the YOLO format. The YOLO format usually includes the number of the target category and the relative coordinates of the target box. In order to improve the generalization ability of the model, some common enhancement operations can be performed on the image, such as flipping, rotating, brightness adjustment, scaling, etc., which can increase the diversity of training data and reduce overfitting. Select this method for configuration, set the hyperparameters of the network of this method, input the image and the corresponding label into the network for training. Since the DeepPCB dataset contains different electronic components, each target has a corresponding category label. The training process will learn the characteristics of these targets and output their positions and categories. The training process optimizes the network weights by minimizing these loss functions, and uses the SGD optimizer to adjust the parameters. After each training cycle, the performance of the model is evaluated by the validation set, and the trained model is evaluated by the test set. By analyzing the detection results, check whether the model has missed detection or false detection problems. After completing the training, use this model to detect targets on new PCB images. The trained model can be embedded in the PCB automatic detection system to achieve real-time detection and component positioning. Similarly, other existing methods are selected to process images in the DeepPCB dataset.
[0035] As shown in Table 1, the average accuracy mAP of the method of the present invention and the existing methods (image processing method Image Processing, single detection algorithm SSD, and method Faster based on regional convolutional neural network) are compared for open circuit, short circuit, burr, false copper, rat bite mark and hole. The average accuracy of the present invention is higher in each problem, which can prove that the method of the present invention is superior to the other three methods.
[0036] Table 1 Comparison results of the detection of the method of the present invention and the existing method Example 3 like Figure 2 As shown, it is the detection result of the present invention, Figure 2 The above are the detection results of the DeepPCB image to be detected, which is composed of 16 local images. Among them, "open" means open circuit, "short" means short circuit, "mousebite" means mouse bite mark, "spur" means burr, "pin-hole" means hole, and "copper" means fake copper. The above are the problems existing in the detected DeepPCB image. The number after the problem indicates the detection accuracy.
[0037] Although the above describes the specific implementation mode of the invention in conjunction with the drawings, it is not intended to limit the scope of protection of the invention. Based on the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative work are still within the scope of protection of the present invention.
Claims
1. A target detection fusion method for improving Yolov10, characterized in that: The following steps are involved: S1. Select the data in the DeepPCB dataset in the public intelligent manufacturing workshop to construct a dataset, and then preprocess the data in the dataset to obtain a preprocessed dataset; S2. Enhance the preprocessed data set, build a target recognition network model based on the lightweight Yolov10n network, and improve the Yolov10n network. The improved Yolov10n network includes an input end, a backbone network, a neck network, and an output end. The neck network introduces four context fusion CFM modules. The CFM module includes a channel adjustment convolution module, a feature concatenation Concat module, an attention module CBAM, a weighted feature reorganization module and an output feature generation module; S3. Input the image data in the preprocessed data set into the improved target recognition network model to obtain the final detection result.
2. The target detection fusion method for improving Yolov10 according to claim 1, characterized in that: S1 is as follows: S1.
1. Constructing the dataset: The DeepPCB dataset is an existing PCB circuit board defect dataset. The DeepPCB dataset contains 1,500 sets of DeepPCB images. Each set of images contains a defect-free template image and a corresponding test image. The dataset is constructed based on the existing DeepPCB dataset. S1.
2. Preprocess the data in the dataset, remove redundant information in the dataset, verify the accuracy of the original image data in the dataset, and then perform image enhancement and bounding box enhancement on the image data, and flip it to obtain the preprocessed dataset. , , dataset Included images, Representation dataset Middle A preprocessed DeepPCB image. ; Specifically, the getRectSubPix function in the OpenCV library in Python is used for cropping, the GaussianBlur function in the OpenCV library in Python is used for smoothing the image, and the flip function in the OpenCV library in Python is used for vertical flipping with the coordinate axis set to 0.
3. The target detection fusion method for improving Yolov10 according to claim 2, characterized in that: S2 is as follows: Build a target recognition network model. The target recognition network model is essentially a YOLOv10 network. When training the target recognition network model, set the number of iterations to 300, the learning rate to 0.0001, the learning speed to decay to half of the original speed every 20 iterations, and the initial learning rate to , the batch size is set to 16; Improve the lightweight network Yolov10n. The improved lightweight network Yolov10n is divided into four parts: input end, backbone network, neck network and output end; The input includes Mosaic data enhancement, adaptive anchor boxes, and adaptive image scaling; The backbone network includes four convolution modules Conv, four feature extraction layer modules C2f, two downsampling modules SCDown and one adaptive information fusion integration module AIFI; The neck network is located between the backbone network and the output end, and includes two upsampling modules Upsample, four context fusion modules CFM, three feature extraction layer modules C2f, a convolution module Conv, a context perception module C2fCIB and a downsampling module SCDown; The output end includes a detection head module v10Detect; Among them, the convolution module Conv includes a 3 3 convolution kernels of two-dimensional convolution Conv2d, a batch normalization layer BatchNormal and activation function SiLU, the padding of the convolution kernel is 1, and the stride is 1; The context fusion CFM module, which includes a channel adjustment convolution module, a feature concatenation Concat module, a CBAM attention module, a weighted feature reorganization module and an output feature generation module.
4. The target detection fusion method for improving Yolov10 according to claim 3, characterized in that: S3 is as follows: According to the improved Yolov10n target detection network model, the preprocessed dataset Process the data in the dataset Image data in Input into the target detection network model after improving Yolov10n, passing through the input end, backbone network, neck network and output end in sequence; S3.
1. Operation process at the input end: Dataset The data is input to the input end, and the data set is successively enhanced by the Mosaic data enhancement module, the adaptive anchor frame module, and the adaptive image scaling module. Adjust the data in the , Representation dataset Middle Adjusted DeepPCB image; The specific steps are as follows: The data first enters the Mosaic data enhancement module, which extracts For each image Randomly select 3 images and stitch them together to make the images The selected 3 images are cropped and scaled to fit Stitching operation: stitch the 4 processed images into a complete image in a 2×2 layout, and update the information of the complete image according to the stitching position and scaling ratio to obtain a complete image dataset. The updated information includes the target box and category label. Then, the images in the complete image dataset are input into the adaptive anchor box module, the width and height distribution of the annotation boxes of all complete images are counted, and a histogram of the aspect ratio is generated. Clustering, generation Anchor frames, each of which has a size of cluster center, represent the main size distribution of the target in the complete image dataset. The anchor frame parameters are updated according to the clustering results, and the updated anchor frame size is aligned with the target frame. Finally, the complete image with updated information enters the adaptive image scaling module to obtain the image The original width and height , adjust the complete image and generate the adjusted DeepPCB image , and then get the adjusted data set , Representation dataset Middle The adjusted DeepPCB image.
5. The target detection fusion method for improving Yolov10 according to claim 4, characterized in that: S3 is as follows: S3.
2. Operation process in the backbone network: The backbone network consists of four convolution modules Conv, four feature extraction layer modules C2f, two downsampling modules SCDown and one module AIFI; The four convolution modules Conv are the first convolution module , the second convolutional module , the third convolution module And the fourth convolution module , the four feature extraction layers C2f are the first feature extraction layer , the second feature extraction layer , the third feature extraction layer and the fourth feature extraction layer , the two downsampling SCDown modules include the first downsampling layer and the second downsampling layer ; The dataset The image data is input into the backbone network. First, the image is read through the imread function in the OpenCV library in Python, and then the read image is Input to the first convolution module In the example, the number of output channels increases from 3 to 64, and the feature map is obtained. , feature map After the second convolution module , the number of output channels increases from 64 to 128, and the feature map is obtained , then the feature map After the first feature extraction layer , get the feature map , feature map After the third convolution module , the number of output channels increases from 128 to 256, and the feature map is obtained , feature map After the second feature extraction layer , get the feature map , feature map After the first downsampling layer , the number of output channels increases from 256 to 512, and the feature map is obtained , feature map After the third feature extraction layer , and get a feature map with an output channel number of 512 ,Feature map After the second downsampling layer , the number of output channels increases from 512 to 1024, and the feature map is obtained , feature map After the fourth feature extraction layer , and get a feature map with an output channel number of 1024 , feature map Then through the fourth convolution module Feature extraction is performed, and the output channels are reduced from 1024 to 512. The extracted features are input into the AIFI module, and the high-level semantic features are interacted within the scale through the AIFI module to obtain a feature map with an output channel number of 512 .
6. The target detection fusion method for improving Yolov10 according to claim 5, characterized in that: S3 is as follows: S3.
3. Operation process in the network: The neck network is located between the backbone network and the output end, and includes two upsampling modules Upsample, four context fusion modules CFM, three feature extraction layer modules C2f, one convolution module Conv, one context perception module C2fCIB, and one downsampling module SCDown; Among them, the two upsampling modules Upsample are the first upsampling module and the second upsampling module The four context fusion modules CFM are the first context fusion module , Second context fusion module , the third context fusion module and the fourth context fusion module , the three feature extraction layer modules C2f include the fifth feature extraction layer , the sixth feature extraction layer and the seventh feature extraction layer , the convolution module Conv includes the fifth convolution module , the context-aware module C2fCIB includes the first context-aware module The downsampling module SCDown includes the third downsampling layer ; The final output feature map of the Backbone network Input to the Neck network, feature map First, through the first upsampling module Upsampling is performed, the feature map size is doubled, and the output channel number is 512. , the feature map With feature map Through the first context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , feature map After the fifth feature extraction layer , the output channel number is 512 feature map , feature map After the second upsampling module , the output channel number is 512 feature map , feature map With feature map Through the second context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , the feature map After the sixth feature extraction layer , the output channel number is 256 feature maps , the feature map Input to the fifth convolution module , the output channel is 256 feature maps , the feature map and feature map Through the third context fusion module Fusion splicing is performed to output a feature map with 768 channels , feature map After the seventh feature extraction layer , the output channel number is 768 feature map , feature map After the third downsampling layer , the output channel number is 512 feature map , the feature map and feature map Through the fourth context fusion module Fusion and splicing are performed to output a feature map with 1024 channels. , feature map Through the first context-aware module , the output channel number is 1024 feature map .
7. The target detection fusion method for improving Yolov10 according to claim 6, characterized in that S3 The details are as follows: S3.4, the operation process in the output end; Feature Map After the v10Detect detection module performs target detection at three different spatial resolutions, the feature map The spatial resolution of each scale is processed independently and then input into a dedicated convolutional layer for further feature extraction. Using a convolution with a kernel size of 1×1, the feature map of each scale is mapped to the number of channels required for detection. , ,in and Represents the coordinates of the target box, and Represents the width and height of each scale feature map, Indicates confidence, Represents the number of categories. Before prediction, the features of each scale are fused in pairs. After each scale feature map is processed, two branches are formed, namely the classification branch and the regression branch. The classification branch represents the category prediction of the target and outputs the confidence of the category. The regression branch represents the regression of the coordinates of the target box, predicts the position and size of the target box, and outputs each scale feature map. The output resolution of the three scales is , and , and Represents the feature maps The height and width of the grid are calculated, and finally the feature maps of the three scales are merged to generate a complete detection result. The output of each feature map includes the target box position, confidence, and category probability.
8. The target detection fusion method for improving Yolov10 according to claim 6, characterized in that CF The M module workflow is as follows: (1) The CFM module receives two feature maps, which are low-resolution and high-semantic feature maps. and high-resolution, low-semantic feature maps , , , represents the batch size, , and Represents the feature maps The number of channels, height and width, , and Represents the feature maps The number of channels, height and width are then adjusted by the channel convolution module Adjusting feature maps The number of channels of the feature map The consistency of the channel alignment feature map and feature map The concatenation is performed along the channel dimension through the feature concatenation module Concat. , get the splicing features , before performing the splicing operation, determine whether there is and ,like or , then the feature map is interpolated or down-sampled Adjust the resolution; (2) Then the splicing features Input to the CBAM module, and the concatenated features are processed by the channel attention module of the CBAM module. Perform a global pooling operation in the spatial dimension. The global pooling operation in the spatial dimension includes the global average pooling operation GAP and the global maximum pooling operation GMP. The calculation formula is as follows: , , in, and Respectively represent the splicing features The height and width of Indicates height The index of Indicates width The index of Indicates the maximum height and width. Represents splicing features The result of performing the global average pooling operation GAP, Represents splicing features The result of performing the global maximum pooling operation GMP; Then input the results of GAP and GMP into the shared two-layer fully connected layer MLP to generate channel attention weights , the calculation formula is as follows: , in, represents the Sigmoid activation function used for normalization, represents a fully connected layer; Then the concatenated features are processed by the spatial attention module of the CBAM module. Perform the maximum pooling operation on the channel dimension and average pooling operation , the calculation formula is as follows: , , in, Represents splicing features The number of channels, Indicates the number of channels The index of Represents splicing features Perform the maximum pooling operation As a result, Represents splicing features Perform average pooling operation Result; Then The results and The results are concatenated, and after two-dimensional convolution and normalization operations, the spatial attention weight is obtained. , the calculation formula is as follows: , According to the spatial attention weight and channel attention weights Calculate the enhanced attention feature map of the final output of the CBAM module , the calculation formula is as follows: ; (3) Enhanced attention feature map Input to the weighted feature reorganization module for weighted feature reorganization. The weighted feature reorganization module is based on the feature map. and feature map The weights will enhance the attention feature map Split into feature maps and feature map , and then the feature map With feature map Add item by item to get the feature map , the feature map With feature map Add item by item to get the feature map ; (4) Feature map and feature map Input to the output feature generation module, concatenate the two features, and obtain the feature map of the final output of the CFM module , the calculation formula is as follows: , in, Represents a concatenation operation.
Citation Information
Patent Citations
Strawberry fruit identification method based on improved YOLOv5s
CN118397427A
Lightweight parking detection method based on multi-scale attention mechanism
CN119314141A
Unmanned aerial vehicle small target detection method, electronic equipment and storage medium
CN119478739A
Cited By
Power grid operation scene personnel target real-time tracking method, system, equipment and medium
CN120355942A
A power grid operation scene personnel target real-time tracking method, system, device and medium
CN120355942B
Method, device and equipment for identifying primitives of wiring diagram of power grid plant station and medium
CN120472494A
Glass defect detection method based on improved YOLOv5
CN120612307A
Visual positioning method for UHPC highway guardrail center hole
CN120726126A