A method and system for cross-domain gear surface defect detection

CN122289268BActive Publication Date: 2026-09-11JIANGNAN UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610730370.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-05-26
Publication Date
2026-09-11
Estimated Expiration
2046-05-26

AI Technical Summary

Technical Problem

[0007]为此,本发明所要解决的技术问题在于克服由于源域和目标域之间存在较大差异,齿轮表面缺陷检测模型从源域迁移至目标域的过程中特征难以对齐,导致齿轮表面缺陷检测模型精度较差的缺陷

Benefits of technology

[0019]This invention discloses a cross-domain gear surface defect detection method and system. An attention module is introduced before the domain discriminator to align the global feature distributions of the source and target domains, mitigating feature transfer obstacles caused by overall domain offset. Simultaneously, a domain-aware attention mechanism is constructed within the domain discriminator. Through encoding and channel mapping of the feature map spatial semantics, the model is guided to focus on defect semantic regions in the image with high cross-domain adaptability, suppressing domain-specific noise interference such as background and illumination, making the global alignment process more selective and targeted. Based on the classification prediction results of the target domain samples, class prototypes for each defect type are constructed. Soft pseudo-labels are then used to label unlabeled target domain samples using these class prototypes, and their class weights are calculated. Combined with the class weights corresponding to the true one-hot labels of the source domain samples, a local maximum mean difference is introduced as a conditional distribution alignment criterion. Based on global adversarial alignment, fine-grained class-level conditional alignment between the source and target domains under the same defect category is achieved. This layer-by-layer optimization of inter-domain feature matching from global to local levels effectively solves the cross-domain feature alignment problem in multi-class scenarios, improving the detection accuracy of the cross-domain gear surface defect detection model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289268B_ABST
    Figure CN122289268B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of gear surface defect detection, and particularly relates to a cross-domain gear surface defect detection method and system. In order to enrich the diversity of training samples and reduce background interference, an implicit information fusion strategy based on Fourier decoupling is proposed, which retains constant phase information and weakens amplitude information, so that the model can learn more robust semantic features; in view of the problem that the distribution difference between domains is difficult to bridge, a field adversarial adaptation framework is constructed to reduce global domain offset, and a domain perception attention mechanism is designed to guide the model to focus on the semantic area of cross-domain adaptation value; on the basis of global alignment, a class prototype label maximum mean difference is designed, and on the basis of global adversarial alignment, a more fine class-level conditional alignment is further realized. The present application effectively improves the detection accuracy of the surface defect detection model for gear surface defects in an unsupervised cross-domain scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of gear surface defect detection technology, and in particular to a cross-domain gear surface defect detection method and system. Background Technology

[0002] Gears, as crucial mechanical transmission components, are widely used in various mechanical equipment in industrial production. Their performance and reliability directly affect the operating efficiency and lifespan of the mechanical system. However, due to complex manufacturing processes and high-intensity working environments, various defects often appear on gear surfaces, such as fatigue cracks, wear, and scratches. These defects may gradually develop under adverse conditions, eventually leading to gear failure. Therefore, defect detection on gear surfaces is particularly important.

[0003] Computer vision technology, as a non-contact, rapid response solution, has advantages over traditional manual inspection and mechanical testing, such as high efficiency, high precision, high degree of automation, and adaptability to various surface materials and defect types.

[0004] Traditional machine vision surface defect detection technology typically combines image processing with shallow machine learning, playing a crucial role in numerous industrial sectors and serving as a key link in ensuring product quality. The core challenge of traditional machine vision surface defect detection technology lies in extracting good feature representations to accurately distinguish between defective and non-defective areas. This requires engineers specializing in the field to manually select and design feature extraction methods and appropriate classifiers for defect detection, which limits its applicability and scalability to some extent. Furthermore, since manually designed features may not cover all situations, traditional machine vision surface defect detection technology often performs poorly when handling complex and varied defect types.

[0005] With the rapid development of deep learning technology, emerging deep learning-based defect detection methods have gradually attracted widespread attention. Deep learning models can automatically learn feature representations from data, no longer relying on manually designed features, thus possessing stronger generalization ability and adaptability. However, in actual industrial inspection scenarios, various external factors such as lighting, resolution, and equipment can interfere, causing differences between the training scenario and the target task scenario. Directly applying a trained model to the target task scenario will result in a significant performance degradation.

[0006] To address the aforementioned issues, unsupervised domain adaptation methods train the model on both labeled source domain data and unlabeled target domain data, extending the model from the source domain to the target domain. This leverages knowledge from the source domain data to compensate for the deficiencies in the labeled data in the target domain, thereby improving the model's generalization ability and adaptability. However, in existing unsupervised domain adaptation methods, due to the significant differences between the source and target domains, feature alignment is difficult during the model's migration from the source to the target domain, leading to a substantial decrease in classification accuracy. Summary of the Invention

[0007] Therefore, the technical problem to be solved by the present invention is to overcome the defect that the features of the gear surface defect detection model are difficult to align during the migration of the gear surface defect detection model from the source domain to the target domain due to the large difference between the source domain and the target domain, resulting in poor accuracy of the gear surface defect detection model.

