Gear defect detection method, apparatus, device, and medium

By improving the YOLOv11 model and introducing the FEM module, GAM-SE cascaded attention mechanism, α-IoU loss function, and Focal Loss mechanism, the problems of large influence of lighting environment, low detection accuracy, and high computational complexity in EMB small module gear detection are solved, and efficient online monitoring in industrial fields is realized.

CN120747100BActive Publication Date: 2025-12-30GUANGZHOU KORMEE AUTOMOTIVE ELECTRONICS CONTROL TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511256066.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2025-12-30
Estimated Expiration
2045-09-04

AI Technical Summary

Technical Problem

Existing gear defect detection methods are greatly affected by the lighting environment in EMB small module gears, resulting in low detection accuracy, strong dependence, difficulty in achieving real-time online monitoring, high computational complexity, high hardware investment and complex deployment, and difficulty in meeting the high-speed detection requirements of industrial sites.

Method used

An improved YOLOv11 model is adopted, which introduces the FEM module, GAM-SE cascaded attention mechanism, α-IoU loss function and Focal Loss mechanism. Through multi-scale feature extraction and cross-branch attention interaction, the defect feature capture capability is enhanced, the detection accuracy and real-time performance are improved, and the computational complexity is reduced.

Benefits of technology

It significantly improves the detection accuracy and real-time performance of minute defects on the surface of small module gears, reduces computational complexity and hardware costs, adapts to the detection of various defect types under complex backgrounds, and realizes efficient online monitoring in industrial settings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120747100B_ABST
    Figure CN120747100B_ABST
Patent Text Reader

Abstract

The application relates to a gear defect detection method, device, equipment and medium, the method comprising: acquiring a to-be-detected gear image containing multiple gear defect types; updating a third C3k2 module in a backbone network of a preset first gear defect detection model into an FEM module, introducing a GAM-SE cascaded attention mechanism module into the backbone network, updating an IoU loss function of the first gear defect detection model into an alpha-IoU loss function, and introducing a Focal Loss mechanism to construct a second gear defect detection model; inputting a second enhanced defect feature map into a detection head network in the second gear defect detection model to detect gear defect types in the to-be-detected gear image, and transmitting corresponding defect alarm instructions of the gear defect types to an operation interface in a gear defect detection system. The application greatly improves the precision of the model in micro defect positioning, and is especially suitable for detecting small modulus gear surface micro defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image recognition, and in particular to a method for detecting gear defects, a corresponding device, electronic equipment, and a computer-readable storage medium. Background Technology

[0002] Traditional gear inspection methods primarily rely on manual labor, which suffers from low efficiency and a high rate of missed detections, making it unsuitable for the high-speed, fully automated gear inspection required on EMB assembly lines. In recent years, computer vision technology has developed rapidly, and researchers have been actively exploring computer vision-based gear defect detection methods. It is worth noting that while existing gear defect detection methods have achieved some degree of identification and assessment of gear defects, they still have the following shortcomings in the application scenarios of small-module EMB gears:

[0003] Firstly, for the detection of minute defects in pinions with EMB modules of 0.6-1.2, traditional vision methods are greatly affected by the lighting environment, have strong dependence, and are prone to losing defect features during downsampling, resulting in low detection accuracy, a high probability of defective parts leaving the production line, and high hardware investment, complex deployment, and poor adaptability to the field environment.

[0004] Secondly, in EMB's fully automated mass production lines, the required speed for gear inspection exceeds 200 FPS. However, conventional deep learning models have large inference latency and are more inclined to offline and periodic inspections. They lack the ability to monitor the real-time status of gear systems in industrial settings, which is not conducive to timely intervention and closed-loop control to remove defective gears.

[0005] Third, although the proposed models have high detection accuracy, models that combine convolutional neural networks (CNN) and long short-term memory networks (LSTM) have high computational complexity, making them difficult to deploy on terminals.

[0006] Fifth, the use of 3D sample data is limited by 3D reconstruction capabilities, and the 3D reconstruction process of gears relies on features such as edges and corners extracted from images. If the image has problems such as noise, uneven lighting, or occlusion, it may lead to inaccurate modeling, thereby affecting the accuracy of defect area and geometric indicators, ultimately resulting in low overall detection accuracy.

[0007] In summary, existing gear defect detection methods are highly susceptible to the influence of lighting conditions, have strong dependence on lighting, are prone to losing defect features during downsampling, resulting in low detection accuracy, and suffer from large inference latency in conventional deep learning models. These methods are more inclined towards offline and periodic detection and lack the ability to monitor the real-time status of gear systems in industrial settings. Therefore, a new solution is urgently needed. Summary of the Invention

[0008] The purpose of this application is to solve the above-mentioned problems by providing a method for detecting gear defects, a corresponding device, an electronic device, and a computer-readable storage medium.

[0009] To achieve the various objectives of this application, the following technical solution is adopted:

[0010] A gear defect detection method proposed for one of the purposes of this application includes:

[0011] Acquire images of the gear to be inspected, which contain multiple types of gear defects;

[0012] The third C3k2 module in the backbone network of the preset first gear defect detection model is updated to an FEM module. A GAM-SE cascaded attention mechanism module is introduced into the backbone network. The IoU loss function of the first gear defect detection model is updated to an α-IoU loss function, and a Focal Loss mechanism is introduced to construct a second gear defect detection model. The GAM-SE cascaded attention mechanism module includes a GAM spatial attention mechanism module and an SE channel attention mechanism module.

[0013] The gear image to be detected is input into the second gear defect detection model that has been trained to convergence. In the middle branch of the multi-branch convolution module in the FEM module, a dilated convolution layer is introduced to expand the receptive field to capture contextual information. In parallel, multi-scale and multi-receptive field defect features in the gear image to be detected are extracted to construct an intermediate feature map. After being processed by the cross-branch attention interaction module, the first enhanced defect feature map is output.

[0014] In the GAM spatial attention mechanism module, the spatial location of the defect feature is focused in the first enhanced defect feature map by modeling the long-distance dependency between the global space and the channel. In the SE channel attention mechanism module, the channel features are adaptively recalibrated to highlight the channel of the defect feature, so as to output the second enhanced defect feature map.

[0015] The second enhanced defect feature map is input into the detection head network in the second gear defect detection model to detect the gear defect type in the gear image to be detected. Based on the gear defect type, a corresponding defect alarm command is generated and transmitted to the operation interface of the gear defect detection system to complete the fault detection of gear defects.

[0016] Optionally, the GAM-SE cascaded attention mechanism module includes a GAM spatial attention mechanism module and an SE channel attention mechanism module;

[0017] The backbone network of the second gear defect detection model includes, in sequence, an input layer, a first convolutional layer, a second convolutional layer, a first C3k2 module, a third convolutional layer, a second C3k2 module, a fourth convolutional layer, an FEM module, a fifth convolutional layer, a third C3k2 module, a GAM spatial attention mechanism module, an SPPF module, and an SE channel attention mechanism module;

[0018] The FEM module includes a multi-branch convolution module and a cross-branch attention interaction module. The multi-branch convolution module includes a 1×3 convolution kernel branch, a 3×1 convolution kernel branch, and a 3×3 convolution kernel branch. A dilated convolution layer is introduced in the 3×3 convolution kernel branch.

[0019] Optionally, the step of introducing a dilated convolutional layer in the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field to capture contextual information, and extracting multi-scale, multi-receptive field defect features in the gear image to be detected in parallel to construct an intermediate feature map, which is then input to the cross-branch attention interaction module for processing to output a first enhanced defect feature map, includes:

[0020] In the cross-branch attention interaction module, an intermediate feature map is obtained, which is constructed from defect features of multiple scales and multiple receptive fields.

[0021] A convolution operation is performed on the intermediate feature map to generate a query branch feature map and a support branch feature map. The query branch feature map and the support branch feature map are then multiplied by a matrix to calculate the spatial correlation between features, resulting in a query branch attention map and a support branch attention map, which are used to locate the key defect region in the gear image to be detected.

[0022] A convolution operation is applied to the intermediate feature map to generate a query branch value feature map and a support branch value feature map. The query branch value feature map is then weighted and aggregated with the query branch attention map, and the support branch value feature map is then weighted and aggregated with the support branch attention map to obtain a weighted and aggregated defect feature map.

