A yolo-based target single edge detection method
By using the multi-layer CBS module of the YOLOV8n-seg model and the multi-scale cross-fusion of the neck structure, an accurate edge contour image is generated, which solves the problem of insufficient accuracy of traditional edge detection algorithms in complex environments and achieves high-precision and fast single edge detection.
Patent Information
- Application Number
- CN202411141043.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-08-19
AI Technical Summary
Traditional edge detection algorithms lack accuracy in complex environments, making it difficult to meet the high-precision requirements of precision measurement and automated detection, especially under noise and lighting conditions.
A target single edge detection method based on the YOLOV8n-seg model is adopted. By combining the backbone network, neck structure, detection head and mask processing module, and utilizing the multi-level CBS module and multi-scale cross-fusion of the neck structure, an accurate edge contour image is generated.
It improves the accuracy and stability of single-edge detection, meets the measurement needs of ultra-high precision industrial production lines, has low training costs, fast inference speed, and is suitable for real-time detection.
Smart Images

Figure CN119090905B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology, specifically relating to a target single edge detection method based on YOLO. Background Technology
[0002] With the continuous advancement of industrial automation and intelligence, especially in the fields of precision robotics, automated quality inspection, and manufacturing, the requirements for the accuracy and reliability of edge detection technology are constantly increasing. Traditional edge detection algorithms, such as Canny, Sobel, and Prewitt, while achieving some success in early applications, are often affected by noise and lighting variations in complex real-world scenarios, leading to insufficient detection accuracy. To overcome these limitations, researchers have begun to adopt deep learning-based methods, such as convolutional neural networks (CNNs). These methods learn edge detection features through large amounts of training data, enabling more accurate and stable edge detection in variable environments.
[0003] In the field of precision measurement, edge detection not only needs to identify the contours of objects but also needs to complete tasks with extremely high precision, such as measuring the dimensions of tiny parts or detecting minute defects in products. Traditional edge detection algorithms, due to their limitations in recognition accuracy, struggle to meet these high-precision requirements. Therefore, deep learning-based edge detection algorithms, such as the Holistic Edge Detection (HED) algorithm based on deep convolutional networks and the Richter Convolutional Features (RCF) algorithm based on structured learning, have been widely used to extract more refined edge information. These algorithms can better distinguish object edges in complex backgrounds, but they typically require a large amount of labeled data for training.
[0004] The YOLO (You Only Look Once) model plays a crucial role in edge detection technology. YOLO is a real-time object detection system renowned for its speed and high accuracy. In the field of measurement, the YOLO model processes the entire image at once, predicting object boundaries and classifications. This one-step approach significantly improves processing speed, making it ideal for industrial applications requiring real-time measurement. Through a series of iterations, the YOLO model has continuously optimized its speed and accuracy, leveraging deep learning for feature extraction to more accurately identify and measure the precise location and size of objects. Particularly in automated inspection lines and high-speed quality control systems, the YOLO model has begun to replace traditional image processing methods. Summary of the Invention
[0005] The purpose of this invention is to provide a target single edge detection method based on YOLO to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a target single edge detection method based on YOLO, which is based on the YOLOV8n-seg model set by the YOLOV8n model. The YOLOV8n-seg model includes a backbone network, a neck structure, a detection head, a Proto module, and a mask processing module. The backbone network includes a multi-layer CBS module, and the neck structure is provided with multiple input terminals and multiple output terminals.
[0007] S1: The original image is input into the backbone network. The original image is processed by convolution through multiple layers of the CBS module. Each layer of the CBS module outputs a set of preliminary feature maps, which are combined to obtain a preliminary feature map library.
[0008] S2: Each set of preliminary feature maps in the preliminary feature map library is input to the input end of the neck structure. Each set of preliminary feature maps is cross-fused at multiple scales. Each output end outputs a predicted Box feature map, a predicted cls feature map, and a Mask coefficient feature map. The final feature map sets are combined to obtain the final feature map library.
[0009] S3: The predicted Box feature map and predicted CLS feature map of each group in the final feature map library are input into the detection head. The detection head is filtered by the classification score threshold and NMS threshold to obtain category information and location information, which are then combined to obtain the target information group.
[0010] S4: The predicted Box feature map and predicted cls feature map of each group in the final feature map library are input into the detection head to calculate the native mask and mask coefficients;
[0011] S5: The Mask coefficient feature map of each group in the final feature map library is input into the Proto module to obtain the original segmentation feature map;
[0012] S6: Input the original mask, the mask coefficients, and the original segmentation feature map into the mask processing module to obtain a single-edge contour image.
[0013] Preferably, the multi-layer CBS module includes a P1-CBS module, a P2-CBS module, a P3-CBS module, a P4-CBS module, and a P5-CBS module, and the CBS module includes the P1-CBS module, the P2-CBS module, the P3-CBS module, the P4-CBS module, and the P5-CBS module combined in series.
[0014] Preferably, the P1-CBS module is an input terminal, and the P3-CBS module, P4-CBS module and P5-CBS module are all provided with an input terminal P.
[0015] Preferably, the neck structure is a PAN+FPN structure, and the neck structure has three input terminals and three output terminals.
[0016] Preferably, step S6 further includes: the target information group is filtered by nonmaximum suppression to obtain the final category information and location information, and a prediction mask is generated using the native mask and mask coefficients;
[0017] The predicted mask is batch-cropped and binarized using a threshold to obtain a single-edge contour image.
[0018] Preferably, the original image has a size of 640*640, and the preliminary feature map group includes multiple preliminary feature maps, each with a size of 20*20.
[0019] Preferably, the neck structure outputs three predicted Box feature maps, and the sizes of the three predicted Box feature maps are 80*80, 40*40 and 20*20, respectively.
[0020] Preferably, the neck structure outputs three predicted CLS feature maps, and the sizes of the three predicted CLS feature maps are 80*80, 40*40 and 20*20, respectively.
[0021] Preferably, the neck structure outputs three Mask coefficient feature maps, the sizes of which are 80*80, 40*40 and 20*20 respectively.
[0022] Compared with the prior art, the beneficial effects of the present invention are:
[0023] This invention utilizes a YOLOV8n-seg model based on the YOLOV8n model. During actual scheduling, both the YOLOV8n and YOLOV8n-seg models are invoked simultaneously, improving the accuracy of specific single-edge detection through the dual-model approach. The dual-model approach offers high applicability, providing precise measurement data for industrial production lines requiring ultra-high precision.
[0024] The present invention has low training cost, requires a small training dataset for the dual models used, and only 50 or more data points are needed to complete the model training. The trained model has good detection results.
[0025] The present invention features fast inference speed and superior performance of the dual-model approach, with a single image inference speed of approximately 0.11 seconds, meeting the detection speed requirements of industrial production lines. Attached Figure Description
[0026] Figure 1This is a flowchart of the single edge detection method of the YOLOV8n model and the YOLOV8n-seg model of the present invention.
[0027] Figure 2 This is a flowchart of a specific single-edge detection method based on YOLOV8n according to the present invention.
[0028] Figure 3 This is a flowchart of a specific single-edge detection method for the YOLOV8n-seg model of this invention.
[0029] Figure 4 This is the original image to be detected in this invention.
[0030] Figure 5 This is the result of the traditional edge detection algorithm, Canny.
[0031] Figure 6 This is the detection result of the deep learning LDC edge detection model.
[0032] Figure 7 This is the detection result of the deep learning HED edge detection model.
[0033] Figure 8 The present invention provides the detection results of a specific single-edge detection method based on the YOLOV8n model. Detailed Implementation
[0034] The technical solutions of this embodiment will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments, not all embodiments. Based on the embodiments herein, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0035] Example 1:
[0036] like Figures 1-8As shown, this invention provides a target single-edge detection method based on YOLO, using the YOLOV8n-seg model set up based on the YOLOV8n model. The YOLOV8n-seg model includes a backbone network, a neck structure, a detection head, a Proto module, and a mask processing module. The backbone network includes a multi-layer CBS module, and the neck structure has multiple input terminals and multiple output terminals. S1: The original image is input into the backbone network. The original image undergoes convolution processing through the multi-layer CBS module. Each CBS module outputs a set of preliminary feature maps, which are combined to obtain a preliminary feature map library. S2: Each set of preliminary feature maps in the preliminary feature map library is input to the input terminal of the neck structure. Each set of preliminary feature maps is cross-fused at multiple scales. Each output terminal outputs a predicted Box feature map and a predicted... S3: The predicted Box feature map and predicted CLS feature map of each group in the final feature map library are combined to obtain the final feature map group. The final feature map group output from multiple output terminals is combined to obtain the final feature map library. S4: The predicted Box feature map and predicted CLS feature map of each group in the final feature map library are input into the detection head. The detection head is filtered by classification score threshold and NMS threshold to obtain category information and location information, which are combined to obtain the target information group. S5: The predicted Box feature map and predicted CLS feature map of each group in the final feature map library are input into the detection head to calculate the native mask and mask coefficients. S6: The Mask coefficient feature map of each group in the final feature map library is input into the Proto module to obtain the native segmentation feature map. S7: The native mask, mask coefficients and native segmentation feature map are input into the mask processing module to obtain the single edge contour image. The multi-layer CBS module includes P1-CBS, P2-CBS, P3-CBS, P4-CBS, and P5-CBS modules, which are combined in series. The P1-CBS module is the input terminal, while the P3-CBS, P4-CBS, and P5-CBS modules each have an input terminal P. The neck structure is a PAN+FPN structure with three input terminals and three output terminals. S6 also includes: the target information group undergoes non-maximum suppression filtering to obtain the final category and location information, and a prediction mask is generated using the original mask and mask coefficients; the prediction mask is batch-cropped and binarized using a threshold to obtain a single-edge contour image. The original image size is 640*640, and the preliminary feature map group includes multiple preliminary feature maps, each with a size of 20*20. The neck structure outputs three predicted Box feature maps with dimensions of 80*80, 40*40, and 20*20, respectively. The neck structure also outputs three predicted CLS feature maps with dimensions of 80*80, 40*40, and 20*20, respectively.The neck structure outputs three Mask coefficient feature maps, with sizes of 80*80, 40*40, and 20*20, respectively.
[0037] Through the above technical solution, the present invention utilizes a YOLOV8n-seg model based on the YOLOV8n model. In actual scheduling, both the YOLOV8n model and the YOLOV8n-seg model are invoked simultaneously, improving the detection accuracy of specific single edges through the dual-model approach. The dual-model approach has high applicability, providing accurate measurement data for industrial production lines requiring ultra-high precision.
[0038] The present invention has low training cost, requires a small training dataset for the dual models used, and only 50 or more data points are needed to complete the model training. The trained model has good detection results.
[0039] The present invention features fast inference speed and superior performance of the dual-model approach, with a single image inference speed of approximately 0.11 seconds, meeting the detection speed requirements of industrial production lines.
[0040] Example 2:
[0041] YOLO (You Only Look Once) is a deep learning-based object detection algorithm that has achieved remarkable results in the field of object detection due to its high speed and high accuracy. The core idea of the YOLO model is to transform the object detection task into a regression problem, predicting the bounding boxes and categories of objects by processing the entire image at once. This method not only improves detection speed but also reduces computational complexity, making the YOLO model very suitable for real-time detection tasks.
[0042] like Figures 1-8 As shown, this invention proposes an automated single-edge detection method based on YOLO for single-edge detection tasks. This method combines the YOLOV8n and YOLOV8n-seg models, achieving accurate detection of specific single edges through dual-model fusion.
[0043] Data labeling and preprocessing:
[0044] First, the publicly available annotation software Labelme needs to be used to annotate the image of the edges to be detected. During the annotation process, two regions need to be annotated separately:
[0045] Region containing the edge to be detected: This is a large region that contains the location of the edge to be detected.
[0046] The object contour (edge) containing the edge to be detected: This is a precise contour that represents the position of the object's edge.
[0047] After annotation is completed, the generated annotation files need to be preprocessed. Preprocessing steps include data format conversion and normalization to ensure that the data can be correctly read and processed by the YOLOv8n and YOLOv8n-seg models.
[0048] YOLOV8n model training:
[0049] The YOLOv8n model is used to generate masked images of the edge regions to be detected. The model training process includes the following steps:
[0050] Model Construction: The backbone network of the YOLOv8n model consists of multiple CBS modules, C2f modules, and SPPF modules. The CBS module performs convolutional processing on the input image to extract features. The C2f and SPPF modules further process and optimize the feature maps.
[0051] Training data preparation: The labeled data is input into the YOLOv8n model for training. The training process includes forward propagation, loss calculation, backpropagation, and optimization updates.
[0052] Model training: The YOLOV8n model is trained using training data to optimize model parameters and obtain the best edge region mask prediction results.
[0053] YOLOV8n-seg model training:
[0054] The YOLOV8n-seg model is used to generate a mask image of the object's contour containing the edges to be detected. The model training process is similar to YOLOV8n, but there are differences in the detection head layer:
[0055] Detection Head Design: The YOLOV8n-seg model generates additional feature maps in the detection head layer. In addition to generating feature maps for Box prediction and CLS prediction, it also generates feature maps (mask_coefficients) for mask coefficients.
[0056] Prototype Mask Generation: Generate a Prototype Mask feature map of size (1, 32, 80, 80) from the 80×80 scale feature map, which is used to generate the feature map of the native segmentation.
[0057] Model training: Input labeled data into the YOLOV8n-seg model for training and optimize model parameters to obtain the best edge contour mask prediction results.
[0058] Post-processing and result fusion:
[0059] After training, the model generates region masks and edge masks. Post-processing steps include:
[0060] Mask fusion: The region mask generated by the YOLOV8n model and the edge mask generated by the YOLOV8n-seg model are fused together, and the intersection image is taken to obtain the final single edge detection result.
[0061] Mask cropping and thresholding: The mask generated by the YOLOV8n-seg model is cropped and thresholded to obtain the final mask contour result.
[0062] This method has the following advantages in single edge detection tasks:
[0063] High-precision automatic detection:
[0064] By fusing the YOLOv8n and YOLOv8n-seg models, this method enables intelligent automated detection in ultra-high-precision scenes. The YOLOv8n model is responsible for locating edge regions, while the YOLOv8n-seg model is responsible for generating accurate edge contour masks. This dual processing makes the detection results more accurate and stable.
[0065] Dual-model hybrid detection:
[0066] This method proposes a dual-model hybrid detection approach, combining the YOLOV8n and YOLOV8n-seg models to effectively address the noise and interference issues inherent in traditional single-edge detection methods. The YOLOV8n model locates edge regions, while the YOLOV8n-seg model improves detection accuracy by generating detailed masks.
[0067] Efficient mask generation and fusion:
[0068] The YOLOV8n-seg model provides more detailed masking information in object detection by generating additional masking coefficients and prototype mask feature maps. Combining edge region masks with the YOLOV8n model enables more accurate mask fusion, thereby improving the accuracy of single edge detection.
[0069] Outperforms traditional algorithms and models:
[0070] Compared to traditional edge detection algorithms (such as Canny and Sobel) and common deep learning edge detection models (such as LDC and HED), this method performs better in specific single-edge automatic detection tasks. Traditional methods often perform poorly when dealing with complex backgrounds and noise, while this method leverages the powerful feature extraction capabilities of deep learning models to effectively reduce noise interference and improve detection accuracy.
[0071] To verify the reliability of the single edge detection method of this invention, a comparative experiment was conducted, comparing three edge detection algorithms: the traditional edge detection algorithm Canny, the deep learning LDC edge detection model, and the deep learning HED edge detection model.
[0072] Figure 4 , Figure 5 , Figure 6 , Figure 7 , Figure 8 The results are as follows: the original image to be detected, the detection results of the traditional edge detection algorithm Canny, the detection results of the deep learning LDC edge detection model, the detection results of the deep learning HED edge detection model, and the detection results of the specific single edge detection method based on YOLO of this invention.
[0073] Traditional edge detection algorithms and common deep learning edge detection models such as Canny, LDC, and HED are all designed for full-image detection and do not meet the requirements for automatic single-edge detection. Even with the assistance of the YOLOv8n model or other object detection models provided by this invention, a lot of noise and interference will still be generated in the area of the edge to be detected. In terms of performance, this invention is significantly better than the above algorithms and models. The YOLO-based method for automatic single-edge detection has great potential.
[0074] Example 3:
[0075] like Figure 1 As shown, the YOLO-based single-edge detection method provided in this embodiment includes the following steps:
[0076] The edge image was annotated using the publicly available annotation software Lableme, which annotates both the region containing the edge to be detected and the outline of the object containing the edge.
[0077] The obtained annotation files are preprocessed and then fed into the YOLOV8n and YOLOV8n-seg models for training, respectively, to infer the region mask image of the edge to be detected and the edge mask image of the object containing the edge to be detected.
[0078] The region mask and edge mask are post-processed, and their intersection images are fused to obtain a single-edge detection result containing only the edge to be detected.
[0079] like Figure 2As shown, the backbone network extracts features from the input image and mainly consists of the CBS module, C2f module, and SPPF module. The CBS module stands for Conv, BN, and SILU, and is generally used to perform convolution on the input image or feature map. The result of convolution is a decrease in resolution and an increase in the number of channels. There are a total of 5 CBS modules in the backbone network. The input image resolution changes from 640*640 to 20*20, and the number of input channels changes from 3 to 512.
[0080] The neck structure is used to perform feature fusion on the feature maps output by the backbone network. That is, the features extracted from these three different scales are concatenated by upsampling. After two upsampling operations, the first feature map (80*80) is output and sent to the head layer. Then, the CBS module downsamples the feature map and outputs the remaining two feature maps (40*40 and 20*20) to the head layer.
[0081] The head layer of the detection network generates specific feature maps based on the number of categories. YOLOv8 uses a decoupled head approach, meaning that feature maps for predicting class criterion (cls) and box prediction are generated separately. For example, if the input feature map P3 has a scale of (1, 256, 80, 80), the branch generating the box prediction feature map will generate a feature map of (1, nc, 80, 80) through two CBS modules and one Cov2d module, where nc represents the predicted class. After passing through the head layer, three feature maps for predicting the box prediction (1, 64, 80, 80), (1, 64, 40, 40), and (1, 64, 20, 20) are generated; and three feature maps for predicting the class criterion (cls) are generated (1, nc, 80, 80), (1, nc, 40, 40), and (1, nc, 20, 20). Finally, the feature map is converted into two forms: (1, 8400, nc) and (1, 8400, 4). After filtering by some classification score thresholds and NMS thresholds, the target's category information and location information are finally obtained.
[0082] like Figure 3 As shown, in the YOLOV8n-seg model for instance segmentation, the backbone network, neck structure, and object detection YOLOV8n model are completely identical, except for the detection head layer. The differences are twofold: First, in addition to generating three feature maps for predicting Boxes (1, 64, 80, 80), (1, 64, 40, 40), and (1, 64, 20, 20) and three feature maps for predicting CLS (1, nc, 80, 80), (1, nc, 40, 40), and (1, nc, 20, 20) in the head layer, three additional feature maps with 32 channels each are generated to serve as mask coefficients. _The coefficients are (1, 32, 80, 80), (1, 32, 40, 40), and (1, 32, 20, 20). Secondly, a prototype mask feature map of size (1, 32, 80, 80) is generated from the 80*80 scale feature map as the original segmentation feature map. Finally, two targets are selected using NMS, and predicted masks for these two targets are generated using the original mask and mask coefficients. The predicted masks are then cropped according to the predicted bounding boxes, and finally binarized using a threshold to obtain the final mask contour result.
[0083] Figure 4 , Figure 5 , Figure 6 , Figure 7 , Figure 8 The results are as follows: the original image to be detected, the detection results of the traditional edge detection algorithm Canny, the detection results of the deep learning LDC edge detection model, the detection results of the deep learning HED edge detection model, and the detection results of the specific single edge detection method based on YOLO of this invention.
[0084] Traditional edge detection algorithms and common deep learning edge detection models such as Canny, LDC, and HED are all designed for full-image detection and do not meet the requirements for single-edge automatic detection. Even with the addition of the YOLOv8n model or other object detection models provided by this invention for auxiliary localization, a lot of noise and interference will still be generated in the area of the edge to be detected.
[0085] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0086] The above description is only used to illustrate the technical solution of the present invention and is not intended to limit it. Any other modifications or equivalent substitutions made by those skilled in the art to the technical solution of the present invention, as long as they do not depart from the spirit and scope of the present technical solution, should be covered within the scope of the claims of the present invention.
Claims
1. A target single-edge detection method based on YOLO, characterized in that, The YOLOV8n-seg model is based on the YOLOV8n model. The YOLOV8n-seg model includes a backbone network, a neck structure, a detection head, a Proto module, and a masking module. The backbone network includes a multi-layer CBS module, and the neck structure has multiple input terminals and multiple output terminals. S1: The original image is input into the backbone network. The original image is processed by convolution through multiple layers of the CBS module. Each layer of the CBS module outputs a set of preliminary feature maps, which are combined to obtain a preliminary feature map library. S2: Each set of preliminary feature maps in the preliminary feature map library is input to the input end of the neck structure. Each set of preliminary feature maps is cross-fused at multiple scales. Each output end outputs a predicted Box feature map, a predicted cls feature map, and a Mask coefficient feature map. The final feature map sets are combined to obtain the final feature map library. S3: The predicted Box feature map and predicted CLS feature map of each group in the final feature map library are input into the detection head. The detection head is filtered by the classification score threshold and NMS threshold to obtain category information and location information, which are then combined to obtain the target information group. S4: The predicted Box feature map and predicted cls feature map of each group in the final feature map library are input into the detection head to calculate the native mask and mask coefficients; S5: The Mask coefficient feature map of each group in the final feature map library is input into the Proto module to obtain the original segmentation feature map; S6: Input the original mask, the mask coefficients, and the original segmentation feature map into the mask processing module to obtain a single-edge contour image.
2. The target single edge detection method based on YOLO according to claim 1, characterized in that, The multi-layer CBS module includes a P1-CBS module, a P2-CBS module, a P3-CBS module, a P4-CBS module, and a P5-CBS module, which are combined in series.
3. The target single edge detection method based on YOL0 according to claim 2, characterized in that, The P1-CBS module is an input terminal, and the P3-CBS module, P4-CBS module and P5-CBS module are all equipped with an input terminal P.
4. The target single edge detection method based on YOLO according to claim 1, characterized in that, The neck structure is a PAN+FPN structure, and the neck structure has 3 input terminals and 3 output terminals.
5. The target single edge detection method based on YOLO according to claim 1, characterized in that, The S6 further includes: the target information group is filtered by nonmaximum suppression to obtain the final category information and location information, and a prediction mask is generated using the original mask and mask coefficients; The predicted mask is batch-cropped and binarized using a threshold to obtain a single-edge contour image.
6. The target single edge detection method based on YOLO according to claim 1, characterized in that, The original image has a size of 640*640, and the preliminary feature map group includes multiple preliminary feature maps, each with a size of 20*20.
7. The target single edge detection method based on YOLO according to claim 1, characterized in that, The neck structure outputs three predicted Box feature maps, with sizes of 80*80, 40*40, and 20*20, respectively.
8. A target single edge detection method based on YOL0 according to claim 1, characterized in that, The neck structure outputs three predicted CLS feature maps, with sizes of 80*80, 40*40, and 20*20, respectively.
9. A target single edge detection method based on YOLO according to claim 1, characterized in that, The neck structure outputs three Mask coefficient feature maps, with sizes of 80*80, 40*40, and 20*20, respectively.
Citation Information
Patent Citations
Insulator fault identification method and system based on target detection and instance segmentation
CN115294473A
Cargo segmentation method and system based on SAM and YOLOV8n
CN117475148A