[0008] To address the aforementioned technical problems, this invention provides a method for detecting surface defects in cross-domain gears, comprising: The training set is obtained by acquiring gear surface images containing different gear types and different defect types. The training set samples are divided into regions according to gear type, including the source region and the target region. A cross-domain gear surface defect detection model is constructed, which includes a feature extractor, a classifier, and a neighborhood discriminator; the neighborhood discriminator is obtained by setting an attention mechanism before the discriminator. The samples from each domain are processed by a feature extractor to obtain feature maps of the samples from each domain. The feature maps of samples from each domain are passed through a domain discriminator to obtain the domain attribution determination results of samples from each domain and the domain-aware feature maps output by the attention mechanism; By passing the domain-aware feature maps of samples from each domain through a classifier, the defect classification prediction results of samples from each domain are obtained. Based on the domain-aware feature maps and defect classification prediction results of each target domain sample, class prototypes of different defect types are obtained; Based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type, the weight of each target domain sample to each defect category is obtained. Based on the similarity between the domain-aware feature maps of each source domain sample and the one-hot labels of each defect type, the weight of each source domain sample to each defect category is obtained. Based on the weights of samples from each domain for each defect category and the domain-aware feature maps of samples from each domain, the maximum mean difference distance loss is constructed. A total loss function is constructed using the maximum mean difference distance loss, classification loss, and neighborhood discrimination loss. This function is then used to train the cross-domain gear surface defect detection model, resulting in the target cross-domain gear surface defect detection model. Finally, the target cross-domain gear surface defect detection model is used to detect gear surface defects in actual gear surface images.

[0009] Preferably, the formula for obtaining class prototypes of different defect types based on the domain-aware feature maps and defect classification prediction results of each target domain sample is as follows: , in, For the first The class prototype of class defects The total number of samples in the target domain. For the target domain sample index, For the first The target domain sample belongs to the first The probability of class defects, For defect type index, For the first Domain-aware feature maps of target domain samples.

[0010] Preferably, the formula for obtaining the weight of each target domain sample for each defect category based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type is as follows: , in, For the first The nth target domain sample pair Weights of class defects For defect type index, For the first The domain-aware feature map of the target domain sample and the first target domain sample Similarity between class prototypes of class defects For the first The domain-aware feature map of the target domain sample and the first target domain sample Similarity between class prototypes of class defects For the first One target domain sample, , For the target domain sample index, The target domain sample set.

[0011] Preferably, the maximum mean difference distance loss is: , in, For the maximum mean difference distance loss, This represents the total number of defect types. For defect type index, The total number of samples in the source domain. The total number of samples in the target domain. For the first Domain-aware feature maps of source domain samples For the first Domain-aware feature maps of source domain samples This represents the Gaussian kernel function that maps the domain-aware feature map to the Hilbert space. For the first The source domain sample pairs of the first Weights of class defects For the first The source domain sample pairs of the first Weights of class defects For the first The nth target domain sample pair Weights of class defects For the first The nth target domain sample pair Weights of class defects , For source domain sample index, , Index the target domain samples.

[0012] Preferably, the cross-domain gear surface defect detection model further includes: a Fourier enhancement module; The Fourier enhancement module expands the training set based on samples from various domains to obtain the target training set, including: The selected target domain samples are subjected to Fast Fourier Transform to obtain the amplitude spectrum and phase spectrum of each channel of the selected target domain samples; Any source domain sample whose highest confidence level is in the same threshold range as the highest confidence level of the selected target domain sample is taken as the selected source domain sample. Using the amplitude spectrum of each channel of the selected source domain sample, linear interpolation is performed on the amplitude spectrum of each channel of the selected target domain sample to obtain the amplitude spectrum of each channel of the fused sample. The phase spectrum of each channel of the selected target domain sample is used as the phase spectrum of each channel of the fused sample. Based on the amplitude spectrum and phase spectrum of each channel of the fused sample, the fused sample is generated through inverse Fourier transform; The generated fused samples are used as augmentation samples for the training set to obtain the target training set.

[0013] Preferably, the method for optimizing the total loss function to obtain the target total loss function includes: The fused samples are processed by a feature extractor to obtain the feature map of the fused samples; The feature maps of the fused samples are passed through a classifier to obtain the defect classification prediction results of the fused samples; The KL divergence between the defect classification prediction results of the fused samples and the corresponding defect classification prediction results of the selected target domain samples is used as the consistency loss. The cross-entropy loss between the defect classification prediction results of the fused samples and the corresponding true defect labels of the selected source domain samples is used as the supervision loss; Construct Fourier enhancement loss using consistency loss and supervision loss; By fusing the Fourier enhancement loss and the total loss function, the target total loss function is obtained.

[0014] Preferably, the Fourier enhancement loss is: , in, To enhance the Fourier loss, This indicates the calculation of KL divergence. The defect classification prediction results are for the selected target domain samples. For the defect classification prediction results of the fused samples, Represents cross-entropy loss, Represents a classifier. Indicates feature extractor, Indicates fused samples, The true defect labels of the selected source domain samples corresponding to the fused samples.

[0015] Preferably, the target total loss function is: , in, Let the target total loss function be... To enhance the Fourier loss, For the maximum mean difference distance loss, The total domain adversarial loss consists of classification loss and domain discrimination loss. As a scaling factor, This is a dynamic weighting factor.

