Gear end face defect detection method based on multi-scale target detection
By improving the YOLOv8 model and combining GSConv, ECA, BiFPN and Wise-IoU loss functions, the problems of low detection accuracy of small targets and high computational resource consumption in gear end face defect detection are solved, achieving efficient and real-time industrial inspection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2025-01-09
- Publication Date
- 2026-05-29
AI Technical Summary
Existing gear end face defect detection technologies have shortcomings in terms of low detection accuracy for small targets, large interference from complex backgrounds, high computational resource consumption, insufficient lightweighting, and limited model generalization ability, making it difficult to meet the real-time detection needs of industrial scenarios.
A multi-scale object detection method is adopted, which combines the YOLOv8 model, grouped channel convolutional module (GSConv), efficient channel attention mechanism (ECA), bidirectional feature pyramid network (BiFPN) and Wise-IoU loss function to optimize feature extraction and bounding box regression, thereby improving detection accuracy and efficiency.
It significantly improves the accuracy and speed of gear end face defect detection, is suitable for industrial equipment with limited resources, enables efficient and real-time defect detection, reduces missed and false detections, and is adaptable to complex backgrounds and small target detection.
Smart Images

Figure CN119904444B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields of image processing of gear end faces and machine vision, and particularly relates to a gear end face defect detection method based on multi-scale object detection. Background Art
[0002] At present, the gear end face defect detection technology is an important quality control link in the industrial manufacturing field. Traditional gear end face defect detection methods mainly rely on manual detection or machine vision-based detection systems, but these methods have problems such as low efficiency and insufficient robustness. In recent years, object detection technologies based on deep learning have been widely used in defect detection. In particular, the YOLO series (You Only Look Once) models have become a popular choice for industrial defect detection due to their efficient real-time detection capabilities. However, in practical applications, existing deep learning models still have bottlenecks in the face of problems such as small object detection, complex background interference, and large model computing resource consumption. Especially when applied to edge devices with limited resources, the balance problem between model lightweight and detection accuracy needs to be solved urgently.
[0003] The main purposes of existing gear end face defect detection technologies are to improve the automation degree of detection, improve the detection accuracy, especially for the detection of tiny defects, and achieve efficient and real-time detection capabilities. Technical measures include using deep learning technologies for automatic identification and classification of defects. Common technical means include using convolutional neural networks (CNNs) for feature extraction, using YOLO series networks for real-time detection, and enhancing the model's capture of key features by introducing attention mechanisms. Some research introduced an efficient channel attention mechanism (ECA) into the backbone network of the YOLOv5 network during defect feature extraction, and improved the feature extraction ability by enhancing the network's attention to bearing surface defect information. The ECA mechanism trains weights in the channel dimension, enabling the network to better focus on defect information on the bearing surface while ignoring useless background information.
[0004] However, existing gear end face defect detection technologies have the following defects and deficiencies in practical applications:
[0005] (1) Insufficient adaptability of detection accuracy to complex backgrounds: Although existing technologies have improved in small object detection, for background interference in complex industrial scenarios, gear end faces are often affected by background interference such as oil stains and light changes. The detection model is still easily affected and difficult to effectively suppress background noise, resulting in missed detections and false detections.
[0006] (2) High computational resource consumption: Although existing models (such as YOLOv5, YOLOv8, etc.) have high detection efficiency, their computational load is large and the model parameters are too many. Especially when deployed on devices with limited resources (such as edge computing devices), it is difficult to meet the requirements of real-time detection.
[0007] (3) Insufficient lightweighting: Although some existing technologies have introduced lightweight convolution modules or attention mechanisms, these improvements are mostly focused on the optimization of individual modules. The overall model still has a large number of parameters and computational load, which cannot meet the deployment needs of edge devices with limited resources.
[0008] (4) Small target detection still has limitations: Most detection models are not good at extracting small target features, and these features are easily masked by background information. Since gear end face defects are usually small, existing models are difficult to accurately detect these tiny targets, resulting in frequent missed detections and false detections. Although the existing small target detection layer has improved the detection of tiny defects, it has limited performance for more complex gear end face defects (such as scratches and wear), especially in densely distributed defects, where it is still easy to miss detections.
[0009] (5) Limited generalization ability of the model: Existing gear detection models are usually trained on specific datasets, with weak generalization ability, making it difficult to adapt to complex industrial scenarios.
[0010] Therefore, existing technologies still have room for improvement in terms of detection accuracy, model lightweighting, and adaptability to complex backgrounds. In particular, when applied in actual industrial scenarios, how to effectively solve these problems is an urgent goal to be addressed. Summary of the Invention
[0011] The purpose of this invention is to solve the above-mentioned problems in the prior art and to provide a gear end face defect detection method based on multi-scale target detection. This method can effectively solve the problems of low detection accuracy of small targets, large background interference, and high consumption of computing resources, and is suitable for real-time detection needs in industrial production.
[0012] To achieve the above-mentioned objectives, the present invention specifically adopts the following technical solution:
[0013] In a first aspect, the present invention provides a method for detecting defects on the end face of gears based on multi-scale target detection, which includes the following steps:
[0014] S1. Set the data acquisition parameters for gear end face defect detection, and generate original images containing different types of gear end face defects based on the data acquisition parameters;
[0015] S2. Label the original image to generate a label file corresponding to the original image, and preprocess the original image. The processed image dataset consists of the label file and the preprocessed image.
[0016] S3. Add a small target detection layer to the YOLOv8 model, replace all splicing operations in the YOLOv8 model with a bidirectional feature pyramid network, replace one convolutional layer in the backbone network of the YOLOv8 model with a grouped channel convolutional module, and add an efficient channel attention mechanism before the SPPF module of the backbone network of the YOLOv8 model to obtain a gear end face defect detection model.
[0017] S4. Train the gear end face defect detection model on the processed image dataset, and update the parameters of the gear end face defect detection model based on the Wise-IoU loss function.
[0018] S5. Input the image to be detected into the trained gear end face defect detection model to obtain the gear end face defect detection result of the image to be detected.
[0019] Preferably, in step S1, the data acquisition parameters include the resolution of image acquisition, the range of image acquisition, and the frequency of image acquisition; the types of defects on the gear end face include scratches, broken teeth, and dents.
[0020] Preferably, in step S2, an image annotation tool is used to annotate the location of the gear end face defect on the original image, a label file is generated, and data augmentation is performed on the original image to obtain a preprocessed image.
[0021] Preferably, in step S4, during the training of the gear end face defect detection model, the preprocessed image is input into the backbone network of the gear end face defect detection model. The preprocessed image sequentially passes through the first convolutional layer, the second convolutional layer, and the first C2f module to obtain the first feature map. The first feature map sequentially passes through the third convolutional layer and the second C2f module to obtain the second feature map. The second feature map sequentially passes through the grouped channel convolutional module and the third C2f module to obtain the third feature map. The third feature map sequentially passes through the fourth convolutional layer, the fourth C2f module, the efficient channel attention mechanism, and the SPPF module to obtain the fourth feature map. The fourth feature map is upsampled, and the upsampled fourth feature map is compared with the third feature map. Figure 1 The input is fed into the first bidirectional feature pyramid network to obtain the fifth feature map. The fifth feature map is then fed into the fifth C2f module to obtain the sixth feature map. The sixth feature map is upsampled, and the upsampled sixth feature map is then compared with the second feature map. Figure 1The first feature map is input into the second bidirectional feature pyramid network to obtain the seventh feature map. The seventh feature map is then input into the sixth C2f module to obtain the eighth feature map. The first and eighth feature maps are then input into the small target detection layer. In the small target detection layer, the eighth feature map is first upsampled. The upsampled eighth feature map is then compared with the first feature map... Figure 1 The input is fed into the third bidirectional feature pyramid network to obtain the ninth feature map. This ninth feature map is then fed into the seventh C2f module to obtain the tenth feature map. The tenth feature map is then fed into the fifth convolutional layer to obtain the eleventh feature map, which is used as the output of the small object detection layer. The tenth feature map is then fed into the first detection layer to obtain the candidate detection boxes output by the small object detection layer. The eleventh feature map and the eighth feature map are then combined... Figure 1 The input is fed into the fourth bidirectional feature pyramid network and the eighth C2f module to obtain the twelfth feature map. This twelfth feature map is then fed into the second detection layer to obtain the candidate detection boxes output by the second detection layer. Finally, the twelfth feature map is fed into the sixth convolutional layer to obtain the thirteenth feature map. The thirteenth feature map and the sixth feature map are then combined... Figure 1 The input is fed into the fifth bidirectional feature pyramid network and the ninth C2f module to obtain the fourteenth feature map. This fourteenth feature map is then fed into the third detection layer to obtain the candidate detection boxes output by the third detection layer. Finally, the fourteenth feature map is fed into the seventh convolutional layer to obtain the fifteenth feature map. The fifteenth feature map and the fourth feature map are then combined... Figure 1 The input is fed into the sixth bidirectional feature pyramid network and the tenth C2f module to obtain the sixteenth feature map. The sixteenth feature map is then input into the fourth detection layer to obtain the candidate detection boxes output by the fourth detection layer. The Wise-IoU loss function between the candidate detection boxes output by each detection layer and the labeled ground truth detection boxes is calculated. Among all candidate detection boxes, the candidate detection box with the smallest Wise-IoU loss function is taken as the final matching detection box. The Wise-IoU loss function between the final matching detection box and the labeled ground truth detection box is calculated as the final Wise-IoU loss function. The parameters of the gear end face defect detection model are updated based on minimizing the final Wise-IoU loss function until the loss converges, resulting in the trained gear end face defect detection model.
[0022] Preferably, the Wise-IoU loss function L Wise-IoU The function form is as follows:
[0023]
[0024] In the formula: B gt B represents the true detection bounding box; p ∩ represents the candidate detection box; ∩ represents the intersection; ∪ represents the union; α represents the weight hyperparameter.
[0025] Preferably, the weight hyperparameter takes values in the range of [0.2, 1.0].
[0026] Preferably, the kernel size of the first convolutional layer and the fourth convolutional layer are both 3×3, the padding is 1, and the stride is 2.
[0027] Preferably, the kernel size of the second convolutional layer, the third convolutional layer, the fifth convolutional layer, the sixth convolutional layer, and the seventh convolutional layer are all 3×3, the padding is 1, and the stride is 1.
[0028] Preferably, in step S5, the detection result of the gear end face defect in the image to be detected includes the predicted gear end face defect type and the bounding box coordinates of the gear end face defect.
[0029] Compared with the prior art, the present invention has the following advantages:
[0030] The advantages of this invention lie in its innovative fusion of the traditional YOLOv8 model with an efficient channel attention mechanism (ECA), a small target detection layer, the GSConv module, and the Wise-IoU loss function. This results in a gear end-face defect detection model that significantly improves detection accuracy and efficiency through optimized feature extraction, lightweight design, and loss function strategies. The efficient channel attention mechanism enhances the model's focus on key features; the GSConv module achieves lightweighting by reducing computational load and feature redundancy; the small target detection layer improves the detection of minute defects; and the Wise-IoU loss function further optimizes bounding box regression, reducing false positives and false negatives and improving the model's convergence speed. This gear end-face defect detection model offers fast detection speed, small storage space, and excellent detection performance, providing a highly practical and innovative efficient detection method for large-scale industrial inspections. Attached Figure Description
[0031] Figure 1 This is a schematic diagram of the steps of the method of the present invention;
[0032] Figure 2 This is a schematic diagram illustrating parameter updates for the gear end face defect detection model of the present invention.
[0033] Figure 3 This is a schematic diagram of the gear end face defect detection model of the present invention. Detailed Implementation
[0034] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.
[0035] In the description of this invention, it should be understood that the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include at least one of those features.
[0036] To address the technical challenges of missing small targets, high computational resource requirements, complex background interference, and high real-time performance in gear end-face defect detection, this invention provides a gear end-face defect detection method based on multi-scale target detection. This method aims to improve the detection accuracy and speed of surface defects in industrial equipment, especially in complex backgrounds and with small targets. The method uses a grouped channel convolutional module (GSConv) instead of a standard convolutional layer in the backbone of the YOLOv8 network, reducing the computational complexity of the gear end-face defect detection model. An efficient channel attention mechanism is incorporated into the feature extraction part to enhance the model's focus on important features, particularly by weighting important channels in the feature map to improve detection accuracy. A bidirectional feature pyramid network (BiFPN) is used in the feature classification process to improve the model's adaptability to defects of different scales. The Wise-IoU loss function and a small target detection layer are employed to improve the accuracy of bounding box regression, thereby enhancing the detection performance of small targets. The method of this invention outperforms existing technologies in terms of detection accuracy, computational complexity, and real-time performance. It is suitable for real-time defect detection on embedded devices, enabling efficient and real-time gear end face defect detection, and is applicable to resource-constrained industrial scenarios.
[0037] like Figure 1 As shown, in a preferred embodiment of the present invention, the gear end face defect detection method based on multi-scale target detection includes the following steps S1 to S5. The specific implementation process of each step will be described in detail below.
[0038] S1. Set the data acquisition parameters for gear end face defect detection, and generate original images containing different types of gear end face defects based on the data acquisition parameters.
[0039] It should be noted that in step S1 of this invention, the data acquisition parameters for gear end face defect detection are set, including the image acquisition resolution, acquisition range, and frequency, to ensure coverage of different types of gear end face defects, including scratches, broken teeth, and dents. Then, the data acquisition parameters are adjusted to collect original images containing different types of gear end face defects such as scratches and dents, ensuring the diversity and comprehensiveness of the data, and obtaining the original image dataset.
[0040] S2. Label the original images to generate label files corresponding to the original images, and preprocess the original images. The processed image dataset consists of the label files and the preprocessed images.
[0041] It should be noted that in step S2 of this invention, the original image dataset is labeled and preprocessed, specifically by using the open-source image labeling tool LabelImg to label the location of the gear end face defect on the original image, generating a label file, and performing data augmentation on the original image to improve the generalization ability of the gear end face defect detection model.
[0042] S3. Add a small target detection layer to the YOLOv8 model, replace all splicing operations in the YOLOv8 model with a bidirectional feature pyramid network, replace one convolutional layer in the backbone network of the YOLOv8 model with a grouped channel convolutional module, and add an efficient channel attention mechanism before the SPPF module of the backbone network of the YOLOv8 model to obtain the gear end face defect detection model.
[0043] It should be noted that this invention improves the YOLOv8 model to obtain a gear end-face defect detection model. Specifically, the improvements include: integrating the GSConv module into the backbone network to enhance feature extraction capabilities, and adding an ECA attention mechanism to highlight key feature information. Feature fusion is achieved through BiFPN, and upsampling operations are used to ensure the alignment of features at different scales, providing rich feature information for the detection layer. A multi-detection layer structure is constructed, and the feature maps extracted by BiFPN are transformed into the output of the small target detection layer through the detection layer, improving the gear end-face defect detection model's ability to detect minute defects on the gear surface.
[0044] This invention improves the defect detection performance of the YOLOv8 model by making a series of improvements to the backbone network, neck, and detection head, including the introduction of grouped channel convolutional modules, efficient channel attention mechanisms, and bidirectional feature pyramid networks. The final result is a gear end-face defect detection model, which specifically includes the following parts:
[0045] 1) Backbone Network: Implemented based on YOLOv8, this backbone network is responsible for the initial extraction of multi-scale features from the gear end face. One of the standard convolutions in this backbone network is replaced with a grouped channel convolution module (GSConv). By using smaller convolutional kernels, optimized convolutional structures, spatial grouping, and pseudo-feature generation mechanisms, the computational cost and redundant feature information in spatial and channel dimensions are significantly reduced, making defect detection more efficient in complex backgrounds. Simultaneously, an efficient channel attention (ECA) mechanism is added before the SPPF module to enhance feature interactions between channels without adding extra parameters, focusing on key defect regions. This lightweight 1D convolution efficiently enhances channel features, effectively improving the gear end face defect detection model's attention to gear end face defects while maintaining computational efficiency and global information capture.
[0046] Specifically, the grouped channel convolution module GSConv employs a combination of group convolution and pointwise convolution, reducing computational cost while maintaining feature extraction capabilities, thus achieving a lightweight design and accelerating model inference. This improvement is particularly suitable for resource-constrained embedded devices, ensuring the model's real-time performance and effectiveness. The introduction of GSConv not only reduces computational complexity but also plays a good balance in maintaining feature representation capabilities. The ECA attention mechanism enhances the model's focus on key features by weighting the features of each channel in the feature map, thereby effectively improving the detection accuracy of small target defects. In the ECA attention mechanism, the channel weights are dynamically adjusted based on global information. This adaptive weighting method allows the model to more accurately focus on the most important features, especially advantageous in complex backgrounds. Furthermore, the implementation methods of GSConv and the ECA attention mechanism are existing technologies and will not be elaborated further.
[0047] 2) Small Target Detection Layer: Located in the neck of YOLOv8, this is a newly added structure. It is used to more accurately identify small defects on the gear end face by upsampling and fusing with the low-level features of the backbone network. This layer processes feature maps with a resolution of 160×160, which improves the accuracy of detecting small defects on the gear end face, effectively reduces the phenomenon of missed detection, and makes the model more reliable when dealing with small defects in industrial equipment.
[0048] 3) Bidirectional Feature Pyramid Network (BiFPN): By effectively fusing feature maps from different scales, it enhances the adaptability of the gear end face defect detection model to defects of various sizes, thereby improving detection accuracy.
[0049] Specifically, in the neck structure, this invention employs a Bidirectional Feature Pyramid Network (BiFPN) instead of the original feature fusion method. BiFPN achieves adaptive control of features at different scales through the fusion of repeatedly weighted multi-scale feature maps, effectively improving the model's performance in detecting multi-scale targets. BiFPN allows the model to dynamically adjust the contribution of features at different scales during feature fusion, which is particularly important for scenarios containing both large and small targets, thereby ensuring detection accuracy and robustness.
[0050] The implementation of the Bidirectional Feature Pyramid Network (BiFPN) is existing technology. To facilitate understanding by those skilled in the art, its implementation is briefly described below. The BiFPN contains bidirectional pathways: a top-down pathway and a bottom-up pathway. The top-down pathway transmits semantic information from high-level features, while the bottom-up pathway transmits positional information from low-level features. Furthermore, an additional connection pathway is added between input and output nodes within the same layer. In BiFPN, initial feature fusion is achieved through lateral connections and downsampling layers. Feature maps at different scales extracted by the main CSPDarkNet layer are downsampled and fused through lateral connections. Subsequently, a second feature fusion is achieved with downsampling and upsampling layers of the same scale through skip connections. Skip connections enable BiFPN to transfer information between feature maps of different scales, thus better fusing multi-scale information. Finally, the multi-scale feature maps obtained after multiple feature fusions are input into the detector to complete the object detection task. Through multiple feature fusions, BiFPN can more accurately capture the features of the target, thereby improving the accuracy of object detection.
[0051] 4) Wise-IoU loss function: By introducing a dynamic non-monotonic focusing mechanism, the bounding box regression process is optimized, the anchor box regression error is reduced, the anchor box error accumulation is avoided, the convergence of the gear end face defect detection model is accelerated, the impact of low-quality images on model training is reduced, and the gear end face defect detection model performs more accurately in small target detection.
[0052] Based on the above structural design, the detection accuracy, computational complexity, and real-time performance are all superior to existing technologies, making it suitable for efficient and real-time gear end face defect detection in resource-constrained industrial scenarios.
[0053] S4. Train the gear end face defect detection model on the processed image dataset, and update the parameters of the gear end face defect detection model based on the Wise-IoU loss function.
[0054] It should be noted that during the training of the gear end face defect detection model in step S4 of this invention, such as Figure 3As shown, the preprocessed image is input into the backbone network of the gear end face defect detection model. The preprocessed image sequentially passes through the first convolutional layer, the second convolutional layer, and the first C2f module to obtain the first feature map. The first feature map sequentially passes through the third convolutional layer and the second C2f module to obtain the second feature map. The second feature map sequentially passes through the grouped channel convolutional module and the third C2f module to obtain the third feature map. The third feature map sequentially passes through the fourth convolutional layer, the fourth C2f module, the efficient channel attention mechanism, and the SPPF module to obtain the fourth feature map. The fourth feature map is upsampled, and the upsampled fourth feature map and the third feature map are then compared. Figure 1 The input is fed into the first bidirectional feature pyramid network to obtain the fifth feature map. The fifth feature map is then fed into the fifth C2f module to obtain the sixth feature map. The sixth feature map is upsampled, and the upsampled sixth feature map is then compared with the second feature map. Figure 1 The first feature map is input into the second bidirectional feature pyramid network to obtain the seventh feature map. The seventh feature map is then input into the sixth C2f module to obtain the eighth feature map. The first and eighth feature maps are then input into the small target detection layer. In the small target detection layer, the eighth feature map is first upsampled. The upsampled eighth feature map is then compared with the first feature map... Figure 1 The input is fed into the third bidirectional feature pyramid network to obtain the ninth feature map. This ninth feature map is then fed into the seventh C2f module to obtain the tenth feature map. The tenth feature map is then fed into the fifth convolutional layer to obtain the eleventh feature map, which is used as the output of the small object detection layer. The tenth feature map is then fed into the first detection layer to obtain the candidate detection boxes output by the small object detection layer. The eleventh feature map and the eighth feature map are then combined... Figure 1 The input is fed into the fourth bidirectional feature pyramid network and the eighth C2f module to obtain the twelfth feature map. This twelfth feature map is then fed into the second detection layer to obtain the candidate detection boxes output by the second detection layer. Finally, the twelfth feature map is fed into the sixth convolutional layer to obtain the thirteenth feature map. The thirteenth feature map and the sixth feature map are then combined... Figure 1 The input is fed into the fifth bidirectional feature pyramid network and the ninth C2f module to obtain the fourteenth feature map. This fourteenth feature map is then fed into the third detection layer to obtain the candidate detection boxes output by the third detection layer. Finally, the fourteenth feature map is fed into the seventh convolutional layer to obtain the fifteenth feature map. The fifteenth feature map and the fourth feature map are then combined... Figure 1The input is fed into the sixth bidirectional feature pyramid network and the tenth C2f module to obtain the sixteenth feature map. The sixteenth feature map is then input into the fourth detection layer to obtain the candidate detection boxes output by the fourth detection layer. The Wise-IoU loss function between the candidate detection boxes output by each detection layer and the labeled ground truth detection boxes is calculated. Among all candidate detection boxes, the candidate detection box with the smallest Wise-IoU loss function is taken as the final matching detection box. The Wise-IoU loss function between the final matching detection box and the labeled ground truth detection box is calculated as the final Wise-IoU loss function. The parameters of the gear end face defect detection model are updated based on minimizing the final Wise-IoU loss function until the loss converges, resulting in the trained gear end face defect detection model.
[0055] It should be noted that in this embodiment, the kernel size of the first convolutional layer and the fourth convolutional layer are both 3×3, the padding is 1, and the stride is 2. The kernel size of the second convolutional layer, the third convolutional layer, the fifth convolutional layer, the sixth convolutional layer, and the seventh convolutional layer are all 3×3, the padding is 1, and the stride is 1.
[0056] In this embodiment, as Figure 2 As shown, the parameters of the gear end face defect detection model only need to be updated in areas that differ from the YOLOv8 model, such as the bidirectional feature pyramid network, grouped channel convolutional module, small object detection layer, and efficient channel attention mechanism. The remaining structure, identical to the YOLOv8 model, requires no parameter updates. Before model training, a training strategy is first formulated, including setting hyperparameters such as learning rate adjustment scheme, loss function weight ratio, and training batch size. The focus is on optimizing the small object detection layer's recognition performance for small objects, improving its ability to detect small-sized defects (such as micro-scratches and wear). After training, model performance is evaluated, analyzing the small object detection layer's accuracy, recall, and mAP for small object detection to verify the model's detection effectiveness. During the model detection performance evaluation process, the types and locations of detected defects are recorded and analyzed, with particular attention paid to false positives and false negatives, especially the detection performance in complex backgrounds. Based on the analysis of false positives and false negatives, the parameter configuration of the GSConv module, the weights of the ECA attention mechanism, and the parameters of the small target detection layer were adjusted. The configuration of BiFPN was optimized to improve the small target detection performance. The detection strategy of the model was also optimized to further improve the detection accuracy and recall. Finally, a lightweight gear end face defect detection model was generated and deployed in an industrial production environment for actual detection. The detection effect and running performance of the model in the real scene were recorded.
[0057] It should be noted that in step S4 of this invention, to further improve the accuracy of the bounding boxes, Wise-IoU is used as the loss function for bounding box regression. Compared with the traditional IoU loss function, Wise-IoU can better handle the overlap between bounding boxes, accelerate the model's convergence process, and improve the accuracy of bounding box localization. Through the improved loss function design, the model can achieve better localization results in a shorter training time, thereby reducing the occurrence of false positives and false negatives.
[0058] In this embodiment, the Wise-IoU loss function L Wise-IoU The function form is as follows:
[0059]
[0060] In the formula: B gt B represents the true detection bounding box; p ∩ represents the candidate detection box; ∩ represents the intersection; ∪ represents the union; α represents the weight hyperparameter, which ranges from [0.2, 1.0].
[0061] It should be noted that in step S4 of this invention, for the gear end face defect detection model, in addition to the Efficient Channel Attention (ECA) mechanism, other attention mechanisms or feature fusion methods can also be used, such as the SE layer (Squeeze-and-Excitation) or CBAM (Convolutional Block Attention Module). However, these methods may not be as efficient as ECA in terms of lightweight performance. The SE layer enhances the representation of important features in the channel dimension, while CBAM enhances feature extraction in both spatial and channel dimensions. However, compared to ECA, their computational complexity is slightly higher, which may increase the demand for computing resources. In addition, the traditional FPN (Feature Pyramid Network) can also replace the GSConv module as a multi-scale feature fusion method. However, although the traditional FPN has good feature fusion capabilities, it may not be as efficient as the GSConv module in terms of lightweight performance and real-time performance. GSConv reduces the computational load by generating pseudo-features, while FPN is relatively more complex.
[0062] S5. Input the image to be detected into the trained gear end face defect detection model to obtain the gear end face defect detection result of the image to be detected.
[0063] It should be noted that in step S5, the detection result of the gear end face defect in the image to be detected includes the predicted gear end face defect type and the bounding box coordinates of the gear end face defect.
[0064] This invention, based on the YOLOv8 network model, introduces an efficient channel attention mechanism (ECA), a grouped channel convolution module (GSConv), and a small target detection layer, and designs an optimization strategy for the Wise-IoU loss function to improve gear end-face defect detection. These technological innovations constitute the core of this invention, ensuring the efficiency, accuracy, and real-time performance of the gear end-face defect detection process, making it particularly suitable for large-scale applications in industrial environments. Specifically, the efficient channel attention mechanism enhances the gear end-face defect detection model's focus on key defect features, while the grouped channel convolution module reduces redundancy in spatial and channel dimensions, lowering the computational load and parameter count of the gear end-face defect detection model, achieving a lightweight design. Simultaneously, the small target detection layer significantly improves the detection accuracy and recall rate for minute gear defects. Through these improvements, this invention exhibits significant advantages in the following aspects:
[0065] (1) Improved feature extraction efficiency: By introducing a lightweight grouped channel convolution module, the computational complexity of the gear end face defect detection model is reduced, while maintaining high-quality feature extraction, making the gear end face defect detection model more suitable for resource-limited environments.
[0066] (2) Improved small target detection performance: The combination of efficient channel attention mechanism and small target detection layer significantly improves the detection accuracy of small targets in complex backgrounds and multi-scale scenarios, reducing missed detections and false detections.
[0067] (3) Enhancement of multi-scale feature fusion: The efficient fusion of feature maps is achieved through the bidirectional feature pyramid network (BiFPN), which improves the adaptability of the gear end face defect detection model to defects of different scales, enabling the gear end face defect detection model to work stably in various complex industrial scenarios.
[0068] (4) More accurate bounding box positioning: The Wise-IoU loss function is adopted, which enables the gear end face defect detection model to perform better bounding box regression, reduces the error of overlapping areas, and ensures accurate positioning of defect areas.
[0069] In summary, this invention achieves efficient and accurate detection of surface defects in industrial equipment through various improvements to the YOLOv8 network model structure, especially excelling in the detection of complex backgrounds and small targets, thus meeting the requirements for high precision, real-time performance, and lightweight design for gear end face defect detection in complex environments.
[0070] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.
Claims
1. A method for detecting defects on the end face of gears based on multi-scale target detection, characterized in that, Includes the following steps: S1. Set the data acquisition parameters for gear end face defect detection, and generate original images containing different types of gear end face defects based on the data acquisition parameters; S2. Label the original image to generate a label file corresponding to the original image, and preprocess the original image. The processed image dataset consists of the label file and the preprocessed image. S3. Add a small target detection layer to the YOLOv8 model, replace all splicing operations in the YOLOv8 model with a bidirectional feature pyramid network, replace one convolutional layer in the backbone network of the YOLOv8 model with a grouped channel convolutional module, and add an efficient channel attention mechanism before the SPPF module of the backbone network of the YOLOv8 model to obtain a gear end face defect detection model. S4. Train the gear end face defect detection model on the processed image dataset, and update the parameters of the gear end face defect detection model based on the Wise-IoU loss function. S5. Input the image to be detected into the trained gear end face defect detection model to obtain the gear end face defect detection result of the image to be detected; In step S4, during the training of the gear end face defect detection model, the preprocessed image is input into the backbone network of the gear end face defect detection model. The preprocessed image sequentially passes through the first convolutional layer, the second convolutional layer, and the first C2f module to obtain the first feature map. The first feature map sequentially passes through the third convolutional layer and the second C2f module to obtain the second feature map. The second feature map sequentially passes through the grouped channel convolutional module and the third C2f module to obtain the third feature map. The third feature map sequentially passes through the fourth convolutional layer, the fourth C2f module, the efficient channel attention mechanism, and the SPPF module to obtain the fourth feature map. The fourth feature map is upsampled, and the upsampled fourth feature map and the third feature map are combined... The first feature map is input into the first bidirectional feature pyramid network to obtain the fifth feature map. The fifth feature map is then input into the fifth C2f module to obtain the sixth feature map. The sixth feature map is upsampled, and the upsampled sixth feature map, along with the second feature map, is input into the second bidirectional feature pyramid network to obtain the seventh feature map. The seventh feature map is input into the sixth C2f module to obtain the eighth feature map. The first and eighth feature maps are then input into the small target detection layer. In the small target detection layer, the eighth feature map is first upsampled. The upsampled eighth feature map, along with the first feature map, is input into the third bidirectional feature pyramid network to obtain the ninth feature map. The ninth feature map is input into the seventh C2f module to obtain the tenth feature map. The image is input to the fifth convolutional layer to obtain the eleventh feature map, which is then used as the output of the small object detection layer. The tenth feature map is input to the first detection layer to obtain the candidate detection boxes output by the small object detection layer. The eleventh and eighth feature maps are input together to the fourth bidirectional feature pyramid network and the eighth C2f module to obtain the twelfth feature map. The twelfth feature map is input to the second detection layer to obtain the candidate detection boxes output by the second detection layer. The twelfth feature map is input to the sixth convolutional layer to obtain the thirteenth feature map. The thirteenth and sixth feature maps are input together to the fifth bidirectional feature pyramid network and the ninth C2f module to obtain the fourteenth feature map. The fourteenth feature map is input to the third detection layer to obtain the output of the third detection layer. The candidate detection boxes are processed by inputting the fourteenth feature map into the seventh convolutional layer to obtain the fifteenth feature map. This fifteenth and fourth feature maps are then input into the sixth bidirectional feature pyramid network and the tenth C2f module to obtain the sixteenth feature map. This sixteenth feature map is then input into the fourth detection layer to obtain the candidate detection boxes output by the fourth detection layer. The Wise-IoU loss function between each candidate detection box and the labeled ground truth detection box is calculated. The candidate detection box with the smallest Wise-IoU loss function is selected as the final matching detection box, and the Wise-IoU loss function between the final matching detection box and the labeled ground truth detection box is calculated as the final Wise-IoU loss function.The parameters of the gear end face defect detection model are updated by minimizing the final Wise-IoU loss function until the loss converges, resulting in a trained gear end face defect detection model.
2. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, In step S1, the data acquisition parameters include the resolution of image acquisition, the range of image acquisition, and the frequency of image acquisition.
3. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, In step S1, the types of defects on the gear end face include scratches, broken teeth, and dents.
4. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, In step S2, the location of the gear end face defect is marked on the original image using an image annotation tool to generate a label file, and the original image is augmented to obtain a preprocessed image.
5. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, The Wise-IoU loss function The function form is as follows: ; In the formula: Represents the actual detection bounding box; Represents candidate detection boxes; This indicates finding the intersection; This represents taking the union of sets; This represents the weight hyperparameter.
6. The gear end face defect detection method based on multi-scale target detection as described in claim 5, characterized in that, The weight hyperparameter takes values in the range of [0.2, 1.0].
7. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, The kernel size of the first convolutional layer and the fourth convolutional layer are both 3×3, the padding is 1, and the stride is 2.
8. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, The kernel size of the second, third, fifth, sixth, and seventh convolutional layers is 3×3, the padding is 1, and the stride is 1.
9. The gear end face defect detection method based on multi-scale target detection as described in claim 1, characterized in that, In step S5, the detection results of the gear end face defects in the image to be detected include the predicted gear end face defect type and the bounding box coordinates of the gear end face defects.