[0023] The query branch and the weighted aggregated defect feature map of the supporting branch output are processed by the transformation function layer and then fused to determine the first enhanced defect feature map.

[0024] Optionally, in the GAM spatial attention mechanism module, the step of focusing on the spatial location of defect features in the first enhanced defect feature map by modeling the long-distance dependency between the global space and channels includes:

[0025] In the GAM spatial attention mechanism module, the first enhanced defect feature map is processed sequentially through a first 3×3 convolutional layer, a first ReLU function activation layer, a first batch of normalization layers, a second 3×3 convolutional layer, and a first Sigmoid activation function layer to generate channel attention weights to dynamically enhance the feature channels related to the defect features, thereby generating the first enhanced defect feature map after channel enhancement.

[0026] After the enhanced defect feature map is processed sequentially through a first 5×5 convolutional layer, a second ReLU activation layer, a second batch normalization layer, a second 5×5 convolutional layer, and a second Sigmoid activation layer, a spatial attention feature map is generated to focus on the key regions of the defect features in the spatial location within the first enhanced defect feature map.

[0027] Optionally, the step of adaptively recalibrating channel features in the SE channel attention mechanism module to highlight channels with defect features and output a second enhanced defect feature map includes:

[0028] In the SE channel attention mechanism module, the defect feature map output by the GAM spatial attention mechanism module is subjected to global average pooling to generate a global channel descriptor, so as to aggregate the global information of each channel.

[0029] Channel attention weights are generated using two fully connected layers to quantify the importance of each channel for defect detection.

[0030] The channel attention weights are multiplied channel by channel in the defect feature map to enhance the response of the defect feature channels, thereby highlighting the channels with defect features in the defect feature map and outputting a second enhanced defect feature map.

[0031] Optionally, the steps for training the second gear defect detection model include:

[0032] Obtain a sample dataset, wherein the sample dataset includes multiple training samples and their corresponding supervision labels, the training samples represent a single gear image, and the supervision labels represent the annotation information of gear defect types in the gear images;

[0033] The second gear defect detection model is trained using the sample dataset. During the training process, the bounding box regression of the second gear defect detection model is optimized according to the α-IoU loss function, and the feature learning of difficult-to-classify training samples is enhanced through the FocalLoss mechanism until the second gear defect detection model is trained to a convergent state, thereby completing the training of the second gear defect detection model.

[0034] Optionally, the gear defect types include tooth loss defects, crack defects, wear defects, and foreign object defects; wherein, the foreign objects include metal shavings, oil clumps, and dust accumulations; the basic network architecture of the first gear defect detection model is the original YOLOv11 target detection model; the basic network architecture of the second gear defect detection model is the improved YOLOv11 target detection model.

[0035] A gear defect detection device provided for another purpose of this application includes:

[0036] The gear image acquisition module is configured to acquire images of gears to be inspected that contain multiple types of gear defects;

[0037] The detection model construction module is configured to update the third C3k2 module in the backbone network of the preset first gear defect detection model to an FEM module, introduce a GAM-SE cascaded attention mechanism module in the backbone network, update the IoU loss function of the first gear defect detection model to an α-IoU loss function, and introduce a Focal Loss mechanism to construct a second gear defect detection model.

[0038] The first feature enhancement module is configured to input the gear image to be detected into the second gear defect detection model that has been trained to convergence. In the multi-branch convolution module of the FEM module, a dilated convolutional layer is introduced into the middle branch to expand the receptive field to capture contextual information. In parallel, multi-scale and multi-receptive field defect features in the gear image to be detected are extracted to construct an intermediate feature map. After being processed by the cross-branch attention interaction module, the first enhanced defect feature map is output.

[0039] The second feature enhancement module is configured to focus on the spatial location of the defect feature in the first enhanced defect feature map by modeling the long-distance dependency between the global space and the channel in the GAM spatial attention mechanism module, and to adaptively recalibrate the channel feature in the SE channel attention mechanism module to highlight the channel of the defect feature, so as to output the second enhanced defect feature map.

[0040] The gear defect detection module is configured to input the second enhanced defect feature map into the detection head network in the second gear defect detection model to detect the gear defect type in the gear image to be detected, and generate a corresponding defect alarm command based on the gear defect type and transmit it to the operation interface of the gear defect detection system to complete the fault detection of gear defects.

[0041] An electronic device provided for another purpose of this application includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the gear defect detection method of this application.

[0042] A computer-readable storage medium is provided for another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the gear defect detection method, which, when invoked by a computer, executes the steps included in the corresponding method.

[0043] Compared to existing technologies, this application addresses the problems of existing gear defect detection methods, such as high susceptibility to lighting conditions, strong dependence on lighting, easy loss of defect features during downsampling leading to low detection accuracy, and high inference latency of conventional deep learning models, which are more inclined to offline and periodic detection and lack the ability to monitor the real-time status of gear systems in industrial settings. This application includes, but is not limited to, the following beneficial effects:

[0044] Firstly, the gear defect detection method of this application introduces the FEM module. This method constructs a lightweight convolutional structure and a multi-scale fusion mechanism in the backbone network of the original YOLOv11 model. This significantly enhances the model's ability to perceive small targets and edge details, especially for detecting tiny defects on the surface of small-module gears. The FEM module effectively improves the feature representation ability of defect areas and can meticulously capture defects within a small range on the gear surface.

[0045] Secondly, the GAM-SE module enhances the model's sensitivity to key regions through a cascaded global spatial attention mechanism and a channel feature recalibration mechanism. In the spatial domain, it focuses on the spatial location of defect features by modeling long-distance dependencies; in the channel domain, it highlights important defect feature channels through adaptive recalibration. This dynamic feature enhancement improves the model's ability to perceive different types of gear defects, enabling it to maintain high detection accuracy when facing complex backgrounds and multiple defect types.

[0046] Third, traditional IoU loss has low regression accuracy for small targets, especially in handling highly overlapping predicted boxes. This application introduces an α-IoU loss function and uses a power-law adjustment parameter to significantly improve the regression constraints for highly overlapping predicted boxes. This improvement greatly enhances the model's accuracy in locating small defects, ensuring better bounding box regression performance in the detection of small defects on the surface of small-module gears.

[0047] Fourth, the positive and negative samples for small defects are extremely imbalanced, and traditional loss functions are easily affected by easily classified background samples, making it difficult for the model to sensitively detect small defects that are difficult to classify. To address this issue, this application introduces a Focal Loss mechanism in the classification branch. This mechanism effectively reduces the interference of background samples, enhances the model's sensitivity to detecting small defects that are difficult to classify, and thus improves the detection capability for small defects.

[0048] Fifth, while maintaining high accuracy, this application reduces computational complexity by introducing a lightweight feature enhancement module, an α-IoU loss function, and a Focal Loss mechanism, ensuring that the detection system has good real-time performance and low computational cost. This makes the method more applicable to practical embedded detection systems, ensuring efficient detection while reducing the computational burden and cost of terminal devices.

[0049] Sixth, this application can effectively handle various types of gear defects, especially defect detection in complex backgrounds, solving the detection difficulties caused by environmental noise, image blurring, or the variability of gear surfaces in traditional detection methods. Through multimodal feature extraction and cross-branch attention interaction, the model can accurately separate the defect region from the background and perform multi-dimensional feature extraction at multiple scales and receptive fields, ensuring accurate localization of gear defects.

[0050] Seventh, this application not only effectively improves the detection accuracy and robustness of gear defects, but also takes into account the actual needs of industrial applications, such as real-time performance and the computing power of terminal devices, while ensuring performance. By optimizing the network structure and loss function, the computational complexity of the system is reduced, the feasibility of its application in actual industrial environments is improved, and the deployment difficulty and hardware cost are reduced.

[0051] Furthermore, this application addresses several key issues in small target detection by introducing an improved YOLOv11 model, which incorporates an FEM module, a GAM-SE cascaded attention mechanism module, an α-IoU loss function, and a Focal Loss mechanism. This method is particularly suitable for detecting minute defects on the surface of small-module gears. It demonstrates excellent performance in improving detection accuracy, robustness, positioning accuracy, and real-time performance, and has broad prospects for industrial applications. In particular, it can be efficiently deployed in embedded systems and reduce the cost of terminal devices. Attached Figure Description

[0052] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0053] Figure 1 This is a schematic flowchart of the gear defect detection method in the embodiments of this application;