[0016] Preferably, the attention mechanism is a domain-aware attention mechanism; the feature maps of samples from each domain are passed through a domain discriminator to obtain the domain-aware feature maps output by the attention mechanism for each domain sample, including: The feature map of each domain sample is passed sequentially through a 3×3 convolutional layer, a ReLU activation function, a 1×1 convolutional layer, and a Sigmoid activation function to obtain the domain response of the feature map of each domain sample. Based on the domain response of the feature map of each domain sample, the domain-aware metric of the feature map of each domain sample is generated using the entropy criterion. By using the domain-aware metric of the feature map of each domain sample, the feature map of each domain sample is weighted to obtain the domain-aware feature map of each domain sample.

[0017] The present invention also provides a cross-domain gear surface defect detection system, comprising: The training set acquisition module is used to acquire gear surface images containing different gear types and different defect types as the training set. The training set samples are divided into regions according to gear type, and the regions include the source region and the target region. The model building module is used to construct a cross-domain gear surface defect detection model, which includes a feature extractor, a classifier, and a neighborhood discriminator; the neighborhood discriminator is obtained by setting an attention mechanism before the discriminator. The feature extraction module is used to process samples from various domains through a feature extractor to obtain feature maps of the samples from each domain. The domain discrimination module is used to pass the feature maps of samples from each domain through the domain discriminator to obtain the domain attribution determination results of samples from each domain and the domain-aware feature maps output by the attention mechanism; The prediction module is used to pass the domain-aware feature maps of samples from various domains through a classifier to obtain the defect classification prediction results of samples from various domains. The class prototype acquisition module is used to obtain class prototypes of different defect types based on the domain-aware feature maps and defect classification prediction results of each target domain sample. The target domain weight acquisition module is used to obtain the weight of each target domain sample for each defect category based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type. The source domain weight acquisition module is used to obtain the weight of each source domain sample for each defect category based on the similarity between the domain-aware feature map of each source domain sample and the one-hot label of each defect type. The maximum mean difference distance loss construction module is used to construct the maximum mean difference distance loss based on the weights of samples from each domain to each defect category and the domain-aware feature maps of samples from each domain. The detection module is used to construct a total loss function using the maximum mean difference distance loss, classification loss, and neighborhood discrimination loss, and to train the cross-domain gear surface defect detection model to obtain the target cross-domain gear surface defect detection model; the target cross-domain gear surface defect detection model is then used to detect gear surface defects on actual gear surface images.

[0018] Compared with the prior art, the above-described technical solution of the present invention has the following advantages:

[0019] This invention discloses a cross-domain gear surface defect detection method and system. An attention module is introduced before the domain discriminator to align the global feature distributions of the source and target domains, mitigating feature transfer obstacles caused by overall domain offset. Simultaneously, a domain-aware attention mechanism is constructed within the domain discriminator. Through encoding and channel mapping of the feature map spatial semantics, the model is guided to focus on defect semantic regions in the image with high cross-domain adaptability, suppressing domain-specific noise interference such as background and illumination, making the global alignment process more selective and targeted. Based on the classification prediction results of the target domain samples, class prototypes for each defect type are constructed. Soft pseudo-labels are then used to label unlabeled target domain samples using these class prototypes, and their class weights are calculated. Combined with the class weights corresponding to the true one-hot labels of the source domain samples, a local maximum mean difference is introduced as a conditional distribution alignment criterion. Based on global adversarial alignment, fine-grained class-level conditional alignment between the source and target domains under the same defect category is achieved. This layer-by-layer optimization of inter-domain feature matching from global to local levels effectively solves the cross-domain feature alignment problem in multi-class scenarios, improving the detection accuracy of the cross-domain gear surface defect detection model. Attached Figure Description

[0020] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein:

[0021] Figure 1 This is a schematic flowchart of a cross-domain gear surface defect detection method according to the present invention.

[0022] Figure 2 This is a structural diagram of a cross-domain gear surface defect detection model.

[0023] Figure 3 This is a structural diagram of the domain-aware attention mechanism. Detailed Implementation

[0024] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.

[0025] In practical industrial inspection scenarios, due to various factors such as production processes, equipment performance, and material differences, gear surface defects often exhibit unavoidable distribution differences under different acquisition environments. Domain offset severely weakens the generalization ability of the detection model in new environments, leading to a significant decrease in the detection capability of the trained model in the target scenario. However, re-collecting and labeling defect data is costly, especially in practical industrial scenarios, and is often difficult to implement. Unsupervised domain adaptation methods do not rely on target domain labels; by aligning the data distributions of the source and target domains, they significantly reduce manual costs while maintaining transferability, thus gaining widespread attention and application in industrial defect detection. However, existing unsupervised domain adaptation methods still have limitations. They only align the source and target domains at the edge distribution level, rarely considering the differences in conditional distributions, thereby affecting the model's discrimination ability in the target domain. Therefore, this invention addresses the problems of difficulty in bridging domain offset and lack of supervision signals in the target domain data in cross-domain gear surface defect detection tasks by proposing a cross-domain gear surface defect detection method based on an improved domain adversarial adaptation network (IDAAN).

