Surface defect detection method based on improved Yolov8 high-reflection cone
By introducing channel and spatial attention mechanisms into the YOLOv8 model and optimizing feature extraction, the accuracy and efficiency issues of high-reflectivity surface defect detection are solved, achieving high-precision and robust defect detection.
Patent Information
- Application Number
- CN202511476411.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-02-06
AI Technical Summary
Existing technologies struggle to achieve high-precision and high-efficiency defect detection on highly reflective surfaces. Traditional methods are sensitive to and complex under lighting conditions, while existing improved methods are costly or slow.
An attention mechanism module, especially channel and spatial attention mechanisms, is introduced to enhance the defect detection capability of the YOLOv8 model in complex lighting and uneven reflection environments. Feature extraction is optimized by combining global average pooling and max pooling with fully connected layers and the Sigmoid activation function.
It significantly improves the accuracy and robustness of defect detection on highly reflective cone surfaces, reduces false detections and missed detections, is suitable for complex lighting environments, and can be extended to the detection of other complex lighting surfaces.
Smart Images

Figure CN121482441A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision and image processing, and particularly relates to a high-reflective cone surface defect detection method based on an improved Yolov8. BACKGROUND
[0002] In industrial automation, surface defect detection is an important link to ensure product quality. Traditional image processing methods such as edge detection and threshold segmentation extract defect information by manually designing features, but such methods are sensitive to lighting conditions and difficult to cope with high-reflective surfaces. The prior art discloses a high-reflective cylindrical workpiece surface defect detection method based on an improved YOLOv8 model, which improves the Bottleneck module in the C2f structure to extract weak defect features of the workpiece surface, and then inputs the image to be detected into the preset training model for detection. This method avoids reflection processing and only optimizes the detection accuracy of small defects, but cannot fundamentally solve such problems. The prior art also discloses a defect detection method for high-reflective surfaces, which determines the detection area by calculating the gray value of reflected light and determines the defect distribution by mathematical calculation. This method is complex and not suitable for engineering applications. In summary of existing domestic and foreign literature, existing improved methods mainly develop in two directions: one is multispectral imaging, which improves defect contrast by adding near-infrared bands, but increases equipment cost; the other is polarization technology, which can suppress specular reflection but reduces processing speed. It can be seen that the existing technology cannot meet the demand of high-precision and high-efficiency high-reflective surface defect detection, and it is urgent to develop a new reflection interference optimization method. SUMMARY
[0003] In view of the defects and deficiencies in the above background art, the present application proposes a high-reflective cone surface defect detection method based on an improved Yolov8, which introduces an attention mechanism module to solve the problems of insufficient precision and poor robustness of existing algorithms in processing high-reflective cone surfaces. Specifically, the present application integrates channel attention mechanism and spatial attention mechanism in the network structure of YOLOv8, effectively enhancing the defect detection ability of the model in complex lighting and uneven reflection environments.
[0004] The first object of the present application is to provide a high-reflective cone surface defect detection method based on an improved Yolov8, comprising: obtaining a high-reflective cone surface image; defining a channel attention mechanism and embedding the channel attention mechanism into the Backbone and Neck parts of YOLOv8 to obtain an improved Yolov8; detecting the position, class and confidence of defects in the high-reflective cone surface image by the improved Yolov8; The defined channel attention mechanism comprises: The high-reflective cone surface image is subjected to global average pooling and global maximum pooling respectively; The feature vectors after the global average pooling and the global maximum pooling are sequentially subjected to a first full connection layer and a second full connection layer, and then normalized by using a Sigmoid activation function, to obtain channel attention weights corresponding to the global average pooling and the global maximum pooling; The channel attention weights corresponding to the global average pooling and the global maximum pooling are fused, and the high-reflective cone surface image is enhanced to obtain a feature map after channel attention enhancement.
[0005] In an embodiment, the channel attention mechanism is embedded into the Backbone and the Neck of YOLOv8 as follows:
[0006] In the formula, is a feature fusion network; is a channel attention mechanism module; is a feature processed by a backbone network; is an optimized multi-scale feature map.
[0007] In an embodiment, the position, category and confidence of the defect detected by the improved Yolov8 are as follows:
[0008] In the formula, is a probability of classification output; is a position coordinate of a feature map; is a confidence.
[0009] In an embodiment, the probability of classification output is as follows:
[0010] In the formula, is a classification score of detection output; represents a target existence probability, and the range is ; is a scaling factor.
[0011] In an embodiment, the output result of the first full connection layer is input to the second full connection layer after ReLU nonlinear transformation.
[0012] In an embodiment, when the high-reflective cone surface image is obtained, the defect types of the high-reflective cone are defined as: transverse scratch, longitudinal scratch and surface pit; The illumination condition is defined as a mixture of natural light and artificial light; The collection includes multi-view and multi-distance collection, and includes close-up, long-distance, side view and overhead view.
[0013] In an embodiment, the high-reflective cone material is copper-plated metal.
[0014] The second object of the present application is to provide a computer program product comprising a computer program which, when executed by a processor, implements the improved Yolov8 high-reflective cone surface defect detection method.
[0015] The third object of the present application is to provide an electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the improved Yolov8 high-reflective cone surface defect detection method via execution of the executable instructions.
[0016] The fourth object of the present application is to provide an improved Yolov8 high-reflective cone surface defect detection system comprising: a data acquisition module for acquiring high-reflective cone surface images; an improvement module for defining a channel attention mechanism and embedding the channel attention mechanism into the Backbone and Neck parts of YOLOv8 to obtain an improved Yolov8; wherein the defined channel attention mechanism comprises: performing global average pooling and global maximum pooling on the high-reflective cone surface images respectively; sequentially passing the feature vectors after global average pooling and global maximum pooling through a first layer of fully connected layers and a second layer of fully connected layers, and then using a Sigmoid activation function for normalization processing to obtain the channel attention weights corresponding to global average pooling and global maximum pooling; fusing the channel attention weights corresponding to global average pooling and global maximum pooling, and enhancing the high-reflective cone surface images to obtain a feature map enhanced by channel attention; a defect detection module for detecting the position, class and confidence of defects detected by the improved Yolov8 according to the high-reflective cone surface images.
[0017] The present application has at least the following beneficial effects: The present application provides an improved Yolov8 high-reflective cone surface defect detection method, which introduces a channel attention mechanism, effectively enhances the extraction ability of the high-reflective cone surface features, significantly reduces the false detection and missed detection problems caused by uneven light reflection, and improves the accuracy and robustness of defect detection.
[0018] This invention designs a defect detection process specifically for highly reflective cones, including illumination equalization and feature enhancement strategies in the data preprocessing stage, enabling the model to run stably even in complex lighting environments.
[0019] The improved algorithm of this invention has good scalability and is not only applicable to the detection of surface defects on highly reflective cones, but can also be extended to other surface defect detection scenarios with complex lighting characteristics, making it widely applicable. Attached Figure Description
[0020] Figure 1 This is a flowchart for detecting defects in highly reflective cones. Detailed Implementation
[0021] In order to illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following detailed description is provided in conjunction with the embodiments.
[0022] The purpose of this invention is to provide an improved method for detecting defects on the surface of highly reflective cones based on YOLOv8. This method can be used for defect detection on the surface of highly reflective cones by introducing an attention mechanism module to address the high reflectivity and uneven reflection characteristics of the cone, thereby enabling dynamic adjustment of the weights of feature regions.
[0023] To achieve the above objectives, see Figure 1 As shown, a method for detecting surface defects on highly reflective cones based on the improved Yolov 8 standard includes: S1. Obtain an image of the highly reflective cone surface; When acquiring images of the highly reflective cone surface, the defect types of the highly reflective cone are defined as: transverse scratches, longitudinal scratches, and surface pits; the lighting conditions are defined as: a mixture of natural light and artificial light; the acquisition includes multi-view and multi-distance acquisition, including close-up, long-distance, side view, and top view. The material of the highly reflective cone is copper-plated metal.
[0024] In this embodiment, the defect types of the highly reflective cone are defined as: transverse scratches, longitudinal scratches, and surface pits; the lighting conditions are defined as a mixture of natural and artificial light to cover the lighting conditions in a real production environment; to improve the model's adaptability to cone surface defects, the dataset needs to include multi-view and multi-distance acquisition, including close-up, long-distance, side, and top views during the shooting process; the highly reflective cone material used in the dataset is copper-plated metal, and the dataset's annotation information includes defect location and defect type. Then, the images in the dataset undergo enhancement processing and sample balancing to ensure a balanced number of samples for each defect category. The final dataset contains 1000 images, covering various lighting conditions and defect types, with the original image resolution at 1080p to facilitate the extraction of detailed features. Annotation was performed by professionals to ensure the accuracy of defect location and category labeling.
[0025] S2. Define the channel attention mechanism and embed it into the Backbone and Neck parts of YOLOv8 to obtain an improved YOLOv8. The defined channel attention mechanisms include: Global average pooling and global max pooling are performed on the images of highly reflective cone surfaces, respectively. The feature vectors after global average pooling and global max pooling are passed through the first fully connected layer and the second fully connected layer in sequence, and then normalized using the Sigmoid activation function to obtain the channel attention weights corresponding to global average pooling and global max pooling. After fusing the channel attention weights corresponding to global average pooling and global max pooling, the highly reflective cone surface image is enhanced to obtain the feature map after channel attention enhancement.
[0026] For example, a channel attention mechanism module is designed, including: The global feature vector is: ,
[0027] Global average pooling is:
[0028] Global max pooling is:
[0029] in, It is the input feature map. It is the number of channels. and These are the height and width of the feature map, respectively.
[0030] The output of the first fully connected layer is:
[0031] in, It is the output of the first fully connected layer. It is the weight matrix of the first fully connected layer. It is the bias term of the first fully connected layer. This is a learnable parameter that can be introduced to improve the model's fitting ability.
[0032] First layer fully connected output The output after ReLU nonlinear transformation is :
[0033] The output of the second fully connected layer is :
[0034] in, It is the weight matrix of the second fully connected layer. It is the bias term of the second layer fully connected layer.
[0035] The channel attention weights normalized using the Sigmoid activation function are: :
[0036] in, , These are the learning parameters of the YOLOv8 network. It is the channel compression ratio.
[0037] To introduce a channel attention mechanism, the features from global average pooling and global max pooling are weighted and fused, resulting in a final fusion weight of: :
[0038] in, and It is an adjustable hyperparameter used to balance the contributions of the two weights.
[0039] Enhanced feature map:
[0040] in, C is the number of channels, H is the height, and W is the width. Original input feature map, These are feature map elements after channel attention enhancement.
[0041] The channel attention mechanism is embedded in the Backbone and Neck parts of YOLOv8 as follows:
[0042] In the formula, It is a feature fusion network; It is the channel attention mechanism module; These are the characteristics of the backbone network after processing; This is the optimized multi-scale feature map.
[0043] S3. Determine the location, type, and confidence level of defects detected by improved Yolov8 based on images of highly reflective cone surfaces; In this embodiment, the YOLOv8 detection head performs target classification and regression using multi-scale feature maps. The classification output probability is:
[0044] In the formula, It is the classification score output by the detection; This indicates the probability that the target exists, and its range is... ; It is a scaling factor, and its specific value is determined by... The results were obtained through categorized calculations.
[0045] The position coordinates of the feature map are:
[0046] in, These are the coordinates of the defect center point. It's the width. It is the height; its specific value is obtained through... The results were obtained through regression calculations.
[0047] Using the output of the YOLOv8 model, we obtain the location, category, and confidence level of the detected defects. The final output is as follows:
[0048] Then, based on the optimized output, the location and type of defects are labeled on the image, and visualization is achieved. Using... The value is used to draw a rectangle, and different types of defects are distinguished by different colored boxes. Finally, the defect location information is output.
[0049] This invention provides a computer program product, including a computer program that, when executed by a processor, implements an improved method for detecting surface defects on highly reflective cones based on YOLOv8.
[0050] This invention provides an electronic device, comprising: Processor; and Memory for storing the executable instructions of the processor; The processor is configured to execute a method for detecting defects on highly reflective cone surfaces based on the improved Yolov8 standard by executing the executable instructions.
[0051] This invention provides an improved YOLOv8 high-reflectivity cone surface defect detection system, comprising: The data acquisition module is used to acquire images of the highly reflective cone surface; An improved module is used to define the channel attention mechanism and embed it into the Backbone and Neck parts of YOLOv8 to obtain an improved YOLOv8. The defined channel attention mechanism includes: performing global average pooling and global max pooling on the highly reflective cone surface image; passing the feature vectors obtained from global average pooling and global max pooling through a first fully connected layer and a second fully connected layer, and then normalizing them using a Sigmoid activation function to obtain the channel attention weights corresponding to global average pooling and global max pooling; fusing the channel attention weights corresponding to global average pooling and global max pooling, and then enhancing the highly reflective cone surface image to obtain a channel attention-enhanced feature map. The defect detection module is used to determine the location, type, and confidence level of defects detected by improving Yolov8 based on images of highly reflective cone surfaces.
[0052] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An improved Yolov8-based high-reflectance cone surface defect detection method, characterized in that, The method comprises the following steps: obtaining a high-reflective cone surface image; defining a channel attention mechanism and embedding the channel attention mechanism into a Backbone and a Neck part of YOLOv8 to obtain an improved Yolov8; detecting the position, category and confidence of defects from the high-reflective cone surface image by using the improved Yolov8; wherein the defined channel attention mechanism comprises: performing global average pooling and global maximum pooling on the high-reflective cone surface image respectively; processing the feature vectors after the global average pooling and the global maximum pooling through a first fully connected layer and a second fully connected layer in sequence, and then using a Sigmoid activation function for normalization to obtain channel attention weights corresponding to the global average pooling and the global maximum pooling; fusing the channel attention weights corresponding to the global average pooling and the global maximum pooling, and enhancing the high-reflective cone surface image to obtain a channel attention enhanced feature map.
2. The improved Yolov8-based high-reflective conical surface defect detection method according to claim 1, characterized in that, The channel attention mechanism is embedded into the Backbone and the Neck part of YOLOv8 as follows: In the formula, is a characteristic fusion network; is a channel attention mechanism module; is a feature processed by a backbone network; is an optimized multi-scale feature map.
3. The improved Yolov8-based high-reflective conical surface defect detection method according to claim 1, characterized in that, The position, category and confidence of defects detected by the improved Yolov8 are as follows: In the formula, is a probability of a classification output; is a position coordinate of a feature map; is a confidence.
4. The improved Yolov8-based high-reflective conical surface defect detection method according to claim 3, characterized in that, The probability of classification output is: wherein is the classification score of the detection output; denotes the target existence probability, ranging from ; is a scaling factor.
5. The improved Yolov8-based high-reflective conical surface defect detection method according to claim 1, characterized in that, The output result of the first fully connected layer is input to the second fully connected layer after ReLU nonlinear transformation.
6. The improved Yolov8-based high-reflective conical surface defect detection method according to claim 1, characterized in that, When obtaining the high-reflective cone surface image, the defined defect types of the high-reflective cone are: horizontal scratches, vertical scratches and surface pits; the defined lighting conditions are: natural light and artificial light mixed; The collection includes multi-angle and multi-distance collection, including close-up, long-distance, side view and overhead view.
7. The improved Yolov8-based high-reflective conical surface defect detection method according to claim 1, characterized in that, The high-reflective cone material is copper-plated metal.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to realize the improved Yolov8-based high-reflective cone surface defect detection method according to any one of claims 1 to 7.
9. An electronic device, comprising: The method comprises the following steps: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the improved Yolov8-based high-reflective cone surface defect detection method according to any one of claims 1 to 7 by executing the executable instructions.
10. An improved Yolov8-based high-reflectance cone surface defect detection system, characterized in that, The method comprises the following steps: a data acquisition module for obtaining a high-reflective cone surface image; an improvement module for defining a channel attention mechanism and embedding the channel attention mechanism into a Backbone and a Neck part of YOLOv8 to obtain an improved Yolov8; wherein the defined channel attention mechanism comprises: performing global average pooling and global maximum pooling on the high-reflective cone surface image respectively; processing the feature vectors after the global average pooling and the global maximum pooling through a first fully connected layer and a second fully connected layer in sequence, and then using a Sigmoid activation function for normalization to obtain channel attention weights corresponding to the global average pooling and the global maximum pooling; fusing the channel attention weights corresponding to the global average pooling and the global maximum pooling, and enhancing the high-reflective cone surface image to obtain a channel attention enhanced feature map; The defect detection module is used for detecting the position, category and confidence of the defect detected by improving Yolov8 according to the high-reflective cone surface image.