[0054] Figure 2 The exemplary network architecture used as the base network architecture for the improved YOLOv11 object detection model in the embodiments of this application;

[0055] Figure 3 This is a schematic block diagram of the gear defect detection device in the embodiments of this application;

[0056] Figure 4 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation

[0057] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0058] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.

[0059] Those skilled in the art will understand that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0060] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDAs (Personal Digital Assistants) that may include radio frequency receivers, pagers, internet / intranet access, web browsers, notebooks, calendars, and / or GPS (Global Positioning System) receivers; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.

[0061] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.

[0062] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.

[0063] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.

[0064] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on a client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on a client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.

[0065] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.

[0066] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.

[0067] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.

[0068] Please see Figure 1 In one embodiment of the gear defect detection method of this application, the method includes:

[0069] Step S10: Obtain an image of the gear to be inspected that contains multiple types of gear defects;

[0070] The gear defect detection system in the terminal device can acquire images of the gear to be inspected containing various types of gear defects in the Electro-Mechanical Brake (EMB) system; wherein the gear defect types include tooth loss defects, crack defects, wear defects and foreign object defects; wherein the foreign objects include metal shavings, oil condensate, and dust accumulation.

[0071] Specifically, the gear defect detection system is used to acquire images of the gear to be inspected from an external source, analyze and judge the defects in the images, and finally issue an alarm when a defect is detected to ensure the normal operation of the electromechanical braking system. The image of the gear to be inspected is the raw data for defect detection by the gear defect detection system, provided by the electromechanical braking system, and contains information on various possible defects in the gear, serving as the basis for subsequent defect identification and analysis.

[0072] The term "tooth loss defect" refers to the absence of teeth on a gear, which may be caused by excessive wear, impact, or other external forces, and will affect the normal meshing and transmission of the gear.

[0073] The crack defect refers to the fracture lines that appear on or inside the gear surface. It may be caused by material fatigue, manufacturing defects, stress concentration during use, etc. If it is not dealt with in time, it may lead to serious failures such as gear breakage.

[0074] Wear defects refer to the material loss on the tooth surface of gears due to friction during long-term meshing operation. This will reduce the tooth profile accuracy of the gear and affect the smoothness of transmission.

[0075] Foreign matter defects refer to defects caused by foreign substances not belonging to the gear itself adhering to or embedding on the gear surface. Metal shavings, for example, originate from residues during gear manufacturing or metal particles generated by wear on other components; their adhesion to the gear surface accelerates wear. Oil congealed clumps refer to the condensation of lubricating oil or other greases from the electromechanical braking system on the gear surface, affecting heat dissipation and normal meshing. Dust accumulation refers to the long-term accumulation of dust from the environment on the gear surface, which may clog gear clearances and affect normal operation.

[0076] Step S20: Update the third C3k2 module in the backbone network of the preset first gear defect detection model to an FEM module, introduce a GAM-SE cascaded attention mechanism module into the backbone network, update the IoU loss function of the first gear defect detection model to an α-IoU loss function, and introduce a Focal Loss mechanism to construct a second gear defect detection model. The GAM-SE cascaded attention mechanism module includes a GAM spatial attention mechanism module and an SE channel attention mechanism module.

[0077] After acquiring gear images containing various gear defect types, the third C3k2 module in the backbone network of the preset first gear defect detection model is updated to an FEM module. A GAM-SE cascaded attention mechanism module is introduced into the backbone network, the IoU loss function of the first gear defect detection model is updated to an α-IoU loss function, and a Focal Loss mechanism is introduced to construct a second gear defect detection model. The GAM-SE cascaded attention mechanism module includes a GAM spatial attention mechanism module and an SE channel attention mechanism module. The basic network architecture of the first gear defect detection model is the original YOLOv11 object detection model; the basic network architecture of the second gear defect detection model is an improved YOLOv11 object detection model. The backbone network of the second gear defect detection model includes, in sequence, an input layer, a first convolutional layer, a second convolutional layer, a first C3k2 module, a third convolutional layer, a second C3k2 module, a fourth convolutional layer, an FEM module, a fifth convolutional layer, a third C3k2 module, a GAM spatial attention mechanism module, and an SPPF module. The module includes an SE channel attention mechanism module; the FEM module includes a multi-branch convolution module and a cross-branch attention interaction module, wherein the multi-branch convolution module includes a 1×3 convolution kernel branch, a 3×1 convolution kernel branch, and a 3×3 convolution kernel branch, wherein a dilated convolution layer is introduced in the 3×3 convolution kernel branch.

[0078] Please see Figure 2 The basic network architecture of the improved YOLOv11 object detection model in this application is as follows: Figure 2 As shown, the backbone network of the second gear defect detection model includes, in sequence, an input layer, a first convolutional layer (ConV), a second convolutional layer (ConV), a first C3k2 module (C3k2), a third convolutional layer (ConV), a second C3k2 module (C3k2), a fourth convolutional layer (ConV), a FEM module (FEM), a fifth convolutional layer (ConV), a third C3k2 module (C3k2), a GAM spatial attention mechanism module (GAM), an SPPF module, and an SE channel attention mechanism module (SE).

[0079] In some embodiments, the third C3k2 module in the backbone network of the preset original YOLOv11 object detection model is updated to an FEM module (Lightweight Feature Enhancement Module). This module can improve model accuracy while reducing model computational complexity. By introducing the FEM module into the backbone network of the model to replace the traditional convolution module, the feature representation capability of small gear defects can be improved, while maintaining the model's lightweight nature and adapting to the requirements of high frame rate real-time detection.

[0080] Furthermore, by introducing a GAM-SE cascaded attention mechanism module into the backbone network, wherein the GAM-SE cascaded attention mechanism module includes a GAM spatial attention mechanism module and an SE channel attention mechanism module, it can construct a complex feature information suppression layer to enhance the importance judgment of feature channels and the ability to suppress spatial background, thereby effectively improving the defect detection accuracy under complex backgrounds (such as oil stains and reflections).

[0081] Furthermore, to further improve the accuracy of detecting minute defects in EMB small module gears, this application improves the original loss function of the original YOLOv11 target detection model, mainly including:

[0082] First, the α-IoU loss function is introduced. Traditional IoU loss has limited regression accuracy for small target bounding boxes. The improved YOLOv11 target detection model proposed in this application adopts the α-IoU loss function in the bounding box regression stage. By introducing a power exponent adjustment parameter, the regression constraint on highly overlapping prediction boxes is enhanced, thereby improving the localization accuracy when detecting small defects.

[0083] Secondly, to address the problem of extreme imbalance in the number of positive and negative samples for small defects, this application introduces a Focal Loss mechanism in the classification branch, which effectively reduces the interference of a large number of easily classifiable background samples on model training and improves the detection sensitivity for difficult-to-classify small defect samples.

[0084] In some embodiments, the step of training the second gear defect detection model includes:

[0085] Step S201: Obtain a sample dataset, wherein the sample dataset includes multiple training samples and their corresponding supervision labels, the training samples represent a single gear image, and the supervision labels represent the annotation information of the gear defect type in the gear image;

[0086] Step S202: The second gear defect detection model is trained using the sample dataset. During the training process, the bounding box regression of the second gear defect detection model is optimized according to the α-IoU loss function. The feature learning of difficult-to-classify training samples is enhanced through the Focal Loss mechanism until the second gear defect detection model is trained to a convergent state, thereby completing the training of the second gear defect detection model.

[0087] Specifically, firstly, gear samples with various types of defects and moduli ranging from 0.6 to 1.2 were collected. Next, a data acquisition system was built using a high-resolution industrial camera and an adjustable light source. Then, using a high-resolution industrial camera (ensuring clear details of even minor defects) and an adjustable light source (simulating different lighting conditions on the production line), gear images were captured under multiple angles (e.g., front, side, tilt) and lighting conditions (e.g., strong light, weak light, backlight) to enhance the dataset's adaptability to complex industrial environments. The dataset covered various typical defect types such as missing teeth, cracks, wear, and foreign objects. Professional annotation tools (e.g., LabelImg) were used to accurately annotate the acquired gear images: bounding boxes were used to select the boundary of each defect region (locating the defect location), and the defect type (e.g., "missing teeth," "cracks," etc.) was labeled to form supervisory labels. The annotated images were divided into a training set (for model parameter learning), a validation set (for parameter optimization and overfitting monitoring during training), and a test set (for final performance evaluation) to ensure the representativeness and diversity of the sample dataset, providing a reliable foundation for model training.