[0026] Reference Figure 1 As shown, this embodiment provides a method for detecting surface defects in cross-domain gears, including: Step S1: Obtain gear surface images containing different gear types and different defect types as a training set. Divide the training set samples into regions according to gear type. The regions include source region and target region. Source region samples have real defect labels, while target region samples have no labels. In this embodiment, surface images of Type I and Type II gears with four types of defects—cracks, dents, missing teeth, and powder shedding—are acquired. Type I and Type II gears represent gears manufactured using different processes. The training set includes 500 images of Type I gears with cracks, 200 images of Type I gears with dents, 300 images of Type I gears with missing teeth, 300 images of Type I gears with powder shedding, 500 images of Type II gears with cracks, 142 images of Type II gears with dents, 500 images of Type II gears with missing teeth, and 300 images of Type II gears with powder shedding. The test set includes 100 images of Type II gears with cracks, 50 images of Type II gears with dents, 70 images of Type II gears with missing teeth, and 70 images of Type II gears with powder shedding. In the test set, the source domain is divided into source and target domain samples, with the image samples corresponding to Type I gears as the source domain and the image samples corresponding to Type II gears as the target domain.

[0027] Step S2: Construct a cross-domain gear surface defect detection model, which includes a feature extractor, a classifier, and a neighborhood discriminator; the neighborhood discriminator is obtained by setting an attention mechanism before the discriminator. Step S3: Process the samples from each domain using a feature extractor to obtain feature maps for each domain sample; Step S4: Pass the feature maps of each domain sample through the domain discriminator to obtain the domain attribution determination results of each domain sample and the domain-aware feature map output by the attention mechanism; like Figure 3 As shown, Figure 3 This is a structural diagram of the domain-aware attention mechanism.

[0028] In this embodiment, preferably, the attention mechanism is a domain-aware attention mechanism; the feature maps of each domain sample are passed through a domain discriminator to obtain the domain-aware feature maps output by the attention mechanism corresponding to each domain sample, including: In domain adversarial scenarios, a domain-aware attention mechanism is introduced. The feature map of each domain sample is sequentially passed through a 3×3 convolutional layer, a ReLU activation function, a 1×1 convolutional layer, and a Sigmoid activation function. The output is normalized using the Sigmoid activation function to generate the domain response, thus obtaining the domain response of the feature map of each domain sample. ;in, Used to characterize domain samples Feature maps Domain response at a spatial location, For domain sample indexing, , and Representing domain samples respectively The width and height of the feature map depend on the output size of the feature extractor.

[0029] Based on the domain response of the feature map of each domain sample, the domain-aware metric of the feature map of each domain sample is generated using the entropy criterion. Domain-aware attention mechanisms aim to guide models to dynamically focus on semantic regions that are more adaptive in cross-domain scenarios. The more extreme the value, the more domain-specific the region is, indicating that it can provide significant cross-domain discriminative information and has high adaptation value. By assigning amplified attention response values ​​to these key regions, we can ensure that they receive more significant gradient activation during backpropagation, thereby enhancing the model's ability to model cross-domain differential structures and providing a clearer optimization direction for subsequent adaptation processes.

[0030] In information theory, the entropy function It is defined as The uncertainty measure effectively meets the need to quantify the adaptability value of each spatial region. This describes the probability of belonging to a certain class. Therefore, the entropy criterion is used to generate a domain-aware metric for each spatial location. Specifically: ,in, For domain samples Feature maps Domain-aware metric for a spatial location; By using the domain-aware metric of the feature map of each domain sample, the feature map of each domain sample is weighted to obtain the domain-aware feature map of each domain sample.

[0031] Domain-aware attention mechanisms can refine the transfer path from the source domain to the target domain, but incorrect attention distribution can negatively impact domain adaptation tasks. To mitigate this, a residual connection mechanism is introduced. The residual structure makes the model more robust to inaccurate attention, assigning greater attention weights to regions with higher cross-domain adaptation value on the original feature map. This causes the domain adaptation model to focus more on these regions, resulting in a weighted domain-aware feature map of the source and target domain samples. The unified representation is: , For domain samples Domain-aware feature map, For domain samples The feature map.

[0032] Step S5: Pass the domain-aware feature maps of samples from each domain through a classifier to obtain the defect classification prediction results of samples from each domain. Step S6: Based on the domain-aware feature maps and defect classification prediction results of each target domain sample, obtain the class prototypes for different defect types, using the following formula: , in, For the first The class prototype of class defects The total number of samples in the target domain. For the target domain sample index, For the first The target domain sample belongs to the first The probability of class defects, For defect type index, For the first Domain-aware feature maps of target domain samples.

[0033] Step S7: Based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type, obtain the weight of each target domain sample for each defect category, using the following formula: , in, For the first The nth target domain sample pair Weights of class defects For defect type index, For the first The domain-aware feature map of the target domain sample and the first target domain sample Similarity between class prototypes of class defects For the first The domain-aware feature map of the target domain sample and the first target domain sample Similarity between class prototypes of class defects For the first One target domain sample, , For the target domain sample index, The target domain sample set.

[0034] In this embodiment, cosine similarity is used, and the formula is: , in, For defect type index, For the first The class prototype of class defects For the first The class prototype of class defects This represents the cosine similarity.

