Surface defect detection system and method based on area light source image acquisition and improved C-YOLO
By using surface light source image acquisition and an improved YOLOv11 network algorithm, combined with C3k2_HDRAB, ELA_HSFPN and LADH modules, the problems of low efficiency and insufficient accuracy in industrial surface defect detection are solved, and efficient and accurate detection of minute defects is achieved.
Patent Information
- Application Number
- CN202610005777.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-05
- Publication Date
- 2026-02-24
AI Technical Summary
Existing technologies for industrial surface defect detection suffer from low efficiency, unstable accuracy, insufficient ability to extract nanoscale micro-defect features, and decreased detection accuracy in complex environments.
A surface light source image acquisition system combined with an improved YOLOv11 network algorithm is adopted. Feature extraction and detection are performed through the C3k2_HDRAB module, ELA_HSFPN module and LADH module to construct a C-YOLO target detection network, which enhances feature expression ability and detection accuracy.
It improves the detection accuracy and recall rate of minute defects, reduces computational complexity and cost, realizes online or near real-time automatic detection of workpiece surface defects, and improves product yield.
Smart Images

Figure CN121558624A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection and recognition technology, specifically a surface defect detection system and method based on surface light source image acquisition and improved C-YOLO. Background Technology
[0002] Current industrial surface defect detection technologies are mainly divided into two categories: traditional detection technologies and machine learning-based detection technologies. Machine learning-based detection technologies can be further subdivided into shallow machine learning detection and deep learning detection.
[0003] Neural networks are an end-to-end machine learning method that learns the ability to extract image features during model training. Convolutional Neural Networks (CNNs), as an important method in computer vision, have shown excellent performance in extracting image feature information.
[0004] In machine learning-based detection technologies, shallow machine learning detection introduces models such as Support Vector Machines (SVM), Random Forests, and Artificial Neural Networks (ANNs). It collects a large number of defective and non-defective samples, manually extracts features such as texture, shape, and grayscale histograms, and trains the model to learn feature mapping relationships to complete the detection. Deep learning detection, as a recent development direction, mainly includes detection schemes based on Convolutional Neural Networks (CNNs), Generative Adversarial Networks (GANs), and Transformers. CNN-based schemes automatically extract deep features from workpiece images using CNNs, and achieve defect identification and localization by constructing classification models (such as LeNet and ResNet) or object detection models (such as YOLO and Faster R-CNN). GAN-based schemes generate simulated defect samples through a generator, and a discriminator distinguishes between real and generated samples, improving detection capabilities in small sample scenarios. Transformer-based schemes capture global features of workpiece images using a self-attention mechanism, suitable for scenarios where defect features are dispersed. Furthermore, some deep learning schemes combine multimodal fusion technology, fusing optical and infrared image information to enhance the recognition of complex defects.
[0005] In traditional inspection technologies, manual visual inspection is extremely inefficient and cannot meet the needs of large-scale mass production. Moreover, the inspection results are affected by the experience and fatigue of personnel, resulting in strong subjectivity, unstable accuracy, and difficulty in identifying nanoscale defects. Traditional machine vision inspection has poor generalization ability, relies on fixed algorithms and preset thresholds, and has weak adaptability to changes in defect type, differences in workpiece surface texture, and lighting fluctuations. It is prone to missed detections (low-contrast defects) or false detections (surface textures are misjudged as defects). Furthermore, it has insufficient ability to extract features of nanoscale defects (such as pits with a size <1μm). To deal with complex defects, the algorithm needs to be redesigned, resulting in high debugging costs.
[0006] In machine learning-based detection technologies, shallow machine learning detection relies on manual feature engineering. Manually designed features struggle to fully capture the deep features of minute, low-contrast defects, resulting in insufficient model complexity to handle multi-scale and mixed defects. Furthermore, it requires a large number of labeled samples, making the collection and labeling of nanoscale defect samples difficult and costly. While deep learning detection addresses some traditional problems, it still has limitations: CNN-based solutions are sensitive to small sample sizes; when the number of defect samples is small (e.g., novel nanoscale defects), the model's generalization ability drops significantly. Deep CNN models also have many parameters, long training times, and high hardware computational requirements. GAN-based solutions suffer from mode collapse, generating insufficient diversity of defect samples, and the training process is prone to instability, making it difficult to accurately simulate real defect features. Transformer-based solutions have high computational complexity, resulting in low efficiency and poor real-time performance when detecting large-scale images of the entire workpiece surface. Moreover, multimodal fusion deep learning solutions require coordinating the consistency of data from different modalities, leading to complex data preprocessing. In special production environments such as high temperature and high humidity, modal data is easily interfered with, causing a decrease in fusion detection accuracy and making it difficult to meet high-precision detection requirements. Summary of the Invention
[0007] The purpose of this invention is to provide a surface defect detection system and method based on surface light source image acquisition and improved C-YOLO, so as to solve the problems mentioned in the background art.
[0008] To achieve the above objectives, the present invention provides the following technical solution: A surface defect detection system based on surface light source image acquisition and improved C-YOLO includes: a surface light source image acquisition system, a data acquisition and processing terminal, and a defect detection software system; The surface light source image acquisition system includes: Lens: 16mm fixed focal length lens; Camera: A monochrome industrial camera was selected and connected to the imaging end of the lens; Light source: Use a uniform surface light source; Stage: Used to fix workpiece samples and achieve minute translation and positioning; Data acquisition and processing terminal: The computer is responsible for image acquisition, image preprocessing, defect detection model training, and inference. The accompanying data acquisition software is used to control the image acquisition module to capture defect images and save the images to a specified path; Defect detection software system: It includes an image preprocessing module, a dataset construction module, a C-YOLO detection module, and a results visualization and statistics module.
[0009] As a further aspect of the present invention: Image acquisition process: The workpiece sample to be inspected is placed on a horizontal platform, and its position is coarsely adjusted by a mechanical structure. The surface light source image acquisition system is activated, and the industrial camera is focused on the workpiece surface. The industrial camera acquires images of the workpiece surface at a fixed focal length, covering different areas of the workpiece and different defect types. The light source brightness and exposure time are adjusted as needed to reduce noise and ensure that the image grayscale range is appropriate. The acquired images are classified and stored according to workpiece type and defect type. Image preprocessing and enhancement: The acquired images are preprocessed by distortion correction, cropping, rotation, contrast adjustment and size scaling. Random flipping, random cropping, color dithering and blur data enhancement strategies are used to improve the generalization performance of the model. Dataset construction: Label Studio annotation tool was used to annotate the surface defect images of the workpiece. A bounding box was drawn for each defect and the defect category was labeled. The dataset was divided into training set, validation set and test set in a ratio of 7:2:1.
[0010] A surface defect detection method based on surface light source image acquisition and improved C-YOLO includes the following steps: S1: Optimize and improve the YOLOv11 network algorithm; S1.1: In the backbone network part of the YOLOv11 network algorithm, the input image is extracted layer by layer through a multi-layer convolutional structure. An improved C3k2_HDRAB module is introduced to enhance the feature expression capability, enabling the network to extract more discriminative defect features on the surface of workpieces with complex lighting and obvious texture changes. S1.2: In the neck network of the YOLOv11 network algorithm, Conv2d convolutional layers, ELA_HSFPN enhanced feature fusion module and ConvTranspose2d upsampling structure are adopted to complete the interaction and transmission of high-level semantic information and low-level spatial information, thereby significantly enhancing the model's ability to perceive small defects and complex backgrounds, while maintaining the network's lightweight characteristics and computational efficiency. S1.3: In the detection head part of the YOLOv11 network algorithm, the LADH lightweight adaptive detection head is used to complete the classification and localization of targets at different scales. This structure improves detection accuracy and small target recognition performance while reducing the number of model parameters and computational cost. S2: Construct a surface light source image acquisition system; S3: Collect workpiece surface defects and create a workpiece surface defect dataset; S4: Train the optimized YOLOv11 network algorithm using the workpiece surface defect dataset to obtain the YOLOv11-C-YOLO target detection network algorithm for workpiece surface defect detection.
[0011] As a further aspect of the present invention: In S1.1, the improved C3k2_HDRAB module combines the advantages of dilated convolution, residual learning, and attention mechanisms. It includes multiple dilated convolutional layers with different dilation rates and ReLU activation functions. By combining dilated convolutions with d∈{1,2,4,8}, the receptive field can be increased exponentially from 1×1 to 31×31. This hybrid dilation design avoids the checkerboard effect of standard dilated convolution. When a single dilation rate is used, the convolution operation produces a regular checkerboard texture on the feature map. However, the hybrid dilation, through multiple complementary dilation rates, makes each convolution operation complement each other and completely cover every position of the feature map.
[0012] As a further aspect of the present invention: In S1.2, the original PAN structure and standard convolution are replaced by an ELA_HSFPN enhanced lightweight asymmetric hierarchical scale feature pyramid for feature fusion. The horizontal encoding is performed by pooling the feature map with a pooling kernel of size 1×W, compressing the feature dimension into a 1-dimensional sequence and preserving the spatial position information in the horizontal direction. The vertical encoding is performed by pooling with a pooling kernel of size H×1, preserving the position information in the vertical direction. Factoring significantly reduces computational complexity while effectively preserving key spatial location information; Horizontal encoding: ; Vertical coding: ; Independent direction processing: ; ; Final Fusion: ; in , for Convolution, with a kernel size of 7×1. For group normalization, there are 16 groups. It is the sigmoid activation function; This approach encodes positional information in the horizontal and vertical directions using strip pooling and one-dimensional convolution, enabling the network to more accurately locate minute defects while fully preserving the channel dimension of the features and avoiding feature degradation. From a computational efficiency perspective, processing sequences of length H or W using one-dimensional convolution requires only a fraction of the computational cost. Compared to two-dimensional convolution for processing connectivity features One-dimensional convolution significantly improves computational efficiency. The group normalization method used is less dependent on the mini-batch size than batch normalization, providing a more stable and consistent normalization effect. In the processing of each level of the feature pyramid, P5, P4, and P3, the processing parameters are flexibly adjusted according to the specific size of the feature map, making full use of the characteristics of multi-scale features.
[0013] As a further solution of the present invention: In S1.3, the LADH lightweight asymmetric detection head is used to replace the original structure. This module uses depthwise separable convolution to replace standard convolution and decomposes the detection task into three independent branches: confidence branch, classification branch and regression branch. Depthwise separable convolution decomposes the operation of standard convolution into two stages: depthwise convolution and pointwise convolution. Depthwise convolution performs independent convolution operations on each channel of the input features: ; Where c represents the c-th channel. Indicates the convolution operation; For an input with c channels, the depthwise convolution contains c independent 3×3 convolution kernels, and the pointwise convolution uses a 1×1 convolution to mix the channel information: ; in The weights of the 1×1 convolution kernel for the c-th channel; The complete depthwise separable convolution process is as follows: ; This decomposition method significantly reduces the number of parameters and computational complexity. The effect of parameter reduction is significant, and depthwise separable convolution achieves efficient utilization of parameters. The computational complexity (FLOPs) of standard convolution is: ; The computational complexity of depthwise separable convolution is: ; The reduction in computational workload is as follows: ; A three-branch structure is adopted: confidence branch, classification branch, and regression branch. The specific branch structure design is as follows: Confidence branch: ; Classification branches: ; Regression branch: ; Where f is the input feature. It is the sigmoid activation function.
[0014] Compared with the prior art, the beneficial effects of the present invention are: This invention constructs a workpiece surface defect image acquisition system consisting of a surface light source, a fixed-focus lens, an industrial camera, and an image acquisition terminal. It can obtain high-resolution, low-distortion workpiece surface images at a fixed magnification and constructs a dedicated dataset of various types of defects commonly found in industrial environments. Compared with traditional manual inspection and general visual acquisition schemes, it improves the representativeness of defect samples and the reliability of inspection results. This invention proposes a C-YOLO detection model based on YOLOv11n. By introducing improved structures such as C3k2_HDRAB into the backbone and combining it with the C2PSA context enhancement module, it effectively expands the receptive field, enhances the ability to express multi-scale features and suppress complex backgrounds without significantly increasing the amount of computation and parameters. It has higher detection accuracy and recall for small defects and low-contrast defects on the workpiece surface. This invention introduces the ELA_HSFPN enhanced lightweight asymmetric hierarchical feature pyramid and the LADH lightweight asymmetric decoupled detection head into the feature fusion and detection part. Compared with the existing detection methods based on the YOLO series, it significantly improves detection accuracy and processing speed while maintaining lightweight design. This makes it easy to realize online or near real-time automatic detection of workpiece surface defects in actual production lines, improve product yield and reduce manual inspection costs. Attached Figure Description
[0015] Figure 1 This is the YOLOv11n model structure.
[0016] Figure 2 This is the C-YOLO model structure of the present invention.
[0017] Figure 3 This is a structural diagram of the HDRAB model of the hybrid dense residual attention block of the present invention.
[0018] Figure 4 The diagram shows the addition of the HDRAB structure to the YOLOv11 backbone network in this invention.
[0019] Figure 5 This is a structural diagram of the enhanced lightweight asymmetric hierarchical scale feature pyramid ELA_HSFPN model of the present invention.
[0020] Figure 6 The diagram shows the structure of the ELA_HSFPN module added to the YOLOv11 neck network in this invention.
[0021] Figure 7 This is a structural diagram of the LADH lightweight asymmetric detection head model of the present invention.
[0022] Figure 8 The structural diagram of the LADH lightweight asymmetric detection head model is provided for this invention.
[0023] Figure 9 This is a schematic diagram of the system of the present invention. Detailed Implementation
[0024] Various exemplary embodiments, features, and aspects of this application will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.
[0025] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.
[0026] Furthermore, to better illustrate this application, numerous specific details are provided in the following detailed embodiments. Those skilled in the art should understand that this application can be implemented even without certain specific details. In some instances, methods, means, and elements well-known to those skilled in the art have not been described in detail in order to highlight the main points of this application.
[0027] A surface defect detection system based on surface light source image acquisition and improved C-YOLO includes: a surface light source image acquisition system, a data acquisition and processing terminal, and a defect detection software system; The surface light source image acquisition system includes: Lens: 16mm fixed focal length lens; Camera: A monochrome industrial camera was selected and connected to the imaging end of the lens; Light source: Use a uniform surface light source; Stage: Used to fix workpiece samples and achieve minute translation and positioning; Data acquisition and processing terminal: The computer is responsible for image acquisition, image preprocessing, defect detection model training, and inference. The accompanying data acquisition software is used to control the image acquisition module to capture defect images and save the images to a specified path; Defect detection software system: It includes an image preprocessing module, a dataset construction module, a C-YOLO detection module, and a results visualization and statistics module.
[0028] As a further aspect of the present invention: Image acquisition process: The workpiece sample to be inspected is placed on a horizontal platform, and its position is coarsely adjusted by a mechanical structure. The surface light source image acquisition system is activated, and the industrial camera is focused on the workpiece surface. The industrial camera acquires images of the workpiece surface at a fixed focal length, covering different areas of the workpiece and different defect types. The light source brightness and exposure time are adjusted as needed to reduce noise and ensure that the image grayscale range is appropriate. The acquired images are classified and stored according to workpiece type and defect type. Image preprocessing and enhancement: The acquired images are preprocessed by distortion correction, cropping, rotation, contrast adjustment and size scaling. Random flipping, random cropping, color dithering and blur data enhancement strategies are used to improve the generalization performance of the model. Dataset construction: Label Studio annotation tool was used to annotate the surface defect images of the workpiece. A bounding box was drawn for each defect and the defect category was labeled. The dataset was divided into training set, validation set and test set in a ratio of 7:2:1.
[0029] Combined with appendix Figure 1-9 A surface defect detection method based on surface light source image acquisition and improved C-YOLO includes the following steps: S1: Optimize and improve the YOLOv11 network algorithm; S1.1: In the backbone network part of the YOLOv11 network algorithm, the input image is extracted layer by layer through a multi-layer convolutional structure. An improved C3k2_HDRAB module is introduced to enhance the feature expression capability, enabling the network to extract more discriminative defect features on the surface of workpieces with complex lighting and obvious texture changes. S1.2: In the neck network of the YOLOv11 network algorithm, Conv2d convolutional layers, ELA_HSFPN enhanced feature fusion module and ConvTranspose2d upsampling structure are adopted to complete the interaction and transmission of high-level semantic information and low-level spatial information, thereby significantly enhancing the model's ability to perceive small defects and complex backgrounds, while maintaining the network's lightweight characteristics and computational efficiency. S1.3: In the detection head part of the YOLOv11 network algorithm, the LADH lightweight adaptive detection head is used to complete the classification and localization of targets at different scales. This structure improves detection accuracy and small target recognition performance while reducing the number of model parameters and computational cost. Preferably, in S1.1, the improved C3k2_HDRAB module combines the advantages of dilated convolution, residual learning, and attention mechanisms, containing multiple dilated convolutional layers with different dilation rates and ReLU activation functions, such as... Figure 3 and Figure 4As shown, by combining dilated convolutions of d∈{1,2,4,8}, the receptive field can be increased exponentially from 1×1 to 31×31. This hybrid dilation design avoids the checkerboard effect of standard dilated convolutions. When a single dilation rate is used, the convolution operation produces a regular checkerboard texture on the feature map. However, the hybrid dilation, through multiple complementary dilation rates, makes each convolution operation complement each other and fully cover every position of the feature map.
[0030] exist Figure 4 In this context, the symbol ⊗ represents element-wise multiplication. The channel attention module dynamically reweights the features of different channels, which can adaptively emphasize important features and effectively filter out irrelevant feature responses.
[0031] ; in ⊗ represents the Sigmoid activation function, and ⊗ represents element-wise multiplication. CAM achieves adaptive feature enhancement by dynamically adjusting the weights of each channel.
[0032] In summary, the complete calculation process for HDRAB is as follows: ; Preferably, in S1.2, the original PAN structure and standard convolution are replaced with an ELA_HSFPN enhanced lightweight asymmetric hierarchical scale feature pyramid for feature fusion, such as... Figure 5 and Figure 6 As shown, the horizontal encoding uses a pooling kernel of size 1×W to pool the feature map, compressing the feature dimension into a 1-dimensional sequence and preserving the spatial position information in the horizontal direction. The vertical encoding uses a pooling kernel of size H×1 to pool the feature map, preserving the position information in the vertical direction. Factoring significantly reduces computational complexity while effectively preserving key spatial location information; Horizontal encoding: ; Vertical coding: ; Independent direction processing: ; ; Final Fusion: ; in , for Convolution, with a kernel size of 7×1. For group normalization, there are 16 groups. It is the sigmoid activation function; This approach encodes positional information in the horizontal and vertical directions using strip pooling and one-dimensional convolution, enabling the network to more accurately locate minute defects while fully preserving the channel dimension of the features and avoiding feature degradation. From a computational efficiency perspective, processing sequences of length H or W using one-dimensional convolution requires only a fraction of the computational cost. Compared to two-dimensional convolution for processing connectivity features One-dimensional convolution significantly improves computational efficiency. The group normalization method used is less dependent on the mini-batch size than batch normalization, providing a more stable and consistent normalization effect. In the processing of each level of the feature pyramid, P5, P4, and P3, the processing parameters are flexibly adjusted according to the specific size of the feature map, making full use of the characteristics of multi-scale features.
[0033] Preferably, in S1.3, a lightweight asymmetric detection head of LADH is used to replace the original structure. This module uses depthwise separable convolution to replace standard convolution and decomposes the detection task into three independent branches: confidence branch, classification branch and regression branch. Depthwise separable convolution decomposes the operation of standard convolution into two stages: depthwise convolution and pointwise convolution. Depthwise convolution performs independent convolution operations on each channel of the input features: ; Where c represents the c-th channel. Indicates the convolution operation; For an input with c channels, the depthwise convolution contains c independent 3×3 convolution kernels, and the pointwise convolution uses a 1×1 convolution to mix the channel information: ; in The weights of the 1×1 convolution kernel for the c-th channel; The complete depthwise separable convolution process is as follows: ; This decomposition method significantly reduces the number of parameters and computational complexity. The effect of parameter reduction is significant, and depthwise separable convolution achieves efficient utilization of parameters. The computational complexity (FLOPs) of standard convolution is: ; The computational complexity of depthwise separable convolution is: ; The reduction in computational workload is as follows: ; A three-branch structure is adopted: confidence branch, classification branch, and regression branch. The specific branch structure design is as follows: Confidence branch: ; Classification branches: ; Regression branch: ; Where f is the input feature. It is the sigmoid activation function.
[0034] Furthermore, the independent branch design avoids gradient conflicts between classification and localization tasks, setting the classification loss as... Location loss is The confidence loss is ; The total loss of the standard coupled detection head is: ; Gradient flow is: ; Because the gradient directions of classification and localization tasks may be opposite or conflicting, and There are directional differences between them, but LADH uses an independent branch design, where each branch independently optimizes its own objective function, enabling each task to converge to its own optimal solution.
[0035] S2: Construct a surface light source image acquisition system; To collect different types of defects on the workpiece surface and create a workpiece surface defect dataset, firstly, different types of defects on the workpiece surface are collected using a surface light source acquisition system and a workpiece surface defect dataset is created. Then, the workpiece surface defect dataset is labeled using LabelStudio, and a labeled .txt file is generated and exported. The workpiece surface defect dataset and the corresponding .txt file are randomly divided into training set, validation set and test set in a ratio of 7:2:1.
[0036] S3: Collect workpiece surface defects and create a workpiece surface defect dataset; To evaluate the detection performance of the algorithm, mean average precision (mAP) was used as the main evaluation metric in the experiment. It is calculated from precision, recall, and mean precision (AP), and the calculation formula is shown below: ; Where TP represents the number of correctly detected predicted boxes for the corresponding defects, FP represents the number of incorrectly detected predicted boxes, and FN represents the number of undetected predicted boxes. The value of AP is the area enclosed by the PR curve and the coordinate axis, while mAP is the average AP for all detection categories, APi represents the average precision for a specific category in the dataset, and n is the number of defect types. In this invention, n=4.
[0037] The network modules of this invention were tested and compared using various combinations on a constructed workpiece surface defect dataset. Method 1: Adding an improved C3k2_HDRAB module to the backbone network; Method 2: Introducing an ELA_HSFPN enhanced feature fusion module into the neck network; Method 3: Using a lightweight LADH adaptive detection head in the detection head; Method 4: Adding an improved C3k2_HDRAB module to the backbone network and introducing an ELA_HSFPN enhanced feature fusion module into the neck network; Method 5: Adding an improved C3k2_HDRAB module to the backbone network and using a lightweight LADH adaptive detection head in the detection head; Method 6: Introducing an ELA_HSFPN enhanced feature fusion module into the neck network and using a lightweight LADH adaptive detection head in the detection head; Method 7: Using the C-YOLO target detection network proposed in this invention.
[0038] Five parameters—Precision, Recall, mAP50, mAP50-95, and FLOPs—were used as evaluation metrics in a comparative test experiment. The comparison results are shown in Table 1.
[0039] Table 1 Note: The dataset used above is the workpiece surface defect dataset collected from the Hefei Key Technology R&D "Challenge-Based" Project: Research on Key Technologies for Automated Production Line and Intelligent Detection of Isolation Gowns.
[0040] When used alone, HDRAB improves mAP by 1.9 percentage points, demonstrating the effectiveness of multi-scale feature extraction and channel attention mechanisms. The computational cost increases by only 1.6%, indicating that the cost increase from HDRAB is limited. HDRAB's contribution is even more significant when combined with other modules, demonstrating its good compatibility with subsequent modules.
[0041] When using ELA_HSFPN alone, mAP improved by 1.8 percentage points, demonstrating the effectiveness of location-aware feature fusion. The number of parameters actually decreased by 3.1%, indicating that the lightweight design of ELA_HSFPN is indeed effective.
[0042] When used alone, LADH improves mAP by 1.2 percentage points, demonstrating the effectiveness of location-aware feature fusion. Computational cost is reduced by 1.6 G FLOPs, indicating that LADH's lightweight effect is most significant. Combining with other modules further improves performance, proving the rationality of the task decoupling design. The combined effect of the three modules (2.3% improvement) is less than the simple sum of their individual contributions (approximately 4.9%), indicating negative cooperative interference between the modules, suggesting that different improvement directions may have slight conflicts in optimization objectives.
[0043] S4: Train the optimized YOLOv11 network algorithm using the workpiece surface defect dataset to obtain the YOLOv11-C-YOLO target detection network algorithm for workpiece surface defect detection.
[0044] The overall system design schematic diagram of the surface defect detection system and method based on surface light source image acquisition and C-YOLO described in this invention is shown below. Figure 9 As shown, the items and equipment required for a surface light source image acquisition system include: a black and white industrial camera, a lens, a water platform, a surface light source, a light source support, a workpiece surface defect sample, and a data acquisition terminal.
[0045] The hardware configuration used in this experiment is as follows: The system is Windows 11, the CPU is an Intel(R) Core(TM) Ultra 9 285K, and the GPU is an NVIDIA GeForce RTX 5080. The programming language is Python 3.10, and the deep learning framework used is PyTorch 2.7.1 with CUDA version 12.8. During model training, the optimizer used is stochastic gradient descent (SGD), with an initial learning rate of 0.001, momentum parameter of 0.9, weight decay coefficient of 0.0005, and other parameters kept at system default settings. The input image was set to 640×640 pixels, the batch size was set to 16, and the total number of training epochs was 300.
[0046] Furthermore, to verify the generalization ability of the model, it was validated on the publicly available PKU-Market-PCB dataset. The proposed C-YOLO algorithm was compared with mainstream object detection algorithms such as YOLOv11n and YOLOv12n, using five parameters—mAP50, mAP50-95, Param, FPS, and Weight—as evaluation metrics. The performance of different networks in detecting workpiece surface defects on the dataset is shown in Table 2 below.
[0047] Table 2 In comparisons with other YOLO models, C-YOLO ranked first in multiple metrics, including detection accuracy, recall, and mAP50, demonstrating superior overall performance. Compared to the YOLOv11n baseline model, C-YOLO improved mAP50 and mAP50-95 by 0.9 and 4.9 percentage points, respectively, reduced the number of model parameters by 6.18% to 2.43M, and reduced the model weights by 0.7% to 5.2M.
[0048] The performance of this model in identifying workpiece defects was compared with other algorithms. Analysis of the detection results shows that the C-YOLO model not only improves the confidence of the predicted boundaries and corrects false alarms and missed detections in the bounding boxes, but also corrects problems observed in other bounding boxes. Furthermore, the model enhances its ability to handle small-sized features and significantly improves the detection performance of stray defects. In conclusion, the C-YOLO model demonstrates strong performance in identifying workpiece defects.
[0049] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, it is intended that all variations falling within the meaning and scope of equivalents of the claims be included within the present invention.
[0050] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A surface defect detection system based on surface light source image acquisition and improved C-YOLO, comprising: The surface light source image acquisition system, data acquisition and processing terminal, and defect detection software system are characterized by: The surface light source image acquisition system includes: Lens: 16mm fixed focal length lens; Camera: A monochrome industrial camera was selected and connected to the imaging end of the lens; Light source: Use a uniform surface light source; Stage: Used to fix workpiece samples and achieve minute translation and positioning; Data acquisition and processing terminal: The computer is responsible for image acquisition, image preprocessing, defect detection model training, and inference. The accompanying data acquisition software is used to control the image acquisition module to capture defect images and save the images to a specified path; Defect detection software system: It includes an image preprocessing module, a dataset construction module, a C-YOLO detection module, and a results visualization and statistics module.
2. The surface defect detection system based on surface light source image acquisition and improved C-YOLO according to claim 1, characterized in that: Image acquisition process: Place the workpiece sample to be inspected on a horizontal platform, perform coarse position adjustment through mechanical structure, start the surface light source image acquisition system, and make the industrial camera focus on the workpiece surface. The industrial camera acquires images of the workpiece surface at a fixed focal length, covering different areas of the workpiece and different defect types. Adjust the light source brightness and exposure time as needed to reduce noise and ensure that the image grayscale range is appropriate. Classify and store the acquired images according to workpiece type and defect type. Image preprocessing and enhancement: The acquired images are preprocessed by distortion correction, cropping, rotation, contrast adjustment and size scaling. Random flipping, random cropping, color dithering and blur data enhancement strategies are used to improve the generalization performance of the model. Dataset construction: Label Studio annotation tool was used to annotate the surface defect images of the workpiece. A bounding box was drawn for each defect and the defect category was labeled. The dataset was divided into training set, validation set and test set in a ratio of 7:2:
1.
3. A surface defect detection method based on surface light source image acquisition and improved C-YOLO as described in claims 1-2, characterized in that, Includes the following steps: S1: Optimize and improve the YOLOv11 network algorithm; S1.1: In the backbone network part of the YOLOv11 network algorithm, the input image is extracted layer by layer through a multi-layer convolutional structure. An improved C3k2_HDRAB module is introduced to enhance the feature expression capability, enabling the network to extract more discriminative defect features on the surface of workpieces with complex lighting and obvious texture changes. S1.2: In the neck network of the YOLOv11 network algorithm, Conv2d convolutional layers, ELA_HSFPN enhanced feature fusion module and ConvTranspose2d upsampling structure are adopted to complete the interaction and transmission of high-level semantic information and low-level spatial information, thereby significantly enhancing the model's ability to perceive small defects and complex backgrounds, while maintaining the network's lightweight characteristics and computational efficiency. S1.3: In the detection head part of the YOLOv11 network algorithm, the LADH lightweight adaptive detection head is used to complete the classification and localization of targets at different scales. This structure improves detection accuracy and small target recognition performance while reducing the number of model parameters and computational cost. S2: Construct a surface light source image acquisition system; S3: Collect workpiece surface defects and create a workpiece surface defect dataset; S4: Train the optimized YOLOv11 network algorithm using the workpiece surface defect dataset to obtain the YOLOv11-C-YOLO target detection network algorithm for workpiece surface defect detection.
4. The surface defect detection method based on surface light source image acquisition and improved C-YOLO according to claim 2, characterized in that, In S1.1, the improved C3k2_HDRAB module combines the advantages of dilated convolution, residual learning, and attention mechanisms. It contains multiple dilated convolutional layers with different dilation rates and ReLU activation functions. By combining dilated convolutions with d∈{1,2,4,8}, the receptive field can be increased exponentially from 1×1 to 31×31. This hybrid dilation design avoids the checkerboard effect of standard dilated convolution. When a single dilation rate is used, the convolution operation produces a regular checkerboard texture on the feature map. However, the hybrid dilation, through multiple complementary dilation rates, makes each convolution operation complement each other and fully cover every position of the feature map.
5. The surface defect detection method based on surface light source image acquisition and improved C-YOLO according to claim 2, characterized in that, In S1.2, the original PAN structure and standard convolution are replaced by the ELA_HSFPN enhanced lightweight asymmetric hierarchical scale feature pyramid for feature fusion. The horizontal encoding is performed by pooling the feature map with a pooling kernel of size 1×W, compressing the feature dimension into a 1-dimensional sequence and preserving the spatial position information in the horizontal direction. The vertical encoding is performed by pooling with a pooling kernel of size H×1, preserving the position information in the vertical direction. Factoring significantly reduces computational complexity while effectively preserving key spatial location information; Horizontal encoding: ; Vertical coding: ; Independent direction processing: ; ; Final Fusion: ; in , for Convolution, with a kernel size of 7×1. For group normalization, there are 16 groups. It is the sigmoid activation function; This approach encodes positional information in the horizontal and vertical directions using strip pooling and one-dimensional convolution, enabling the network to more accurately locate minute defects while fully preserving the channel dimension of the features and avoiding feature degradation. From a computational efficiency perspective, processing sequences of length H or W using one-dimensional convolution requires only a fraction of the computational cost. Compared to two-dimensional convolution for processing connectivity features One-dimensional convolution significantly improves computational efficiency. The group normalization method used is less dependent on the mini-batch size than batch normalization, providing a more stable and consistent normalization effect. In the processing of each level of the feature pyramid, P5, P4, and P3, the processing parameters are flexibly adjusted according to the specific size of the feature map, making full use of the characteristics of multi-scale features.
6. The surface defect detection method based on surface light source image acquisition and improved C-YOLO according to claim 2, characterized in that, In S1.3, the LADH lightweight asymmetric detection head is used to replace the original structure. This module uses depthwise separable convolution to replace standard convolution and decomposes the detection task into three independent branches: confidence branch, classification branch and regression branch. Depthwise separable convolution decomposes the operation of standard convolution into two stages: depthwise convolution and pointwise convolution. Depthwise convolution performs independent convolution operations on each channel of the input features: ; Where c represents the c-th channel. Indicates the convolution operation; For an input with c channels, the depthwise convolution contains c independent 3×3 convolution kernels, and the pointwise convolution uses a 1×1 convolution to mix the channel information: ; in The weights of the 1×1 convolution kernel for the c-th channel; The complete depthwise separable convolution process is as follows: ; This decomposition method significantly reduces the number of parameters and computational complexity. The effect of parameter reduction is significant, and depthwise separable convolution achieves efficient utilization of parameters. The computational complexity (FLOPs) of standard convolution is: ; The computational complexity of depthwise separable convolution is: ; The reduction in computational workload is as follows: ; A three-branch structure is adopted: confidence branch, classification branch, and regression branch. The specific branch structure design is as follows: Confidence branch: ; Classification branches: ; Regression branch: ; Where f is the input feature. It is the sigmoid activation function.