[0088] By optimizing bounding box regression using the α-IoU loss function, the problem of insufficient bounding box regression accuracy for minor defects in gears (such as micro-cracks) is addressed. By introducing a power-law adjustment parameter (α), the constraint on highly overlapping predicted boxes is enhanced. That is, the higher the overlap between the predicted box and the actual defect box, the more significant the penalty for deviation by the loss function, forcing the model to locate the defect boundary more accurately and improving the localization accuracy of micro-defects.

[0089] By strengthening the learning of difficult-to-classify samples through the Focal Loss mechanism, this approach addresses the problem of an extreme imbalance between the number of "normal regions (easy to classify)" and "minor defects (difficult to classify)" in the training samples. By introducing a weight factor, the loss weight of easily classified samples is reduced, while the loss weight of difficult-to-classify samples is increased. This reduces the interference of a large number of background samples on model training, allowing the model to focus more on difficult-to-classify minor defect samples (such as slight wear and small foreign objects), thereby improving the detection sensitivity of such samples.

[0090] During iterative training, the model performance, such as the accuracy and recall of defect detection, is monitored through the validation set. When the model's performance on the validation set tends to stabilize and the loss function value converges to below the preset threshold, the model training is considered complete, and a second gear defect detection model that has been trained to a convergent state is obtained. After the second gear defect detection model is trained, it can be put into production and used to detect various types of gear defects in the EMB system.

[0091] Step S30: Input the gear image to be detected into the second gear defect detection model that has been trained to convergence. In the FEM module, the middle branch of the multi-branch convolution module introduces a dilated convolution layer to expand the receptive field to capture contextual information. In parallel, multi-scale and multi-receptive field defect features in the gear image to be detected are extracted to construct an intermediate feature map. After being processed by the cross-branch attention interaction module, the first enhanced defect feature map is output.

[0092] The third C3k2 module in the backbone network of the preset first gear defect detection model is updated to an FEM module. A GAM-SE cascaded attention mechanism module is introduced into the backbone network. The IoU loss function of the first gear defect detection model is updated to an α-IoU loss function, and a Focal Loss mechanism is introduced. After constructing the second gear defect detection model, the gear image to be detected is input into the second gear defect detection model that has been trained to convergence. A dilated convolutional layer is introduced into the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field to capture contextual information. Multi-scale and multi-receptive field defect features in the gear image to be detected are extracted in parallel to construct an intermediate feature map. After being processed by the cross-branch attention interaction module, the first enhanced defect feature map is output.

[0093] In some embodiments, the step of introducing a dilated convolutional layer in the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field to capture contextual information, extracting multi-scale, multi-receptive field defect features in the gear image to be detected in parallel to construct an intermediate feature map, and inputting it to the cross-branch attention interaction module for processing to output a first enhanced defect feature map includes:

[0094] Step S301: In the cross-branch attention interaction module, obtain an intermediate feature map constructed from defect features of multiple scales and multiple receptive fields;

[0095] Step S302: Perform a convolution operation on the intermediate feature map to generate a query branch feature map and a support branch feature map. Multiply the query branch feature map and the support branch feature map by matrix to calculate the spatial correlation between features, and obtain the query branch attention map and the support branch attention map to locate the key defect region in the gear image to be detected.

[0096] Step S303: Perform a convolution operation on the intermediate feature map to generate a query branch value feature map and a support branch value feature map. Then, perform weighted aggregation on the query branch value feature map and the query branch attention map, and on the support branch value feature map and the support branch attention map, respectively, to obtain a weighted aggregated defect feature map.

[0097] Step S304: The query branch and the weighted aggregated defect feature map output by the support branch are processed by the transformation function layer and then fused to determine the first enhanced defect feature map.

[0098] Specifically, the main idea of ​​the FEM (Feature Enhancement Module) is to adopt a multi-branch convolutional module design that introduces dilated convolutional layers to enhance the feature extraction capability of small targets. The FEM module includes a multi-branch convolutional module and a cross-branch attention interaction module. The multi-branch convolutional module includes a 1×3 convolutional kernel branch, a 3×1 convolutional kernel branch, and a 3×3 convolutional kernel branch. Dilated convolutional layers are introduced in the 3×3 convolutional kernel branch, and dilated convolutional layers (dilated convolutional layers) are added in the 3×3 convolutional kernel branch. This can expand the receptive field and enrich the contextual information. The enhanced feature map of the FEM module with a global context view can selectively aggregate the context according to the spatial attention map. Similar semantic features achieve mutual gain, thereby improving intra-class compactness and semantic consistency. Finally, the fusion of multi-branch features is completed through feature concatenation and element-wise addition operations to output the first enhanced defect feature map.

[0099] The calculation process of introducing a dilated convolutional layer in the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field and capture contextual information, and extracting multi-scale, multi-receptive field defect features from the gear image to be detected in parallel to construct an intermediate feature map, and then inputting it to the cross-branch attention interaction module for processing to output the first enhanced defect feature map, includes:

[0100] First, in the cross-branch attention interaction module of the FEM module, the intermediate feature maps output by the multi-branch convolution module are obtained. and intermediate feature maps For intermediate feature maps and intermediate feature maps Convolutional operations are used to generate query branch feature maps. and supporting branch feature maps The query branch feature map With the support branch feature map Matrix multiplication is performed to calculate the spatial correlation between features, resulting in the query branch attention map. and support branch attention graph The calculation formula for locating the key defect region in the image of the gear to be detected includes:

[0101] ,

[0102] ,

[0103] in, The attention weight for query branches represents the weight of the first branch in the query. The spatial location pair in the Support branch The attention weights generated at each spatial location reflect the degree of correlation between the features of the two locations. The larger the value, the more attention the query branch pays to the corresponding location in the support branch. Represents the query branch feature graph The Middle Each spatial location feature vector records the feature information (such as texture, grayscale, etc.) of that spatial location in the gear image query branch. Indicates support branch feature map The Middle Each spatial location's feature vector records the gear features at the corresponding location on the support branch side; This represents an exponential function, used to amplify the differences in the inner product of feature vectors, making the weights of strongly correlated positions more prominent, which facilitates the subsequent selection of key features. For all positions in the Query branch and the Support branch Normalize the correlation between spatial locations to ensure that the sum of the attention weights of each location in the Query branch to a single location in the Support branch is 1, making the weight calculation more reasonable. This represents the query branch attention graph, consisting of all The spatial attention map of the Query branch relative to the Support branch presents the attention distribution of the Query branch to different positions of the Support branch, which can intuitively show which positions may have defects; This indicates support for branch attention graphs. The spatial attention map of the Support branch relative to the Query branch obtained by transposing it reflects the attention of the Support branch to different positions of the Query branch, realizing bidirectional feature association mining.

[0104] As can be seen from the above calculation formula, through calculation and transpose inner product This method quantifies the correlation between features at different spatial locations in the Query and Support branches, identifying regions with closely correlated features in the gear image. These regions are often where defects (such as cracks or missing teeth) may exist. An exponential function and normalization are then used to transform feature correlation into attention weights. This highlights strongly correlated locations and suppresses weakly correlated locations, allowing the model to focus more on key areas of gear defects, thus preparing for subsequent feature aggregation.

[0105] Query branch attention graph Transpose to obtain the support branch attention graph This allows the Query and Support branches to capture each other's feature dependencies in both directions, comprehensively exploring the spatial distribution of defects in gear images and improving the accuracy and comprehensiveness of defect localization.

[0106] Furthermore, regarding the intermediate feature maps and intermediate feature maps Convolutional operations are used to generate query branch value feature maps. and supporting branch value feature maps The query branch value feature map With the query branch attention graph The support branch value feature map With the support branch attention graph Weighted aggregation is performed separately to determine the weighted aggregated defect feature map. The weighted aggregated defect feature maps output from the query branch and the support branch are processed by the transformation function layer and then fused to determine the first enhanced defect feature map. The calculation formula includes:

[0107] ,