[0035] Step S8: Based on the similarity between the domain-aware feature map of each source domain sample and the one-hot label of each defect type, obtain the weight of each source domain sample to each defect category; the weight of each source domain sample to each defect category is calculated using the real-labeled one-hot label.

[0036] Step S9: Based on the weights of each defect category for samples from each domain and the domain-aware feature maps of samples from each domain, construct the maximum mean difference distance loss; Domain adversarial mechanisms primarily reduce inter-domain differences by aligning the edge distributions of the source and target domains. However, in reality, inconsistencies in conditional distributions still exist between the two domains. ,in, It is distributed at the edge of the source domain. For the edge distribution of the target domain, The conditional distribution of the source domain samples. For the conditional distribution of the target domain, simply performing global distribution alignment can weaken the model's focus on class discrimination information, causing some task-irrelevant information to be introduced into the semantic representation, thus incorrectly associating semantic information between domains and affecting transfer performance. Therefore, constructing the maximum mean difference of class prototype labels further reduces the difference in conditional probability distributions between domains from the category level to achieve local alignment. The maximum mean difference of class prototype labels provides category information through class prototypes, achieving cross-domain class-level alignment. The data in the target domain is in an unsupervised setting due to the lack of real labeled information, and conditional distribution alignment needs to assign the probability of each sample belonging to each category. Traditional hard pseudo-labels generated based on the output of a single sample classifier are sensitive to prediction noise in the early stages of transfer, easily leading to error accumulation. The strategy of labeling using class prototypes can reflect the inherent structure in the semantic representation space, thus providing a soft membership estimate for each sample to each category. The unbiased estimation of the maximum mean difference of class prototype labels is as follows: , in, An unbiased estimate of the maximum mean difference for class prototype labels. For source domain distribution, The target domain is distributed as follows.

[0037] The final loss is calculated using the kernel trick: the maximum mean difference distance loss based on class prototype labeling. The maximum mean difference distance loss is: , in, For the maximum mean difference distance loss, This represents the total number of defect types. For defect type index, The total number of samples in the source domain. The total number of samples in the target domain. For the first Domain-aware feature maps of source domain samples For the first Domain-aware feature maps of source domain samples This represents the Gaussian kernel function that maps the domain-aware feature map to the Hilbert space. For the first The source domain sample pairs of the first Weights of class defects For the first The source domain sample pairs of the first Weights of class defects For the first The nth target domain sample pair Weights of class defects For the first The nth target domain sample pair Weights of class defects , For source domain sample index, , Index the target domain samples.

[0038] Step S10: Construct a total loss function using the maximum mean difference distance loss, classification loss, and neighborhood discrimination loss, and train the cross-domain gear surface defect detection model to obtain the target cross-domain gear surface defect detection model; use the target cross-domain gear surface defect detection model to detect gear surface defects in actual gear surface images.

[0039] In this embodiment, specifically, a classification loss is constructed based on the cross-entropy between the defect classification prediction results of each source domain sample and its true defect label; The classification loss is: , in, For classifying losses, The total number of samples in the source domain. For source domain samples, For the source domain sample set, The defect classification prediction results for the source domain samples. The true labels of the source domain samples. Represents cross-entropy loss, This represents a classifier.

[0040] The domain discriminator classifies the source and target domain features output by the feature extractor, while the feature extractor uses adversarial training to confuse the discriminator's judgment. A domain discrimination loss is constructed based on the domain attribution determination results of each domain sample and the loss between the loss and the true domain label. Domain discrimination loss is: , in, To determine the loss in the field, The total number of samples in the source domain. The total number of samples in the target domain. Indicates feature extractor, This represents a domain discriminator. For the j-th domain sample, For the target domain sample set, For the source domain sample set, The true domain label for the j-th domain sample is defined by labeling the source domain and the target domain as 1 and 0, respectively.

[0041] like Figure 2 As shown, Figure 2 This is a structural diagram of a cross-domain gear surface defect detection model.

[0042] In this embodiment, preferably, the cross-domain gear surface defect detection model further includes: a Fourier enhancement module; The Fourier enhancement module expands the training set based on samples from various domains to obtain the target training set, including: Select any target domain sample from the training set as the selected target domain sample; The selected target domain samples are subjected to Fast Fourier Transform (FFT) to obtain the amplitude spectrum and phase spectrum of each channel of the selected target domain samples. The formula is as follows: , in, The spatial dimensions of the gear surface image. For the frequency index in the height direction in the frequency domain, This refers to the frequency index in the width direction within the frequency domain. , The height of the gear surface image, The width of the gear surface image. Spatial index in the width direction of the gear surface image. Spatial index in the height direction of the gear surface image. This represents the complex spectrum in the frequency domain of the current channel of the image on the gear surface. The coordinates of the gear surface image in the current channel space The pixel value at that location.

[0043] The Fast Fourier Transform (FFT) can be used to efficiently calculate the frequency domain representation of an image. The transform result is in complex form and can be further decomposed into amplitude and phase spectra, as shown in the formula: , in, The current channel's frequency domain coordinates The amplitude value at that point, The current channel's frequency domain coordinates Phase value at that point, The complex spectrum in the frequency domain after Fourier transform of the current channel is... The real part of the place, that is The real part, The complex spectrum in the frequency domain after Fourier transform of the current channel is... The virtual part of the place, that is The imaginary part, Any source domain sample whose highest confidence level is in the same threshold range as the highest confidence level of the selected target domain sample is taken as the selected source domain sample. Using the amplitude spectrum of each channel of the selected source domain sample, linear interpolation is performed on the amplitude spectrum of each channel of the selected target domain sample to obtain the amplitude spectrum of each channel of the fused sample. The formula is as follows: , in, To fuse the amplitude spectrum of the current channel of the sample, For the selected source domain samples, i.e., the source domain Predicting the class of Top-k high-confidence samples in the target domain Consistent samples The amplitude spectrum of the current channel of the selected target domain sample. The amplitude spectrum of the current channel of the selected source domain sample. Used to control the strength of the enhancement.

[0044] Phase spectrum of each channel of the selected target domain sample , which serves as the phase spectrum of each channel in the fused sample; Based on the amplitude and phase spectra of each channel of the fused sample, a fused sample is generated through inverse Fourier transform. The formula is: , in, To obtain the complex spectrum in the frequency domain of the current channel of the fused sample, This represents the two-dimensional inverse Fourier transform operation.

[0045] The generated fused samples are used as augmentation samples for the training set to obtain the target training set.

[0046] By enhancing the amplitude information in the original target domain image with source domain data, the model learns more diverse images reconstructed based on amplitude information, while fixing the phase component to preserve semantic information. Since the target domain data is unlabeled, high-confidence samples are selected and fused with corresponding category samples from the source domain.

[0047] The Fourier enhancement module utilizes the Fourier transform to decouple a signal into phase and amplitude information in the frequency domain. The phase component in the spectrum primarily retains the high-order semantics and structural information of the original signal, while the amplitude component reflects low-order statistics. Linear interpolation is performed on the amplitude spectra of high-confidence unlabeled samples in the target domain and samples from the corresponding category in the source domain. This preserves key phase information while suppressing amplitude information, enhancing discriminative semantic representation capabilities and reducing interference from inter-domain background noise.

[0048] Methods for optimizing the total loss function to obtain the target total loss function include: The fused samples are processed by a feature extractor to obtain the feature map of the fused samples; The feature maps of the fused samples are passed through a classifier to obtain the defect classification prediction results of the fused samples; The KL divergence between the defect classification prediction results of the fused samples and the corresponding defect classification prediction results of the selected target domain samples is used as the consistency loss. The cross-entropy loss between the defect classification prediction results of the fused samples and the corresponding true defect labels of the selected source domain samples is used as the supervision loss; Construct Fourier enhancement loss using consistency loss and supervision loss; Due to the inherent uncertainties in the data fusion process, to ensure semantic consistency between the data before and after enhancement, a Fourier enhancement loss is used during the training process of the enhanced image. It consists of supervision loss and consistency loss, where consistency loss is used to ensure that the fused data is consistent with the original data in terms of category distribution.

[0049] The Fourier enhancement loss is: , in, To enhance the Fourier loss, This represents the calculation of the KL divergence (Kullback-Leibler, KL). The defect classification prediction results are for the selected target domain samples. For the defect classification prediction results of the fused samples, Represents cross-entropy loss, Represents a classifier. Indicates feature extractor, Indicates fused samples, The true defect labels of the selected source domain samples corresponding to the fused samples.

[0050] By fusing the Fourier enhancement loss and the total loss function, the target total loss function is obtained.

[0051] The target total loss function is: , in, Let the target total loss function be... To enhance the Fourier loss, For the maximum mean difference distance loss, The total domain adversarial loss consists of classification loss and domain discrimination loss. This is a scaling factor used to control... The degree of influence on the training of the cross-domain gear surface defect detection model. This is a dynamic weighting factor that gradually increases with the number of training iterations, used to adjust the loss term. To take control.

[0052] In this embodiment, the test set is input into the trained gear surface defect detection model to obtain the results of gear surface defect detection in the target domain. The images in the test set are all samples from the target domain.

[0053] This invention presents a cross-domain gear surface defect detection method. To address the lack of labeled supervision in the target domain samples, which limits transfer information and consequently restricts the model's ability to learn discriminative semantic information about defects, an implicit information fusion strategy based on Fourier decoupling is employed. This strategy linearly interpolates the amplitude spectra of high-confidence unlabeled samples from the target domain and samples from the source domain to generate fused data, thus expanding the diversity of training samples. Simultaneously, the original phase information is preserved while the original amplitude information is weakened to enhance the model's representation ability of cross-domain semantic information and reduce the impact of the background environment on model training. Secondly, to address the significant distribution differences between domains, a domain adversarial mechanism is introduced to align global feature distributions. Furthermore, a domain-aware attention mechanism is constructed in the domain discriminator to guide the model to focus on semantic regions with high cross-domain adaptation value within the same image, achieving a more selective alignment process. Finally, to solve the problem that domain adversarial methods neglect class-level alignment requirements and are prone to inter-class confusion in multi-class tasks, soft pseudo-labels are used to mark target domain samples using class prototypes, and a local maximum mean difference is introduced as a conditional alignment criterion, achieving more refined class-level conditional alignment based on global adversarial alignment.