[0108] in, This indicates that the feature map output by the Query branch after feature aggregation and transformation contains enhanced gear defect features, which will be used in the defect detection process to provide more discriminative input to the detection head; The attention weight for query branches represents the weight of the first branch in the query. The spatial location pair in the Support branch The attention weights generated at each spatial location reflect the degree of correlation between the features of the two locations. The larger the value, the more attention the query branch pays to the corresponding location in the support branch. Represents the feature graph of query branch values The Middle The feature vector of each spatial location stores richer gear feature details (such as the texture and shape of defects) for that location in the Query branch. This represents the total number of spatial locations on the feature map that participate in the aggregation calculation; Indicates attention weight based on query branch Query branch value feature map We perform a weighted summation of the features, focusing our attention on key defect features, suppressing irrelevant background features, and strengthening the expression of defect region features. This represents the transformation function layer in the query branch, which consists of operations such as convolution. It can adjust the dimension of the aggregated feature map, extract deeper features, and make the features more suitable for the needs of subsequent defect detection tasks, such as adjusting the number of channels and enhancing feature details.

[0109] As can be seen from the above calculation formula, the query branch value feature map is first... In the example, the feature vector of each spatial location According to the attention weight of the corresponding query branch Weighted summation is performed, where the attention weights reflect the degree of attention different positions in the Query branch pay to their own features. This ensures that features strongly associated with key information such as defects are more amplified during aggregation, highlighting key features and suppressing irrelevant background. This is then further enhanced through a transformation function layer. Further processing is performed on the weighted aggregated defect feature map, such as adjusting the number of channels and extracting deeper features, to enhance the first enhanced defect feature map. It better meets the needs of subsequent defect detection tasks, enhances the ability to discriminate features, and facilitates the detection head to accurately identify defects.

[0110] ,

[0111] in, This represents the output feature map after feature aggregation and transformation of the Support branch, and Collaboration provides a comprehensive defect feature representation for the second gear defect detection model, improving the defect detection effect; To support branch attention weights, it represents the first branch of the query. The spatial location corresponds to the first branch of the Support branch. The greater the weight value of the influence and correlation of a spatial location, the more the Query branch pays attention to the features of the corresponding location in the Support branch. When feature aggregation, the features of that location will be given higher importance to highlight feature regions related to key information such as defects. Indicates the support branch value feature map No. The feature vectors of each spatial location record the feature information of the corresponding location in the Support branch, which are used to enhance the defect features in collaboration with the Query branch; This represents the total number of spatial locations on the feature map that participate in the aggregation calculation; Indicates attention weights based on support branches For support branch value feature maps The features are weighted and summed to highlight key features and suppress irrelevant information; This indicates that the transformation function layer in the support branch consists of operations such as convolution. It can adjust the dimension of the aggregated feature map, extract deeper features, and make the features more suitable for the needs of subsequent defect detection tasks, such as adjusting the number of channels and enhancing feature details.

[0112] Furthermore, the feature map output from the Query branch after feature aggregation and transformation is... The output feature map after aggregation and transformation with Support branch features The features are spliced ​​or element-wise added together to form a first enhanced defect feature map, which is then input into the GAM-SE module for further enhancement.

[0113] As can be seen from the above calculation formula, for the support branch value feature map The characteristics of each spatial location Based on its corresponding support branch attention weight Perform weighted summation to support branch attention weights This reflects the attention paid by the Query branch position to each Support branch position, strengthens features in the Support branch that are closely related to key areas (such as defect areas) in the Query branch, and supplements global feature information; a transformation function layer is used. The weighted aggregated defect feature map is transformed by adjusting the feature dimensions and refining deep features, resulting in a better output feature map after feature aggregation and transformation of the Support branch features. The feature map output after feature aggregation and transformation of the query branch. Collaboration is used to determine the first enhanced defect feature map, providing a more comprehensive and prominent feature representation of defects for subsequent defect detection, thereby improving detection accuracy.

[0114] As can be seen from the above embodiments, this application proposes to insert an FEM (Feature Enhancement Module) module into the backbone network of the original YOLOv11 object detection model, aiming to enhance the model's feature extraction capability, especially its ability to express minute defects and complex textures on gear surfaces. The core working principle of the FEM module is to extract feature information under different receptive fields in parallel using multi-scale convolutions (such as 1×3 convolution kernel branches, 3×1 convolution kernel branches, and 3×3 convolution kernel branches), and then enhance the response of key regions through feature fusion (such as concatenation or weighted summation) and attention mechanisms (such as channel attention or spatial attention).

[0115] To maintain information continuity, FEM often incorporates residual connection structures to prevent the loss of deep information. In this application, we innovatively propose embedding this module into the back end of the YOLOv11 Backbone network, replacing the third C3k2 module in the original network, to perform high-order semantic enhancement on the original feature map. This directly utilizes the diversity of defect features obtained from the backbone network and the naive correlation of noise caused by the similarity between defects of the same class but different scales. We propose enhancing feature representation by associating local similarities between different scales of the same class and enhancing global similarities between the same class. Information exchange is achieved between query branch features and support branch features, enabling precise pattern matching between gear surface defect features.

[0116] In summary, applying the FEM module to gear defect detection tasks in EMB systems can significantly improve the model's ability to detect small-scale defects such as cracks, missing teeth, and wear. Because these defects often have characteristics such as small size, low contrast, and complex backgrounds, traditional backbone structures may not be able to fully extract their features. FEM, by introducing richer contextual information and scale awareness, strengthens the representation of defect regions, thereby improving the model's accuracy, recall, and robustness, meeting the dual requirements of high accuracy and real-time performance in industrial-grade detection.

[0117] Step S40: In the GAM spatial attention mechanism module, the spatial location of the defect feature is focused in the first enhanced defect feature map by modeling the long-distance dependency between the global space and the channel. In the SE channel attention mechanism module, the channel feature is adaptively recalibrated to highlight the channel of the defect feature, so as to output the second enhanced defect feature map.

[0118] The gear image to be detected is input into the second gear defect detection model that has been trained to convergence. In the FEM module, the middle branch of the multi-branch convolution module introduces a dilated convolutional layer to expand the receptive field to capture contextual information. In parallel, multi-scale and multi-receptive field defect features in the gear image to be detected are extracted to construct an intermediate feature map. After being processed by the cross-branch attention interaction module, the first enhanced defect feature map is output. In the GAM spatial attention mechanism module, the spatial position of the defect feature is focused in the first enhanced defect feature map by modeling the long-distance dependency between the global space and the channels. In the SE channel attention mechanism module, the channel features are adaptively recalibrated to highlight the channels of the defect features to output the second enhanced defect feature map.

[0119] Specifically, this application proposes inserting a GAM-SE cascaded attention mechanism module into the end of the backbone network of the original YOLOv11 object detection model. This significantly enhances the model's ability to focus on minute defect features, making it particularly suitable for detecting minute defects on gear surfaces in EMB systems. After connecting the key information of each defect feature through FEM, the obtained key information is then convolved. Subsequently, by combining the advantages of GAM (Global Attention Mechanism) and SE (Squeeze-and-Excitation) modules, feature representation is strengthened from both spatial and channel dimensions, improving detection accuracy and robustness.

[0120] In some embodiments, the step of focusing on the spatial location of a defect feature in the first enhanced defect feature map by modeling the long-distance dependency between the global space and channels in the GAM spatial attention mechanism module includes:

[0121] Step S401: In the GAM spatial attention mechanism module, the first enhanced defect feature map is processed sequentially through the first 3×3 convolutional layer, the first ReLU function activation layer, the first batch normalization layer, the second 3×3 convolutional layer and the first Sigmoid activation function layer to generate channel attention weights to dynamically enhance the feature channels related to the defect features, so as to generate the first enhanced defect feature map after channel enhancement.

[0122] Step S402: After the enhanced first defect feature map is processed sequentially through a first 5×5 convolutional layer, a second ReLU activation layer, a second batch normalization layer, a second 5×5 convolutional layer, and a second Sigmoid activation layer, a spatial attention feature map is generated to focus on the key regions of the defect features in the spatial location of the first enhanced defect feature map.

[0123] Specifically, in the GAM spatial attention mechanism module, the first enhanced defect feature map is processed sequentially through a first 3×3 convolutional layer, a first ReLU activation layer, a first batch of normalization layers, a second 3×3 convolutional layer, and a first Sigmoid activation layer to generate channel attention weights to dynamically enhance feature channels related to the defect features, thereby generating the first enhanced defect feature map after channel enhancement. The expression for the channel attention mechanism in the GAM spatial attention mechanism module is as follows:

[0124] ,

[0125] in, The first enhanced defect feature map, representing the input, is the original feature representation before processing by the GAM module. It contains feature data related to gear surface defects, etc. This represents a 3×3 convolution operation, used to perform convolution calculations on the input feature map, extract local features from the feature map, and change the number of channels or spatial dimensions of the feature map, etc. Represents the Rectified Linear Unit, an activation function used to introduce nonlinearity into the defect feature map, enhancing the model's ability to express complex features, filtering out feature values ​​less than 0, and retaining useful feature information; This represents the Batch Normalization operation, which normalizes the feature map after ReLU processing along the batch dimension. It is used to accelerate model training convergence, reduce the gradient vanishing problem, make the input distribution of each layer more stable, and improve the feature extraction effect. This represents the Sigmoid activation function, which maps the processed feature values ​​to the interval between 0 and 1. The output can be used as channel attention weights to measure the importance of different channels. This represents the feature map obtained after processing by the channel attention mechanism, which is also the first enhancement defect feature map after channel enhancement. It is the first enhancement defect feature map. Based on this, the new feature representation obtained through channel attention calculation highlights the importance of different channels to defect features and strengthens the features of key channels.

[0126] As can be seen from the expression of the channel attention mechanism above, the purpose of the channel attention mechanism in the GAM module is to explore the importance of different channels of the feature map to the defect detection task. The channel attention weights are calculated by the first 3×3 convolutional layer, the first ReLU function activation layer, the first batch of normalization layers, the second 3×3 convolutional layer and the first Sigmoid activation function layer. Then, they are multiplied element by element with the first enhanced defect feature map to dynamically adjust the feature contribution of each channel. This enhances the channel features that are highly related to the defects on the gear surface and suppresses irrelevant or secondary channel features, so that subsequent processing can focus more on the key defect feature channels.

[0127] Furthermore, the enhanced first defect feature map, after channel enhancement, is processed sequentially through a first 5×5 convolutional layer, a second ReLU activation layer, a second batch normalization layer, a second 5×5 convolutional layer, and a second Sigmoid activation layer to generate a spatial attention feature map. This spatial attention feature map focuses on key regions of the defect features in the spatial location within the first enhanced defect feature map. The calculation formula for the spatial attention mechanism in the GAM spatial attention mechanism module is expressed as follows:

[0128] ,

[0129] in, This indicates that the feature map obtained after sequential processing by channel attention and spatial attention mechanisms has enhanced the defect features in both channel and spatial dimensions, highlighting the features of key channels and key spatial locations. Represents the Rectified Linear Unit, an activation function used to introduce nonlinearity into the defect feature map, enhancing the model's ability to express complex features, filtering out feature values ​​less than 0, and retaining useful feature information; This represents the Batch Normalization operation, which normalizes the feature map after ReLU processing along the batch dimension. It is used to accelerate model training convergence, reduce the gradient vanishing problem, make the input distribution of each layer more stable, and improve the feature extraction effect. This represents the Sigmoid activation function, which maps the processed feature values ​​to the interval between 0 and 1. The output can be used as channel attention weights to measure the importance of different channels. This represents a 5×5 convolution operation used to extract spatial features from the feature map and capture information from different spatial locations within the feature map. This indicates that the feature map is obtained after processing by the channel attention mechanism, that is, the first enhancement defect feature map after channel enhancement, which serves as the input to the spatial attention mechanism.

[0130] As can be seen from the calculation formula of the spatial attention mechanism in the GAM spatial attention mechanism module, the spatial location related to defects in the focus feature map is processed sequentially through the first 5×5 convolutional layer, the second ReLU activation layer, the second batch normalization layer, the second 5×5 convolutional layer, and the second Sigmoid activation layer to calculate the spatial attention weights. These weights are then compared with the feature map that has undergone channel attention processing. By multiplying element by element, the spatial location of the feature map is weighted, which enhances the spatial location features of the defects on the gear surface and suppresses irrelevant spatial location features such as the background. This makes the feature map more prominent in terms of the spatial distribution information of the defects, which is more convenient for subsequent more accurate location and identification of defects.

[0131] Furthermore, the final feature map output by the GAM spatial attention mechanism module is represented as follows:

[0132] ,

[0133] This represents the final feature map output by the GAM module. It is the result of comprehensive modeling and dynamic adjustment of the importance of each position and channel through channel and spatial attention mechanisms, compared to the input first enhanced defect feature map. It focuses more on key features related to defects on the gear surface, and can provide more discriminative feature representations for subsequent defect detection and other tasks.

[0134] In a further embodiment, the step of adaptively recalibrating channel features in the SE channel attention mechanism module to highlight channels with defect features, and outputting a second enhanced defect feature map, includes:

[0135] Step S4001: In the SE channel attention mechanism module, the defect feature map output by the GAM spatial attention mechanism module is subjected to global average pooling to generate a global channel descriptor, so as to aggregate the global information of each channel.

[0136] Step S4002: Generate channel attention weights through two fully connected layers to quantify the importance of each channel for defect detection. Multiply the channel attention weights with the defect feature map channel by channel to enhance the response of the defect feature channels, so as to highlight the channels with defect features in the defect feature map and output a second enhanced defect feature map.

[0137] Specifically, in the SE channel attention mechanism module, the defect feature map output by the GAM spatial attention mechanism module is subjected to global average pooling to generate a global channel descriptor, thereby aggregating the global information of each channel. The expression for the global average pooling is:

[0138] ,

[0139] in, Indicates the first A global channel descriptor for each channel, which stores the channels. Nakazato The spatial characteristics of size are compressed into a single global scalar; Represents the input feature map No. The first channel, the first line, number The column's feature values ​​(such as the texture and grayscale of a gear defect at that location); The spatial dimensions (height × width) of the feature map are used as the denominator for average pooling.

[0140] As can be seen from the above expression for global average pooling, a single global scalar summarizes the characteristics of all spatial locations in a channel. For example, if a channel is entirely background, the scalar value will be smaller; if a channel contains defects, the scalar value will be larger. This provides channel-level global information for subsequent steps, allowing the model to know which channels are more important for defects.

[0141] Furthermore, channel attention weights are generated using two fully connected layers to quantify the importance of each channel for defect detection. These channel attention weights are then multiplied channel-by-channel by the defect feature map to enhance the response of defect feature channels, thereby highlighting channels with defect features in the defect feature map. The formula for calculating the channel attention weights is as follows:

[0142] ,

[0143] in, This represents the channel attention weight. Each channel corresponds to a weight between 0 and 1. The larger the value, the more important the channel. ReLU activation function adds a "non-linear" element to the interaction between channels, highlighting key channels; This represents the Sigmoid activation function, which compresses the weights to the range of 0 to 1, facilitating subsequent feature recalibration. , The weight matrix of the fully connected layer is used to learn the non-linear dependencies between channels, such as the possibility that "channels with cracks" and "channels with wear" may have a synergistic effect. This represents the global channel descriptor.

[0144] Furthermore, the defect feature map is recalibrated based on the channel attention weights of each channel. The expression for feature recalibration is as follows:

[0145] ,

[0146] in, This represents the feature map after the c-th channel is recalibrated, where defect features are enhanced and the background is suppressed; This represents the channel attention weight of the c-th channel; This represents the c-th channel feature map of the original input.

[0147] From the above expression for feature recalibration, it can be seen that using attention weights to "adjust channel features" if... The larger the value, the more likely the channel contains gear defects. Preserve and enhance the characteristics of the channel, such as clearer crack details; if If the channel is small, it indicates that the channel is the background. The characteristics of this channel are weakened, such as oil stains and the normal texture of the tooth surface are suppressed.

[0148] Furthermore, after recalibrating the defect feature map according to the channel attention weights of each channel, the SE channel attention mechanism module outputs a second enhanced defect feature map, which is expressed as:

[0149] ,

[0150] in, This represents the final output enhanced defect feature map, also known as the second enhanced defect feature map; This represents the defect feature map output by the GAM spatial attention mechanism module; This indicates that the SE channel attention mechanism module reprocesses the defect feature map output by the GAM spatial attention mechanism module.