[0054] Embodiment 2 of the present invention provides a cross-domain gear surface defect detection system, comprising: The training set acquisition module is used to acquire gear surface images containing different gear types and different defect types as the training set. The training set samples are divided into regions according to gear type, and the regions include the source region and the target region. The model building module is used to construct a cross-domain gear surface defect detection model, which includes a feature extractor, a classifier, and a neighborhood discriminator; the neighborhood discriminator is obtained by setting an attention mechanism before the discriminator. The feature extraction module is used to process samples from various domains through a feature extractor to obtain feature maps of the samples from each domain. The domain discrimination module is used to pass the feature maps of samples from each domain through the domain discriminator to obtain the domain attribution determination results of samples from each domain and the domain-aware feature maps output by the attention mechanism; The prediction module is used to pass the domain-aware feature maps of samples from various domains through a classifier to obtain the defect classification prediction results of samples from various domains. The class prototype acquisition module is used to obtain class prototypes of different defect types based on the domain-aware feature maps and defect classification prediction results of each target domain sample. The target domain weight acquisition module is used to obtain the weight of each target domain sample for each defect category based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type. The source domain weight acquisition module is used to obtain the weight of each source domain sample for each defect category based on the similarity between the domain-aware feature map of each source domain sample and the one-hot label of each defect type. The maximum mean difference distance loss construction module is used to construct the maximum mean difference distance loss based on the weights of samples from each domain to each defect category and the domain-aware feature maps of samples from each domain. The detection module is used to construct a total loss function using the maximum mean difference distance loss, classification loss, and neighborhood discrimination loss, and to train the cross-domain gear surface defect detection model to obtain the target cross-domain gear surface defect detection model; the target cross-domain gear surface defect detection model is then used to detect gear surface defects on actual gear surface images.

[0055] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0056] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0057] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0058] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0059] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.

Claims

1. A method for detecting surface defects in cross-domain gears, characterized in that, include: The training set is obtained by acquiring gear surface images containing different gear types and different defect types. The training set samples are divided into regions according to gear type, including the source region and the target region. A cross-domain gear surface defect detection model is constructed, which includes a feature extractor, a classifier, and a neighborhood discriminator; the neighborhood discriminator is obtained by setting an attention mechanism before the discriminator. The samples from each domain are processed by a feature extractor to obtain feature maps of the samples from each domain. The feature maps of samples from each domain are passed through a domain discriminator to obtain the domain attribution determination results of samples from each domain and the domain-aware feature maps output by the attention mechanism; By passing the domain-aware feature maps of samples from each domain through a classifier, the defect classification prediction results of samples from each domain are obtained. Based on the domain-aware feature maps and defect classification prediction results of each target domain sample, class prototypes of different defect types are obtained; Based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type, the weight of each target domain sample to each defect category is obtained. Based on the similarity between the domain-aware feature maps of each source domain sample and the one-hot labels of each defect type, the weight of each source domain sample to each defect category is obtained. Based on the weights of samples from each domain for each defect category and the domain-aware feature maps of samples from each domain, the maximum mean difference distance loss is constructed. A total loss function is constructed using the maximum mean difference distance loss, classification loss, and neighborhood discrimination loss. This function is then used to train the cross-domain gear surface defect detection model, resulting in the target cross-domain gear surface defect detection model. Finally, the target cross-domain gear surface defect detection model is used to detect gear surface defects in actual gear surface images.

2. The method for detecting surface defects in cross-domain gears according to claim 1, characterized in that, The formula for obtaining class prototypes of different defect types based on the domain-aware feature maps and defect classification prediction results of each target domain sample is as follows: , in, For the first The class prototype of class defects The total number of samples in the target domain. For the target domain sample index, For the first The target domain sample belongs to the first The probability of class defects, For defect type index, For the first Domain-aware feature maps of target domain samples.

3. The method for detecting surface defects in cross-domain gears according to claim 1, characterized in that, The formula for obtaining the weight of each target domain sample for each defect category based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type is as follows: , in, For the first The nth target domain sample pair Weights of class defects For defect type index, For the first The domain-aware feature map of the target domain sample and the first target domain sample Similarity between class prototypes of class defects For the first The domain-aware feature map of the target domain sample and the first target domain sample Similarity between class prototypes of class defects For the first One target domain sample, , For the target domain sample index, The target domain sample set.

4. The method for detecting surface defects in cross-domain gears according to claim 1, characterized in that, The maximum mean difference distance loss is: , in, For the maximum mean difference distance loss, This represents the total number of defect types. For defect type index, The total number of samples in the source domain. The total number of samples in the target domain. For the first Domain-aware feature maps of source domain samples For the first Domain-aware feature maps of source domain samples This represents the Gaussian kernel function that maps the domain-aware feature map to the Hilbert space. For the first The source domain sample pairs of the first Weights of class defects For the first The source domain sample pairs of the first Weights of class defects For the first The nth target domain sample pair Weights of class defects For the first The nth target domain sample pair Weights of class defects , For source domain sample index, , Index the target domain samples.

5. The method for detecting surface defects in cross-domain gears according to claim 1, characterized in that, The cross-domain gear surface defect detection model also includes: Fourier enhancement module; The Fourier enhancement module expands the training set based on samples from various domains to obtain the target training set, including: The selected target domain samples are subjected to Fast Fourier Transform to obtain the amplitude spectrum and phase spectrum of each channel of the selected target domain samples; Any source domain sample whose highest confidence level is in the same threshold range as the highest confidence level of the selected target domain sample is taken as the selected source domain sample. Using the amplitude spectrum of each channel of the selected source domain sample, linear interpolation is performed on the amplitude spectrum of each channel of the selected target domain sample to obtain the amplitude spectrum of each channel of the fused sample. The phase spectrum of each channel of the selected target domain sample is used as the phase spectrum of each channel of the fused sample. Based on the amplitude spectrum and phase spectrum of each channel of the fused sample, the fused sample is generated through inverse Fourier transform; The generated fused samples are used as augmentation samples for the training set to obtain the target training set.

6. The method for detecting surface defects in cross-domain gears according to claim 5, characterized in that, Methods for optimizing the total loss function to obtain the target total loss function include: The fused samples are processed by a feature extractor to obtain the feature map of the fused samples; The feature maps of the fused samples are passed through a classifier to obtain the defect classification prediction results of the fused samples; The KL divergence between the defect classification prediction results of the fused samples and the corresponding defect classification prediction results of the selected target domain samples is used as the consistency loss. The cross-entropy loss between the defect classification prediction results of the fused samples and the corresponding true defect labels of the selected source domain samples is used as the supervision loss; Construct Fourier enhancement loss using consistency loss and supervision loss; By fusing the Fourier enhancement loss and the total loss function, the target total loss function is obtained.

7. The method for detecting surface defects in cross-domain gears according to claim 6, characterized in that, The Fourier enhancement loss is: , in, To enhance the Fourier loss, This indicates the calculation of KL divergence. The defect classification prediction results are for the selected target domain samples. For the defect classification prediction results of the fused samples, Represents cross-entropy loss, Represents a classifier. Indicates feature extractor, Indicates fused samples, The true defect labels of the selected source domain samples corresponding to the fused samples.

8. The method for detecting surface defects in cross-domain gears according to claim 6, characterized in that, The target total loss function is: , in, Let the target total loss function be... To enhance the Fourier loss, For the maximum mean difference distance loss, The total domain adversarial loss consists of classification loss and domain discrimination loss. As a scaling factor, This is a dynamic weighting factor.

9. The method for detecting surface defects in cross-domain gears according to claim 1, characterized in that, The attention mechanism is a domain-aware attention mechanism; The feature maps of samples from each domain are passed through a domain discriminator to obtain the domain-aware feature maps output by the attention mechanism for each domain sample, including: The feature map of each domain sample is passed sequentially through a 3×3 convolutional layer, a ReLU activation function, a 1×1 convolutional layer, and a Sigmoid activation function to obtain the domain response of the feature map of each domain sample. Based on the domain response of the feature map of each domain sample, the domain-aware metric of the feature map of each domain sample is generated using the entropy criterion. By using the domain-aware metric of the feature map of each domain sample, the feature map of each domain sample is weighted to obtain the domain-aware feature map of each domain sample.

10. A cross-domain gear surface defect detection system, characterized in that, include: The training set acquisition module is used to acquire gear surface images containing different gear types and different defect types as the training set. The training set samples are divided into regions according to gear type, and the regions include the source region and the target region. The model building module is used to construct a cross-domain gear surface defect detection model, which includes a feature extractor, a classifier, and a neighborhood discriminator; the neighborhood discriminator is obtained by setting an attention mechanism before the discriminator. The feature extraction module is used to process samples from various domains through a feature extractor to obtain feature maps of the samples from each domain. The domain discrimination module is used to pass the feature maps of samples from each domain through the domain discriminator to obtain the domain attribution determination results of samples from each domain and the domain-aware feature maps output by the attention mechanism; The prediction module is used to pass the domain-aware feature maps of samples from various domains through a classifier to obtain the defect classification prediction results of samples from various domains. The class prototype acquisition module is used to obtain class prototypes of different defect types based on the domain-aware feature maps and defect classification prediction results of each target domain sample. The target domain weight acquisition module is used to obtain the weight of each target domain sample for each defect category based on the similarity between the domain-aware feature map of each target domain sample and the class prototype of each defect type. The source domain weight acquisition module is used to obtain the weight of each source domain sample for each defect category based on the similarity between the domain-aware feature map of each source domain sample and the one-hot label of each defect type. The maximum mean difference distance loss construction module is used to construct the maximum mean difference distance loss based on the weights of samples from each domain to each defect category and the domain-aware feature maps of samples from each domain. The detection module is used to construct a total loss function using the maximum mean difference distance loss, classification loss, and neighborhood discrimination loss, and to train the cross-domain gear surface defect detection model to obtain the target cross-domain gear surface defect detection model; the target cross-domain gear surface defect detection model is then used to detect gear surface defects on actual gear surface images.

Citation Information

Patent Citations

  • Surface defect detection method based on metric element learning

    CN120655571A

  • Industrial surface defect detection method and system based on deep learning

    CN121329851A