[0151] As shown in the above expressions, the GAM module enhances the perception of spatial features of defect locations by modeling the long-distance dependencies between global spaces and channels; the SE module adaptively recalibrates channel features, highlighting key feature channels and suppressing invalid information. The cascading of these two modules enhances the model's ability to focus on small defect areas and improves the accuracy and discriminative power of feature representation, thereby improving the detection performance of minor gear defects under complex backgrounds and low contrast conditions. The defect feature map, enhanced twice by the GAM spatial attention mechanism module and the SE channel attention mechanism module, can better highlight minor gear defects (cracks, wear, etc.) while significantly suppressing background (oil stains, reflections, etc.), making it easier for the detection head network to identify defects.

[0152] Step S50: Input the second enhanced defect feature map into the detection head network in the second gear defect detection model to detect the gear defect type in the gear image to be detected, generate the corresponding defect alarm command according to the gear defect type and transmit it to the operation interface of the gear defect detection system to complete the fault detection of gear defects.

[0153] In the GAM spatial attention mechanism module, the spatial location of the defect feature is focused in the first enhanced defect feature map by modeling the long-distance dependency between the global space and the channels. In the SE channel attention mechanism module, the channel features are adaptively recalibrated to highlight the channels of the defect features. After outputting the second enhanced defect feature map, the second enhanced defect feature map is input into the detection head network in the second gear defect detection model to detect the gear defect type in the gear image to be detected. According to the gear defect type, the corresponding defect alarm command is generated and transmitted to the operation interface of the gear defect detection system to complete the fault detection of the gear defect.

[0154] Specifically, in the output of the detection head network, the model identifies the type of gear defect (such as cracks, corrosion, missing teeth, etc.) based on the second enhanced defect feature map. Once a defect is detected, a corresponding defect alarm command is generated, which can include information such as the type, location, and severity of the defect. Finally, the alarm command is sent to the operation interface of the gear defect detection system for display, so that the inspection personnel can take further action, such as discarding gears with cracks or missing teeth as defective products.

[0155] As can be seen from the above embodiments, compared with the prior art, this application addresses the problems of existing gear defect detection methods being greatly affected by the lighting environment, highly dependent on it, easily losing defect features during downsampling, resulting in low detection accuracy, and having large inference latency of conventional deep learning models, which are more inclined to offline and periodic detection and lack the ability to monitor the real-time status of gear systems in industrial settings. This application includes, but is not limited to, the following beneficial effects:

[0156] Firstly, the gear defect detection method of this application introduces the FEM module. This method constructs a lightweight convolutional structure and a multi-scale fusion mechanism in the backbone network of the original YOLOv11 model. This significantly enhances the model's ability to perceive small targets and edge details, especially for detecting tiny defects on the surface of small-module gears. The FEM module effectively improves the feature representation ability of defect areas and can meticulously capture defects within a small range on the gear surface.

[0157] Secondly, the GAM-SE module enhances the model's sensitivity to key regions through a cascaded global spatial attention mechanism and a channel feature recalibration mechanism. In the spatial domain, it focuses on the spatial location of defect features by modeling long-distance dependencies; in the channel domain, it highlights important defect feature channels through adaptive recalibration. This dynamic feature enhancement improves the model's ability to perceive different types of gear defects, enabling it to maintain high detection accuracy when facing complex backgrounds and multiple defect types.

[0158] Third, traditional IoU loss has low regression accuracy for small targets, especially in handling highly overlapping predicted boxes. This application introduces an α-IoU loss function and uses a power-law adjustment parameter to significantly improve the regression constraints for highly overlapping predicted boxes. This improvement greatly enhances the model's accuracy in locating small defects, ensuring better bounding box regression performance in the detection of small defects on the surface of small-module gears.

[0159] Fourth, the positive and negative samples for small defects are extremely imbalanced, and traditional loss functions are easily affected by easily classified background samples, making it difficult for the model to sensitively detect small defects that are difficult to classify. To address this issue, this application introduces a Focal Loss mechanism in the classification branch. This mechanism effectively reduces the interference of background samples, enhances the model's sensitivity to detecting small defects that are difficult to classify, and thus improves the detection capability for small defects.

[0160] Fifth, while maintaining high accuracy, this application reduces computational complexity by introducing a lightweight feature enhancement module, an α-IoU loss function, and a Focal Loss mechanism, ensuring that the detection system has good real-time performance and low computational cost. This makes the method more applicable to practical embedded detection systems, ensuring efficient detection while reducing the computational burden and cost of terminal devices.

[0161] Sixth, this application can effectively handle various types of gear defects, especially defect detection in complex backgrounds, solving the detection difficulties caused by environmental noise, image blurring, or the variability of gear surfaces in traditional detection methods. Through multimodal feature extraction and cross-branch attention interaction, the model can accurately separate the defect region from the background and perform multi-dimensional feature extraction at multiple scales and receptive fields, ensuring accurate localization of gear defects.

[0162] Seventh, this application not only effectively improves the detection accuracy and robustness of gear defects, but also takes into account the actual needs of industrial applications, such as real-time performance and the computing power of terminal devices, while ensuring performance. By optimizing the network structure and loss function, the computational complexity of the system is reduced, the feasibility of its application in actual industrial environments is improved, and the deployment difficulty and hardware cost are reduced.

[0163] Furthermore, this application addresses several key issues in small target detection by introducing an improved YOLOv11 model, which incorporates an FEM module, a GAM-SE cascaded attention mechanism module, an α-IoU loss function, and a Focal Loss mechanism. This method is particularly suitable for detecting minute defects on the surface of small-module gears. It demonstrates excellent performance in improving detection accuracy, robustness, positioning accuracy, and real-time performance, and has broad prospects for industrial applications. In particular, it can be efficiently deployed in embedded systems and reduce the cost of terminal devices.

[0164] Please see Figure 3A gear defect detection device provided to meet one of the purposes of this application includes a gear image acquisition module 1100, a detection model construction module 1200, a first feature enhancement module 1300, a second feature enhancement module 1400, and a gear defect detection module 1500. The gear image acquisition module 1100 is configured to acquire images of gears to be detected containing multiple types of gear defects. The detection model construction module 1200 is configured to update the third C3k2 module in the backbone network of a preset first gear defect detection model to an FEM module, introduce a GAM-SE cascaded attention mechanism module into the backbone network, update the IoU loss function of the first gear defect detection model to an α-IoU loss function, and introduce Focal... A loss mechanism is used to construct a second gear defect detection model; a first feature enhancement module 1300 is configured to input the gear image to be detected into the second gear defect detection model that has been trained to convergence. A dilated convolutional layer is introduced into the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field to capture contextual information. Multi-scale, multi-receptive field defect features are extracted in parallel from the gear image to construct an intermediate feature map, which is then processed by the cross-branch attention interaction module to output the first enhanced defect feature map; a second feature enhancement module 1400 is configured to, in the GAM spatial attention mechanism module, model... The long-distance dependency between global space and channels is used to focus on the spatial location of defect features in the first enhanced defect feature map. In the SE channel attention mechanism module, the channel features are adaptively recalibrated to highlight the channels of the defect features, so as to output the second enhanced defect feature map. The gear defect detection module 1500 is configured to input the second enhanced defect feature map into the detection head network in the second gear defect detection model to detect the gear defect type in the gear image to be detected, and generate the corresponding defect alarm instruction according to the gear defect type and transmit it to the operation interface of the gear defect detection system to complete the fault detection of gear defects.

[0165] Based on any embodiment of this application, please refer to Figure 4 Another embodiment of this application also provides an electronic device, which can be implemented by a computer device, such as... Figure 4The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When the computer-readable instructions are executed by the processor, the processor can implement a gear defect detection method. The processor of the computer device provides computing and control capabilities, supporting the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute the gear defect detection method of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0166] In this embodiment, the processor is used to execute... Figure 3 The memory stores the specific functions of each module, and stores the program code and various data required to execute the above modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules in the gear defect detection device of this application, and the server can call the server's program code and data to execute the functions of all modules.

[0167] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the gear defect detection method described in any embodiment of this application.

[0168] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the gear defect detection method described in any embodiment of this application.

[0169] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0170] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method of gear defect detection, characterized by, include: Acquire images of the gear to be inspected, which contain multiple types of gear defects; The third C3k2 module in the backbone network of the preset first gear defect detection model is updated to an FEM module. A GAM-SE cascaded attention mechanism module is introduced into the backbone network. The IoU loss function of the first gear defect detection model is updated to an α-IoU loss function, and a Focal Loss mechanism is introduced to construct a second gear defect detection model. The backbone network of the second gear defect detection model includes an input layer, a first convolutional layer, a second convolutional layer, a first C3k2 module, a third convolutional layer, a second C3k2 module, a fourth convolutional layer, an FEM module, a fifth convolutional layer, a third C3k2 module, a GAM spatial attention mechanism module, an SPPF module, and an SE channel attention mechanism module connected in sequence. The FEM module includes a multi-branch convolutional module and a cross-branch attention interaction module. The multi-branch convolutional module includes a 1×3 convolutional kernel branch, a 3×1 convolutional kernel branch, and a 3×3 convolutional kernel branch. A dilated convolutional layer is introduced in the 3×3 convolutional kernel branch. The gear image to be detected is input into the second gear defect detection model that has been trained to convergence. In the middle branch of the multi-branch convolution module in the FEM module, a dilated convolution layer is introduced to expand the receptive field to capture contextual information. In parallel, multi-scale and multi-receptive field defect features in the gear image to be detected are extracted to construct an intermediate feature map. After being processed by the cross-branch attention interaction module, the first enhanced defect feature map is output. In the GAM spatial attention mechanism module, the spatial location of the defect feature is focused in the first enhanced defect feature map by modeling the long-distance dependency between the global space and the channel. In the SE channel attention mechanism module, the channel features are adaptively recalibrated to highlight the channel of the defect feature, so as to output the second enhanced defect feature map. The second enhanced defect feature map is input into the detection head network in the second gear defect detection model to detect the gear defect type in the gear image to be detected. Based on the gear defect type, a corresponding defect alarm command is generated and transmitted to the operation interface of the gear defect detection system to complete the fault detection of gear defects.

2. The gear defect detection method according to claim 1, characterized by, The step of introducing a dilated convolutional layer in the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field to capture contextual information, and extracting multi-scale, multi-receptive field defect features from the gear image to be detected in parallel to construct an intermediate feature map, which is then input into the cross-branch attention interaction module for processing to output the first enhanced defect feature map, includes: In the cross-branch attention interaction module, an intermediate feature map is obtained, which is constructed from defect features of multiple scales and multiple receptive fields. The intermediate feature map is subjected to a convolution operation to generate a query branch feature map and a support branch feature map, the query branch feature map is matrix multiplied with the support branch feature map to calculate the spatial correlation between features, and a query branch attention map and a support branch attention map are obtained to locate the defect key area in the gear image to be detected; The intermediate feature map is subjected to a convolution operation to generate a query branch value feature map and a support branch value feature map, the query branch value feature map is weighted aggregated with the query branch attention map, and the support branch value feature map is weighted aggregated with the support branch attention map, to determine the defect feature map after weighted aggregation. The weighted aggregated defect feature maps output by the query branch and the support branch are fused after being processed by a conversion function layer, to determine the first enhanced defect feature map.

3. The gear defect detection method according to claim 1, characterized by, In the GAM spatial attention mechanism module, the step of focusing on the spatial position of the defect feature in the first enhanced defect feature map by modeling the long-distance dependence between global space and channels includes: In the GAM spatial attention mechanism module, the first enhanced defect feature map is sequentially processed by a first 3x3 convolution layer, a first ReLU function activation layer, a first batch normalization layer, a second 3x3 convolution layer, and a first Sigmoid activation function layer, to generate channel attention weights to dynamically enhance the feature channels related to the defect feature, and to generate a channel-enhanced first enhanced defect feature map; The channel-enhanced first enhanced defect feature map is sequentially processed by a first 5x5 convolution layer, a second ReLU function activation layer, a second batch normalization layer, a second 5x5 convolution layer, and a second Sigmoid activation function layer, to generate a spatial attention feature map to focus on the key area of the defect feature in the spatial position in the first enhanced defect feature map.

4. The gear defect detection method according to claim 3, characterized by, In the SE channel attention mechanism module, the step of adaptively recalibrating the channel feature to highlight the channel of the defect feature to output the second enhanced defect feature map includes: In the SE channel attention mechanism module, the defect feature map output by the GAM spatial attention mechanism module is subjected to global average pooling to generate a global channel descriptor to aggregate the global information of each channel; Channel attention weights are generated through two fully connected layers to quantify the importance of each channel to defect detection, The channel attention weights are multiplied with the defect feature map channel by channel to enhance the response of the defect feature channel, to highlight the channel of the defect feature in the defect feature map, and to output the second enhanced defect feature map.

5. The gear defect detection method according to claim 1, characterized by, The step of training the second gear defect detection model includes: Obtaining a sample data set, wherein the sample data set includes a plurality of training samples and corresponding supervision labels, the training samples represent single gear images, and the supervision labels represent the label information of the gear defect type in the gear image; The second gear defect detection model is trained by using the sample data set, in the training process, the bounding box regression of the second gear defect detection model is optimized according to the alpha-IoU loss function, the feature learning of difficult classification training samples is strengthened through the Focal Loss mechanism, and the training of the second gear defect detection model is stopped until the second gear defect detection model is trained to a convergence state, so as to complete the training of the second gear defect detection model.

6. The gear defect detection method according to any one of claims 1 to 5, characterized by, The gear defect types include tooth missing defects, crack defects, wear defects and foreign matter defects; wherein the foreign matter includes metal debris, oil dirt condensation blocks and dust accumulations. The basic network architecture of the first gear defect detection model is an original YOLOv11 target detection model, and the basic network architecture of the second gear defect detection model is an improved YOLOv11 target detection model.

7. A gear defect detection apparatus characterized by comprising: It comprises: A gear image acquisition module is arranged to acquire a gear image to be detected containing multiple gear defect types; A detection model construction module is arranged to update a third C3k2 module in a backbone network of a preset first gear defect detection model to a FEM module, introduce a GAM-SE cascaded attention mechanism module in the backbone network, update an IoU loss function of the first gear defect detection model to an alpha-IoU loss function, and introduce a Focal Loss mechanism, so as to construct a second gear defect detection model, wherein the backbone network of the second gear defect detection model comprises an input layer, a first convolutional layer, a second convolutional layer, a first C3k2 module, a third convolutional layer, a second C3k2 module, a fourth convolutional layer, a FEM module, a fifth convolutional layer, a third C3k2 module, a GAM spatial attention mechanism module, an SPPF module and an SE channel attention mechanism module connected in sequence; the FEM module comprises a multi-branch convolutional module and a cross-branch attention interaction module, wherein the multi-branch convolutional module comprises a 1x3 convolutional kernel branch, a 3x1 convolutional kernel branch and a 3x3 convolutional kernel branch, wherein a hollow convolutional layer is introduced in the 3x3 convolutional kernel branch; A first feature enhancement module is arranged to input the gear image to be detected into the second gear defect detection model trained to a convergence state, introduce a hollow convolutional layer in the middle branch of the multi-branch convolutional module in the FEM module to expand the receptive field and capture the context information, extract the defect features of multiple scales and multiple receptive fields in the gear image to be detected in parallel to construct an intermediate feature map, and input the intermediate feature map to the cross-branch attention interaction module for processing, so as to output a first enhanced defect feature map; A second feature enhancement module is arranged to focus on the spatial position of the defect feature in the first enhanced defect feature map by modeling the long-distance dependence between the global space and the channels in the GAM spatial attention mechanism module, and to highlight the channel of the defect feature by adaptively recalibrating the channel features in the SE channel attention mechanism module, so as to output a second enhanced defect feature map. The gear defect detection module is configured to input the second enhanced defect feature map into a detection head network in the second gear defect detection model to detect a gear defect type in the gear image to be detected, and generate a corresponding defect alarm instruction according to the gear defect type, and transmit the defect alarm instruction to an operation interface in the gear defect detection system to complete fault detection of the gear defect.

8. An electronic device comprising a central processing unit and a memory, characterized in that The central processing unit is configured to invoke a computer program stored in the memory to execute the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer program is stored in the form of computer readable instructions and is implemented according to the method of any one of claims 1 to 6, and when the computer program is invoked and run by a computer, the steps included in the corresponding method are executed.

Citation Information

Patent Citations

  • Gear end face defect detection method based on multi-scale target detection

    CN119904444A

  • Fan blade defect detection method and system based on improved SSD model

    WO2023173598A1