Sealing nail welding defect detection model training method, detection method, and related device

By using the span vectors of the source domain and the target domain to process the target domain sample features in the sealing nail welding defect detection model, the target generalization features are generated and the model is trained, and the problems of poor generalization and high labeling cost are solved, and defect detection with high accuracy is achieved.

WO2025161386A1PCT designated stage Publication Date: 2025-08-07CONTEMPORARY AMPEREX TECHNOLOGY CO LTD

Patent Information

Application Number
PCT/CN2024/116665
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-02-02
Filing Date
2024-09-03
Publication Date
2025-08-07

AI Technical Summary

Technical Problem

In the prior art, the sealing nail welding defect detection model has poor generalization when facing welding types in an unseen target domain, resulting in low detection accuracy and scarce target domain labeling samples resulting in high costs.

Method used

By obtaining the source model trained by the source domain data set and its first span vector and the second span vector of the target domain support set, the target domain sample features are processed to generate the target generalization feature, and using this feature to train the source model to generate a detection model that can be effectively generalized in the target domain.

Benefits of technology

It improves the accuracy of sealing nail defect detection, reduces the collapse of the model in the target domain, reduces the cost of manual labeling, significantly improves the detection accuracy and reduces the missed kill rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024116665_07082025_PF_FP_ABST
    Figure CN2024116665_07082025_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses a sealing nail welding defect detection model training method, a detection method, and a related device. The sealing nail welding defect detection model training method comprises: obtaining a source model obtained by training a source domain dataset in a source domain, wherein the source domain dataset comprises a plurality of first sealing nail sample images and first defect detection labels corresponding to the first sealing nail sample images; obtaining a first span vector of the source domain and a second span vector corresponding to a support set in a target domain, wherein the first span vector is determined on the basis of the source model, the support set comprises a plurality of second sealing nail sample images and second defect detection labels corresponding to the second sealing nail sample images; on the basis of the first span vector and the second span vector, processing sample features of the second sealing nail sample images to obtain corresponding target generalization features; and training the source model on the basis of the target generalization features to obtain a target detection model. According to the embodiments of the present application, the training accuracy of the detection model can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Sealing nail welding defect detection model training method, detection method and related device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application No. 202410153393.3, filed on February 2, 2024, entitled “Sealing nail welding defect detection model training method, detection method and related device,” and the entire contents of that application are incorporated herein by reference. Technical Field

[0003] The present application relates to the field of model training technology, and in particular to a sealing nail welding defect detection model training method, a detection method and related devices. Background Art

[0004] In the field of new energy technology, sealing pins are widely used in various lithium battery industrial manufacturing scenarios to ensure the sealing and safety of lithium battery products. However, welding defects are inevitable during the sealing pin welding process. Improving the accuracy of detection model training results is a key prerequisite for improving the sealing and safety of battery products.

[0005] At present, the defect detection model used to detect sealing nail welding defects in the relevant technology is trained using the original sealing nail welding image sample set in the source domain. However, when faced with sealing nail welding images of new welding types in the target domain that were not seen during the initial training of the model, the model has poor generalization, resulting in low model detection accuracy.

[0006] Summary of the Invention

[0007] The present application provides a sealing nail welding defect detection model training method, detection method and related devices, which can improve the generalization of the detection model and thus improve the model detection accuracy.

[0008] The present application provides a sealing nail welding defect detection model training method, which includes: obtaining a source model trained by a source domain data set in a source domain; the source domain data set includes multiple first sealing nail sample images and their corresponding first defect detection labels; obtaining a first span vector of the source domain and a second span vector corresponding to a support set in the target domain; the first span vector is determined based on the source model; the support set includes multiple second sealing nail sample images and their corresponding second defect detection labels; the first span vector is used to characterize the statistical feature distribution of the source domain, and the second span vector is used to characterize the feature statistical distribution of the target domain; based on the first span vector and the second span vector, the sample features of the second sealing nail sample image are processed to obtain corresponding target generalization features; based on the target generalization features, the source model is trained to obtain a target detection model, and the target detection model is used to detect sealing nail welding defects.

[0009] In the technical solution of the embodiment of the present application, by obtaining a source model obtained by training the source domain data set, and obtaining a first span vector obtained based on the source model and a second span vector corresponding to the support set in the target domain, the sample features of the second sealing nail sample image in the target domain support set are stylized according to the first span vector corresponding to the source domain and the second span vector corresponding to the target domain, and the corresponding target generalization feature is obtained. This target generalization feature includes the feature styles of both the source domain and the target domain. In this way, by continuing to train the source model in the target domain using this stylized target generalization feature, a target detection model that can be effectively generalized in the target domain is finally obtained, thereby effectively improving the accuracy of sealing nail defect detection by this target detection model. The embodiment of the present application uses the first span vector corresponding to the source domain and the second span vector of the target domain to stylize the support set sample features, and uses this processed target generalization feature to train the source model, so that the generalization and accuracy of the trained sealing nail defect detection model are improved, and the occurrence of model collapse in the target domain is effectively reduced. In addition, this embodiment can quickly continue to train the source model with a small number of labeled target domain sealing nail sample images, reducing the cost of manual expert labeling, and at the same time helping to significantly improve the accuracy of sealing nail defect detection and reduce the missed detection rate.

[0010] According to some embodiments of the present application, optionally, the processing of the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain the corresponding target generalization features includes: determining the LCCS statistic of the BN statistical data based on the first span vector and the second span vector; and processing the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization features.

[0011] In the technical solution of the embodiment of the present application, when the sample features of the second sealing nail sample image are processed based on the first span vector corresponding to the source domain and the second span vector of the target domain support set to obtain the above-mentioned target generalization features, the LCCS statistic is first calculated based on the first span vector and the second span vector, and then the sample features of the second sealing nail sample image are specifically processed based on the LCCS statistic, so that the above-mentioned target generalization features can be determined more reasonably.

[0012] According to some embodiments of the present application, optionally, before obtaining the first span vector based on the source domain and the second span vector corresponding to the support set in the target domain, the method further includes: determining a first number of feature representations corresponding one-to-one to a first number of second sealing nail sample images in the support set; determining a first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set; and determining the second span vector based on the first number of cross-domain feature vectors.

[0013] In this way, by specifically determining a first number of feature representations corresponding one-to-one to a first number of second sealing nail sample images in the target domain support set, and then determining a first number of cross-domain feature vectors based on the first number of feature representations and the support set BN statistics corresponding to the support set, the second span vector can be determined more reasonably and accurately based on the first number of cross-domain feature vectors.

[0014] According to some embodiments of the present application, optionally, in combination with actual training scenarios, the second span vector includes a first vector matrix and a second vector matrix; the first vector matrix includes the mean of the first number of cross-domain feature vectors, and the second vector matrix includes the variance of the first number of cross-domain feature vectors.

[0015] In this embodiment, the specific data in the second span vector is reasonably limited in consideration of the actual training scenario, which is conducive to the subsequent more effective feature generalization processing of the sample features of the second sealing nail sample image in the target domain support set based on this second span vector.

[0016] According to some embodiments of the present application, optionally, determining a first number of cross-domain feature vectors based on the first number of feature representations and the support set BN statistics corresponding to the support set includes: obtaining the first number of cross-domain feature vectors through aggregation or dimensionality reduction processing based on the first number of feature representations and the support set BN statistics.

[0017] In an embodiment of the present application, when determining the first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistical data, the above-mentioned first number of feature representations and support set BN statistical data are processed by specifically adopting aggregation or dimensionality reduction means, and ultimately a more simplified first number of cross-domain feature vectors can be obtained, which is conducive to subsequent reduction of computational burden and achieves the purpose of improving the training efficiency of the target detection model.

[0018] According to some embodiments of the present application, optionally, before determining the first number of cross-domain feature vectors based on the first number of feature representations and the support set BN statistics corresponding to the support set, the method further includes: performing data processing on the support set by an exponential moving average method to obtain the support set BN statistics.

[0019] In this way, before determining the first number of cross-domain feature vectors based on the first number of feature representations and the support set BN statistics corresponding to the support set, data processing of the support set in the target domain using the exponential moving average method can more reasonably obtain the above-mentioned support set BN statistics. Moreover, the exponential moving average method can be used to smoothly update the obtained support set BN statistics for one or more training epochs of model training.

[0020] According to some embodiments of the present application, optionally, before determining the LCCS statistic of the BN statistical data based on the first span vector and the second span vector, the method further includes: based on the principle of minimizing the cross-entropy loss of the support set, binding multiple candidate values ​​of the BN parameters in the LCCS statistic to the batch normalization layer in the source model, and using grid search to determine the initialization value of the BN parameter from the multiple candidate values; determining the LCCS statistic of the BN statistical data based on the first span vector and the second span vector includes: determining the LCCS statistic based on the first span vector, the second span vector and the initialization value of the BN parameter.

[0021] In an embodiment of the present application, in order to fully meet the requirements of model adaptive training and to more reasonably determine the above-mentioned LCCS statistic, multiple candidate values ​​of the BN parameter in the LCCS statistic can be first bound to the batch normalization layer in the source model based on the principle of minimizing the cross-entropy loss of the support set, and a grid search can be used to determine the initialization value of the BN parameter from the multiple candidate values. In this way, after determining the initialization value of the BN parameter, a more accurate LCCS statistic can be determined based on the first span vector, the second span vector, and the initialization value of the BN parameter, thereby facilitating the processing of the sample features of the second sealing nail sample image based on the LCCS statistic to obtain a more effective target generalization feature, thereby facilitating improving the accuracy and generalization of the target detection model.

[0022] According to some embodiments of the present application, optionally, in order to obtain a more accurate LCCS statistic, determining the LCCS statistic based on the first span vector, the second span vector, and the initialization value of the BN parameter includes:

[0023] Determining an LCCS statistic using a first calculation formula based on the first span vector, the second span vector, and an initialization value of a BN parameter;

[0024] The first calculation formula is:

[0025] Among them, μ LCCS , σ LCCS is the LCCS statistic, μ s , σ s is the first span vector, η s , ρ s ,η spt , ρ spt is the initialization value of BN parameters, M spt ,∑ spt is the second span vector.

[0026] According to some embodiments of the present application, optionally, the processing of the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization feature includes: in the process of training the source model based on the support set, updating the LCCS statistic in the current iteration process by a stochastic gradient descent method to obtain the LCCS statistic in the next iteration process; processing the sample features of the second sealing nail sample image based on the LCCS statistic in the next iteration process to obtain the target generalization feature.

[0027] In an embodiment of the present application, in order to fully guarantee the detection accuracy and generalization of the target detection model finally obtained by training, it is proposed that in the process of training the source model based on the support set, the model LCCS parameter optimization can be achieved by adopting the stochastic gradient descent method, so as to obtain target generalization features with better generalization effect. Specifically, in the process of training the source model based on the support set, the LCCS statistics in the current iteration process are updated by the stochastic gradient descent method to obtain the LCCS statistics in the next iteration process. In this way, the sample features of the second sealing nail sample image are processed based on the LCCS statistics in the next iteration process after the stochastic gradient update to obtain the target generalization features, which is more conducive to ensuring the validity of the model parameters and the accuracy of the target detection model.

[0028] According to some embodiments of the present application, optionally, more specifically, processing the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization feature includes: processing the sample features of the second sealing nail sample image based on the LCCS statistic and the scaling parameters corresponding to the source domain to obtain the target generalization feature; wherein the scaling parameters corresponding to the source domain are determined based on the source model.

[0029] According to some embodiments of the present application, optionally, in order to obtain more effective target generalization features, thereby facilitating improvement in the accuracy and generalization of the target detection model, the sample features of the second sealing nail sample image are processed based on the LCCS statistic and the scaling parameter corresponding to the source domain to obtain the target generalization features, including:

[0030] Based on the LCCS statistic and the scaling parameter corresponding to the source domain, the sample features of the second sealing nail sample image are processed by the second calculation formula to obtain the target generalization features;

[0031] The second calculation formula is:

[0032] Among them, Z BN is the target generalization feature, Z is the sample feature of the second sealing nail sample image, γs and βs are the scaling parameters corresponding to the source domain, μ LCCS , σ LCCS is the LCCS statistic.

[0033] According to some embodiments of the present application, optionally, the method further includes: in the m training epochs of training the source model based on the support set, in the second number of iterations of the current training epoch, restoring the parameter values ​​of some elements of the current training model in the second number of iterations to the corresponding original parameter values ​​in the source model through the target mask tensor.

[0034] In an embodiment of the present application, in order to effectively avoid the trained network model from deviating excessively from the initial source model during the model training process, it is proposed to randomly restore some tensor elements in the trainable weights to the initial weights, thereby effectively reducing the occurrence of catastrophic forgetting of the source domain in the final trained target detection model.

[0035] According to some embodiments of the present application, optionally, considering that while avoiding the catastrophic forgetting of the source domain in the target detection model, it is also necessary to ensure the domain generalization effect brought about by the target domain training, the target mask tensor is a mask tensor recovered with a small probability determined by the Bernoulli distribution; and, this embodiment takes into account the actual model element distribution, in order to more accurately realize the random weight recovery of the elements in the above model, the target mask tensor has the same shape as the element distribution in the current training model at the second number of iterations.

[0036] According to some embodiments of the present application, more specifically, the training of the source model based on the target generalization feature to obtain the target detection model includes: training the source model based on the target generalization feature and the second defect detection label to obtain the target detection model.

[0037] According to some embodiments of the present application, optionally, after the source model is trained based on the target generalization features to obtain the target detection model, the method further includes: inputting the sealing nail image to be detected in the target domain into the target detection model to obtain a defect detection result corresponding to the sealing nail image to be detected.

[0038] According to some embodiments of the present application, optionally, the first span vector is source domain BN statistics corresponding to the source domain.

[0039] In the second aspect, the present application provides a sealing nail welding defect detection method, which includes: obtaining an image of a sealing nail to be detected; inputting the image of the sealing nail to be detected into a sealing nail welding defect detection model, and detecting the image of the sealing nail to be detected through the sealing nail welding defect detection model to obtain a sealing nail welding defect detection result; the sealing nail welding defect detection model is trained based on the sealing nail welding defect detection model training method described in any embodiment of the first aspect.

[0040] In the third aspect, the present application provides a sealing nail welding defect detection model training device, which includes: a first acquisition module, used to obtain a source model trained by a source domain data set in a source domain; the source domain data set includes multiple first sealing nail sample images and their corresponding first defect detection labels; a second acquisition module, used to obtain a first span vector of the source domain and a second span vector corresponding to a support set in the target domain; the first span vector is determined based on the source model; the support set includes multiple second sealing nail sample images and their corresponding second defect detection labels; the first span vector is used to characterize the statistical feature distribution of the source domain, and the second span vector is used to characterize the feature statistical distribution of the target domain; a first processing module, used to process the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain corresponding target generalization features; a first training module, used to train the source model based on the target generalization features to obtain a target detection model, and the target detection model is used to detect sealing nail welding defects.

[0041] In a fourth aspect, the present application provides an electronic device comprising: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the steps of the sealing pin welding defect detection model training method as described in any embodiment of the first aspect are implemented.

[0042] In a fifth aspect, the present application provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the steps of the sealing pin welding defect detection model training method as described in any one of the embodiments of the first aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The features, advantages and technical effects of exemplary embodiments of the present application will be described below with reference to the accompanying drawings.

[0044] FIG1 is a flow chart of a method for training a sealing pin welding defect detection model according to an embodiment of the present application;

[0045] FIG2 is a schematic diagram of a sealing nail sample image provided by the present application;

[0046] FIG3 is a schematic flow chart of a scenario embodiment of a method for detecting welding defects of sealing pins provided in an embodiment of the present application;

[0047] FIG4 is a flow chart of a sealing pin welding defect detection method provided in an embodiment of the present application;

[0048] FIG5 is a structural diagram of a sealing nail welding defect detection model training device provided in an embodiment of the present application;

[0049] FIG6 is a schematic structural diagram of a sealing nail welding defect detection model training device provided in an embodiment of the present application;

[0050] In the accompanying drawings, the drawings are not necessarily drawn to scale. DETAILED DESCRIPTION

[0051] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0052] The following embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application and are therefore only examples and are not intended to limit the scope of protection of the present application.

[0053] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the embodiments of the present application should have the common meanings understood by technicians in the field to which the embodiments of the present application belong.

[0054] In the description of the embodiments of this application, the technical terms "first," "second," etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise specifically defined.

[0055] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, technical terms such as "installed," "connected," "connected," and "fixed" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integration; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; and internal connections between two components or interactions between two components. Those skilled in the art can understand the specific meanings of the above terms in the embodiments of the present application based on specific circumstances.

[0056] In the description of the embodiments of the present application, unless otherwise expressly specified or limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediate medium. Furthermore, a first feature being "above," "above," and "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is at a higher level than the second feature. A first feature being "below," "below," and "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is at a lower level than the second feature.

[0057] At present, the relevant technology uses the original sealing nail welding image sample set in the source domain to train a defect detection model for detecting sealing nail welding defects. When faced with sealing nail welding images of new welding types in the target domain that have not been seen during the initial training of the model, the defect detection model has poor generalization, resulting in low detection accuracy.

[0058] Specifically, due to the direct domain offset between source domain training data and target domain test data, defect detection models pre-trained on source domain data often perform poorly on target domain data. This means that the pre-trained source domain model cannot generalize to new data in the target domain, seriously impacting product quality and safety. In this case, it is often necessary to retrain the defect detection model trained in the source domain using sample data from the target domain to improve the accuracy of the defect detection model ultimately used for actual sealing nail defect detection.

[0059] However, in real-world industrial scenarios, labeled samples in the target domain are often scarce. Obtaining a large amount of labeled data in the target domain is time-consuming and labor-intensive, and the labeling cost is high. Therefore, how to use this small amount of labeled data to fine-tune pre-trained models is a challenging problem.

[0060] In order to solve the above technical problems, the embodiments of the present application provide a sealing nail welding defect detection model training method, a detection method and related devices. Among them, the sealing nail welding defect detection model training method provided by the embodiments of the present application, by obtaining a source model obtained by training a source domain data set, and obtaining a first span vector obtained based on the source model and a second span vector corresponding to the support set in the target domain, to process the sample features of the second sealing nail sample image in the target domain support set according to the first span vector corresponding to the source domain and the second span vector corresponding to the target domain, to obtain the corresponding target generalization feature, which simultaneously integrates the feature styles of the source domain and the target domain. In this way, by using this target generalization feature to continue training the source model in the target domain, a target detection model that can be effectively generalized in the target domain is finally obtained, thereby effectively improving the accuracy of the target detection model in detecting sealing nail defects.

[0061] The following is a detailed introduction to the sealing pin welding defect detection model training method provided in an embodiment of the present application. The sealing pin welding defect detection model training method can be applied to the application scenario of detecting sealing pin welding defects. The sealing pin welding defect detection model training method can be executed by an electronic device with computing capabilities. The electronic device can include terminal devices such as mobile phones and computers, and can also include devices such as servers.

[0062] FIG1 is a flow chart of a method for training a sealing pin welding defect detection model according to an embodiment of the present application. As shown in FIG1 , the method for training a sealing pin welding defect detection model may include the following steps:

[0063] S110, obtaining a source model trained by a source domain dataset in a source domain; the source domain dataset includes a plurality of first sealing nail sample images and their corresponding first defect detection labels;

[0064] S120, obtaining a first span vector in the source domain and a second span vector corresponding to a support set in the target domain; the first span vector is determined based on the source model; the support set includes a plurality of second sealing nail sample images and their corresponding second defect detection labels; the first span vector is used to represent the statistical feature distribution of the source domain, and the second span vector is used to represent the feature statistical distribution of the target domain;

[0065] S130, processing the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain corresponding target generalization features;

[0066] S140, training the source model based on the target generalization feature to obtain a target detection model, which is used to detect sealing pin welding defects.

[0067] Thus, by obtaining a source model trained on a source domain dataset, and obtaining a first span vector obtained based on the source model and a second span vector corresponding to the support set in the target domain, the sample features of the second sealing nail sample image in the target domain support set are stylized according to the first span vector corresponding to the source domain and the second span vector corresponding to the target domain, thereby obtaining a corresponding target generalization feature. This target generalization feature includes the characteristic styles of both the source domain and the target domain. In this way, by using this stylized target generalization feature to continue training the source model in the target domain, a target detection model that can be effectively generalized in the target domain is finally obtained, thereby effectively improving the accuracy of this target detection model in detecting sealing nail defects.

[0068] Compared to the prior art, the embodiment of the present application utilizes the first span vector corresponding to the source domain and the second span vector of the target domain to stylize the support set sample features, and uses this processed target generalization feature to train the source model. This improves the generalization and accuracy of the trained sealing nail defect detection model, effectively reducing the occurrence of model collapse in the target domain. In addition, this embodiment can quickly continue to train the source model using a small number of labeled target domain sealing nail sample images, reducing the cost of manual expert annotation, while also significantly improving the accuracy of sealing nail defect detection and reducing the miss rate.

[0069] The specific implementation of the above steps 110 to 140 is described in detail below.

[0070] In S110 , in a specific implementation, a source model trained by a source domain dataset in a source domain is obtained; the source domain dataset includes a plurality of first sealing nail sample images and their corresponding first defect detection labels.

[0071] The source domain may include different first sealing nail sample images, and each first sealing nail sample image has a corresponding first defect detection label.

[0072] The first sealing pin sample image may be a sealing pin welding image, such as that shown in FIG2 . FIG2 shows the sealing pin welding image, respectively, of the sealing pin weld bead 10, two lugs 20, and a tail point 30. The sealing pin welding locations and defect detection locations may typically be the weld bead 10, lugs 20, etc.

[0073] The first defect detection label can be used to characterize the detected welding defects of the sealing nails, such as welding slag defects or non-welding slag defects, etc. Welding slag defects include cracks, burn-through, welding structure deformation, etc., and non-welding slag defects include melted nails, no nails, no welding, etc. This embodiment does not impose strict restrictions here.

[0074] In S120, during the specific implementation, a first span vector of the source domain and a second span vector corresponding to the support set in the target domain are obtained; the first span vector is determined based on the source model; the support set includes a plurality of second sealing nail sample images and their corresponding second defect detection labels; the first span vector is used to characterize the statistical feature distribution of the source domain, and the second span vector is used to characterize the feature statistical distribution of the target domain.

[0075] A spanning vector is a set of vectors in a vector space that can be linearly combined to generate any vector in that vector space. In this embodiment of the present application, a first spanning vector corresponding to the source domain and a second spanning vector corresponding to the target domain support set are obtained to subsequently generalize the source model in the target domain.

[0076] In a specific implementation, the source model trained based on the source domain dataset often contains a large number of parameters, including source domain BN statistics corresponding to the source domain. These source domain BN statistics can be used to characterize the distribution of statistical features in the source domain. In this case, these source domain BN statistics can be used as the first span vector of the source domain, which can be used to characterize the distribution of statistical features in the source domain.

[0077] The second span vector can be used to characterize the characteristic statistical distribution of the target domain. The specific method for determining the second span vector will be described in detail later. In some embodiments, the support set BN statistics corresponding to the support set can be determined directly based on the second sealing nail sample image in the support set, and this can be regarded as the characteristic statistical distribution of the target domain. In other words, it is also feasible to determine the support set BN statistics as the second span vector.

[0078] In S130 , in a specific implementation, the sample features of the second sealing nail sample image are processed based on the first span vector and the second span vector to obtain corresponding target generalization features.

[0079] For example, after obtaining the first span vector of the source domain and the second span vector corresponding to the target domain support set, the sample features of the second sealing nail sample image can be processed by linearly combining the first and second span vectors, etc., in combination with corresponding model parameter calculation methods to obtain the corresponding target generalization feature. This target generalization feature includes the characteristic styles of both the source domain and the target domain.

[0080] In S140 , during specific implementation, the source model is trained based on the target generalization feature to obtain a target detection model, which is used to detect sealing pin welding defects.

[0081] In this way, since the above-mentioned target generalization features include the feature styles of both the source domain and the target domain, by using the target generalization features obtained by this feature stylization to continue training the source model in the target domain, we can eventually obtain a target detection model that can be effectively generalized in the target domain, thereby effectively improving the accuracy of this target detection model in detecting sealing nail defects.

[0082] Overall, the embodiment of the present application stylizes the support set sample features by utilizing the first span vector corresponding to the source domain and the second span vector of the target domain, and trains the source model with the processed target generalization features, thereby improving the generalization and accuracy of the trained sealing nail defect detection model and effectively reducing the occurrence of model collapse after training with target domain samples.

[0083] In addition, even when the target domain contains only a small number of labeled samples (usually labels of defect detection results), this embodiment can quickly continue to train the source model with a small number of labeled target domain sealing nail sample images. This can effectively reduce the cost of manual expert labeling, and is conducive to significantly improving the accuracy of sealing nail defect detection and reducing the missed kill rate in actual detection scenarios.

[0084] According to some embodiments of the present application, more specifically, the training of the source model based on the target generalization feature to obtain the target detection model may include:

[0085] The source model is trained based on the target generalization features and the second defect detection label to obtain the target detection model.

[0086] It should be understood that, in this embodiment, considering the diversity and complexity of current model training methods, there are no excessive restrictions or detailed descriptions on how to train the source model based on the above-mentioned target generalization features and their corresponding second defect detection labels.

[0087] According to some embodiments of the present application, optionally, processing the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain the corresponding target generalization features may include:

[0088] Determining an LCCS statistic of the BN statistics based on the first span vector and the second span vector;

[0089] The sample features of the second sealing nail sample image are processed based on the LCCS statistic to obtain the target generalization features.

[0090] According to some embodiments of the present application, more specifically, processing the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization features may include:

[0091] Based on the LCCS statistic and the scaling parameter corresponding to the source domain, the sample features of the second sealing nail sample image are processed to obtain the target generalization features;

[0092] The scaling parameters corresponding to the source domain are determined based on the source model.

[0093] In the technical solution of the embodiment of the present application, when the sample features of the second sealing nail sample image are processed based on the first span vector corresponding to the source domain and the second span vector of the target domain support set to obtain the above-mentioned target generalization features, the LCCS statistic (the learnable Linear Combination Coefficients for batch normalization Statistics) is first calculated based on the first span vector and the second span vector, and then the sample features of the second sealing nail sample image are specifically processed based on the LCCS statistic and the scaling parameters corresponding to the source domain, so that the above-mentioned target generalization features can be determined more reasonably.

[0094] Considering the actual model parameters, in a specific example, the target generalization feature can be determined based on the second calculation formula. The second calculation formula is shown in the following formula (1):

[0095] Among them, Z BN is the target generalization feature, Z is the sample feature of the second sealing nail sample image, γs and βs are the scaling parameters corresponding to the source domain, μ LCCS , σ LCCS is the LCCS statistic mentioned above.

[0096] According to some embodiments of the present application, optionally, before obtaining the first span vector based on the source domain and the second span vector corresponding to the support set in the target domain, the sealing pin welding defect detection model training method may further include:

[0097] Determine a first number of feature representations corresponding one-to-one to a first number of second sealing nail sample images in the support set;

[0098] Determining a first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set;

[0099] A second span vector is determined based on the first number of cross-domain feature vectors.

[0100] In specific implementation, for example, a first number of second sealing nail sample images can be randomly extracted from the target domain support sample, and they can be passed to the source model to obtain their respective corresponding feature representations, that is, the first number of feature representations corresponding one-to-one to the first number of second sealing nail sample images.

[0101] After obtaining the first number of feature representations, the first number of cross-domain feature vectors are determined based on the first number of feature representations and the support set BN (batch normalization) statistics corresponding to the support set. In this way, based on the first number of cross-domain feature vectors, the second span vector can be determined more reasonably and accurately. For example, the second span vector can be determined by performing a corresponding linear combination of the first number of cross-domain feature vectors.

[0102] According to some embodiments of the present application, optionally, the second span vector may include a first vector matrix and a second vector matrix;

[0103] The first vector matrix may include means of a first number of cross-domain eigenvectors, and the second vector matrix may include variances of the first number of cross-domain eigenvectors.

[0104] In this embodiment, taking into account the actual training scenario, the specific data in the above-mentioned second span vector is reasonably limited: the second span vector includes a first vector matrix containing the mean of a first number of cross-domain feature vectors, and a second vector matrix containing the variance of the first number of cross-domain feature vectors.

[0105] In this way, by reasonably setting the combination method of the first number of cross-domain feature vectors in the above-mentioned second span vector, it is beneficial to subsequently more effectively realize the feature generalization processing of the sample features of the second sealing nail sample image in the target domain support set based on this second span vector.

[0106] According to some embodiments of the present application, optionally, determining the first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set may include:

[0107] Based on the first number of feature representations and support set BN statistics, a first number of cross-domain feature vectors are obtained through aggregation or dimensionality reduction processing.

[0108] In an embodiment of the present application, when determining the first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistical data, the above-mentioned first number of feature representations and support set BN statistical data are processed by using aggregation or dimensionality reduction (such as singular value decomposition SVD) means, and finally a simpler first number of cross-domain feature vectors can be obtained, which is conducive to subsequent reduction of computational burden and achieves the purpose of improving the training efficiency of the target detection model.

[0109] According to some embodiments of the present application, optionally, before determining the first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set, the sealing nail welding defect detection model training method may further include:

[0110] The support set is processed by exponential moving average method to obtain the support set BN statistics.

[0111] Thus, before determining the first number of cross-domain feature vectors based on the first number of feature representations and the support set BN statistics corresponding to the support set, data processing is performed on the support set in the target domain using an exponential moving average (EMA) method, so that the support set BN statistics can be obtained more reasonably. Moreover, the exponential moving average method uses an exponentially decreasing weighted moving average to enable the obtained support set BN statistics to smoothly update one or more training epochs of model training.

[0112] According to some embodiments of the present application, optionally, before determining the LCCS statistic of the BN statistical data based on the first span vector and the second span vector, the sealing pin welding defect detection model training method may further include:

[0113] Based on the principle of minimizing the cross entropy loss of the support set, multiple candidate values ​​of the BN parameter in the LCCS statistic are bound to the batch normalization layer in the source model, and grid search is used to determine the initialization value of the BN parameter from multiple candidate values;

[0114] Determining an LCCS statistic of the BN statistics based on the first span vector and the second span vector may include:

[0115] An LCCS statistic is determined based on the first span vector, the second span vector, and initialization values ​​of the BN parameters.

[0116] In an embodiment of the present application, in order to fully meet the needs of model adaptive training and to more reasonably determine the above-mentioned LCCS statistic, we can first bind multiple candidate values ​​of the BN parameter in the LCCS statistic to the batch normalization layer (BN layer) in the source model based on the principle of minimizing the cross-entropy loss of the support set, and use grid search (for example, one-dimensional grid search) to determine the initialization value of the BN parameter from the multiple candidate values.

[0117] In this way, after determining the initialization value of the BN parameter, a more accurate LCCS statistic can be determined based on the first span vector, the second span vector and the initialization value of the BN parameter, so that the sample features of the second sealing nail sample image can be processed according to the LCCS statistic to obtain more effective target generalization features, which is conducive to improving the accuracy and generalization of the target detection model.

[0118] More specifically, in an example of the present application, the LCCS statistic can be determined based on a first calculation formula. The first calculation formula is shown in the following formula (2):

[0119] Among them, μ LCCS , σ LCCS is the above LCCS statistic, μ s , σ s is the first span vector (source domain BN statistics), η s , ρ s ,η spt , ρ spt is the initialization value of the above BN parameters, M spt ,Σ spt is the second span vector mentioned above.

[0120] According to some embodiments of the present application, optionally, the processing of the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization features may include:

[0121] In the process of training the source model based on the support set, the LCCS statistics in the current iteration are updated by the stochastic gradient descent method to obtain the LCCS statistics in the next iteration;

[0122] The sample features of the second sealing nail sample image are processed based on the LCCS statistics in the next iteration process to obtain the target generalization features.

[0123] In an embodiment of the present application, in order to fully guarantee the detection accuracy and generalization of the target detection model finally obtained by training, it is proposed that in the process of training the source model based on the support set, the model LCCS parameters can be optimized and updated by adopting the stochastic gradient descent (SGD) method, so as to obtain target generalization features with better generalization effect.

[0124] Specifically, in the process of training the source model based on the support set, the LCCS statistics in the current iteration are updated by the stochastic gradient descent method to achieve gradual parameter optimization and obtain the LCCS statistics in the next iteration. In this way, the sample features of the second sealing nail sample image are processed based on the LCCS statistics in the next iteration after the stochastic gradient update to obtain the target generalization features, which is more conducive to ensuring the validity of the model parameters and the accuracy of the target detection model. According to some embodiments of the present application, optionally, the sealing nail welding defect detection model training method may also include:

[0125] In multiple training epochs of training the source model based on the support set, in the second iteration of the current training epoch, the parameter values ​​of some elements of the current training model in the second iteration are restored to the corresponding original parameter values ​​in the source model through the target mask tensor.

[0126] In an embodiment of the present application, in order to effectively avoid the trained network model from deviating excessively from the initial source model during the model training process, it is proposed to randomly restore some tensor elements in the trainable weights to the initial weights, thereby effectively reducing the occurrence of catastrophic forgetting of the source domain in the final trained target detection model.

[0127] In the embodiments of the present application, a training period is an epoch. An iteration is an iteration. An iteration is equal to training once with batchsize samples. An epoch is equal to training once with all samples in the training set.

[0128] In actual implementation, in order to effectively prevent the trained network model from deviating excessively from the initial source model during model training, a sampling random weight recovery method is proposed to restore the weights of some tensors in the model. Specifically, the parameter values ​​of some elements of the current training model in the second iteration are restored to the corresponding original parameter values ​​in the source model through the target mask tensor, thereby randomly restoring some tensor elements in the trainable weights in the current training model to the initial weights, thereby effectively reducing the occurrence of catastrophic forgetting of the source domain in the final trained object detection model.

[0129] According to some embodiments of the present application, optionally, the target mask tensor is a mask tensor recovered with a small probability determined by using a Bernoulli distribution;

[0130] The target mask tensor has the same shape as the element distribution in the current trained model at the second iteration.

[0131] In the specific implementation, considering that the target detection model should avoid catastrophic forgetting of the source domain while ensuring the domain generalization effect brought by target domain training, the target mask tensor is a mask tensor with a small probability of recovery determined by the Bernoulli distribution.

[0132] Furthermore, this embodiment takes into account the actual model element distribution. In order to more accurately restore the random weights of the elements in the above model, the target mask tensor has the same shape as the element distribution in the current training model at the second number of iterations.

[0133] For example, the random weight recovery method proposed in the embodiment of the present application updates the weight W by the following formula (3):

[0134] M~Bernoulli(p),

[0135] W t+1 =M⊙W0+(1-M)⊙W t+1 , formula (3)

[0136] Where ⊙ represents element-by-element multiplication. p is a small recovery probability, and M is a mask tensor with the same shape as Wt+1, i.e., the target mask tensor described above. This target mask tensor M determines which elements in Wt+1 are restored back to the source weights W0. Specifically, it determines which elements of the currently trained model in the second iteration need to be restored to their original parameter values ​​in the source model.

[0137] In this way, by randomly restoring a small number of tensor elements in the trainable weights to the initial weights, the network avoids excessive deviation from the initial source model, thereby effectively avoiding catastrophic forgetting of the source model by the trained object detection model.

[0138] According to some embodiments of the present application, optionally, after training the source model based on the target generalization feature to obtain the target detection model, the sealing pin welding defect detection model training method may further include:

[0139] The image of the sealing nail to be detected in the target domain is input into the target detection model to obtain the defect detection result corresponding to the image of the sealing nail to be detected.

[0140] In this embodiment, considering the actual sealing nail testing scenario, the target domain often includes many unlabeled sealing nail images to be tested in addition to the support set. Based on this, after the target detection model is trained based on the target generalization features, the sealing nail images to be tested in the target domain are input into the target detection model. This target detection model is then put into use for defect testing and detection, thereby obtaining defect detection results corresponding to the sealing nail images to be tested.

[0141] Since the generalization of this target detection model in the target domain has been greatly enhanced after training with target generalization features, the precision and accuracy of the defect detection results of the sealing nail images to be inspected will be greatly improved.

[0142] To facilitate understanding of the sealing nail welding defect detection model training method provided in the above embodiment, the above method is described below using a specific scenario embodiment. Figure 3 is a flow chart of a scenario embodiment of the sealing nail welding defect detection model training method provided in the embodiment of the present application.

[0143] In this scenario embodiment: the adaptive goal of the overall model training is to fine-tune the LCCS statistic to minimize the cross entropy loss on the support set L(η,ρ) = -∑(x,y)∈Lspt y log h(x;η,ρ), where x and y are the input and one-hot encoded categories of the support set samples Lspt, respectively, and h is the source model with learnable BN parameters {η,ρ}.

[0144] As shown in FIG3 , this scenario embodiment may mainly include the following stages during specific implementation: a source model training stage, an initialization stage, and a gradient update stage.

[0145] Source model training phase: execute steps 310 and 311 .

[0146] Step 310: pre-train a source model in the source domain using a source domain dataset.

[0147] Step 311 : Based on the source model, a first span vector corresponding to the source domain and a scaling parameter corresponding to the source domain are calculated.

[0148] Specifically, in this source model training phase, a model is pre-trained on a given source domain based on a source domain dataset to obtain a source model. The source domain dataset may specifically include a plurality of first sealing nail sample images and their corresponding first defect detections.

[0149] After obtaining the source model, the source domain span vector μ can be determined accordingly based on the source model. s , σ s , and the scaling parameters γs and βs corresponding to the source domain. We directly use this source domain span vector as the first span vector for subsequent feature stylization / generalization processing.

[0150] Initialization phase: execute step 320 and step 330.

[0151] Step 320 : Process the support set data by exponential moving average to obtain support set BN statistics.

[0152] In step 330, based on the principle of minimizing the cross entropy loss of the support set, multiple candidate values ​​of the BN parameters in the LCCS statistic are respectively bound to the batch normalization layer in the source model, and a grid search is used to determine the initialization value of the BN parameter from the multiple candidate values.

[0153] Specifically, during this initialization phase, the support set BN statistics μspt and σspt are first calculated by exponential moving average (EMA) so that μspt and σspt are smoothly updated for m training epochs.

[0154] Then, we set the BN parameters ηspt = ρspt = [v0···0]T, where v∈{0,0.1,...,1.0} and ηs = ρs = 1-v, and bind these candidate values ​​on all BN layers, and perform a one-dimensional grid search to determine the initialization values ​​of the above BN parameters. We select the initialization values ​​of the BN parameters that minimize the cross entropy loss on the support samples (also called the initialization values ​​of the LCCS parameters).

[0155] Gradient update phase: execute steps 340 to 370.

[0156] Step 340: Calculate and obtain a second span vector corresponding to the support set based on the support set BN statistics.

[0157] Step 350 , during the training of the source model based on the support set, random weights are restored, and the LCCS statistic is optimized by stochastic gradient descent on the support set through stochastic gradient descent.

[0158] Step 360 : Obtain target generalization features based on the fine-tuned LCCS statistics and the stylized features of the scaling parameters corresponding to the source domain.

[0159] Step 370 : Training the source model based on the target generalization features to obtain a target detection model for detecting sealing pin welding defects.

[0160] Specifically, during the gradient update phase, the second span vectors Mspt and Σspt corresponding to the support set are calculated using the relevant parameters determined during the initialization phase (e.g., support set BN statistics μspt and σspt). The initial LCCS statistic is calculated based on this second span vector, the first span vector corresponding to the source domain, and the initialization values ​​of the aforementioned BN parameters. Subsequently, during the training of the source model based on the support set, the LCCS statistic is further optimized and adjusted over multiple training epochs using stochastic gradient descent. Furthermore, a sampled random weight recovery method is proposed to restore the initial weights of some tensors in the current training model to avoid catastrophic forgetting of the model.

[0161] In this way, the sample features of the sealing nail sample images in the support set are processed based on the fine-tuned LCCS statistics and the corresponding scaling parameters of the source domain to obtain the target generalization features. In this way, the source model is trained based on the target generalization features to obtain the target detection model for detecting sealing nail welding defects.

[0162] Furthermore, during this gradient update phase, parameter values ​​can be set to be unbound across BN layers, and the constraint that the coefficients sum to 1 is not imposed is not added to allow for more diverse combinations. To ensure effective training, when the source model continues to be trained in the target domain, the support set samples used for training can use the same data augmentation processing as the source model training. Furthermore, based on actual needs, the pre-trained source classifier is retained and updated when there are sufficient support samples to represent the target domain and learn a new target classifier.

[0163] In this scenario, by assuming that the statistics of the source and target domain support sets are correlated, and due to the correlation between shared categories and domains, it is proposed to combine the source domain span vector and the target domain span vector in the linear space of available statistics to stylize the target domain support set sample features, thereby obtaining the aforementioned target generalization features, thereby effectively improving the generalization ability and defect detection accuracy of the trained object detection model in the target domain. At the same time, this embodiment introduces random weight recovery, which allows the model to randomly restore a small number of tensor elements in the trainable weights to the initial weights. This prevents the network from deviating excessively from the original source model, thereby avoiding catastrophic forgetting.

[0164] It should be noted that the application scenarios described in the above-mentioned embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Ordinary technicians in this field can know that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0165] Based on the sealing nail welding defect detection model training method provided in the above embodiment, for the same inventive concept, the present application also provides a sealing nail welding defect detection method corresponding to the above sealing nail welding defect detection model training method.

[0166] The following is a detailed introduction to the sealing pin welding defect detection method provided in the embodiment of the present application. The sealing pin welding defect detection method can be applied to the application scenario of detecting sealing pin welding defects. The target detection model is used to detect sealing pin welding defects.

[0167] FIG4 is a flow chart of a method for detecting welding defects of sealing pins provided by an embodiment of the present application. As shown in FIG4 , the method for detecting welding defects of sealing pins may specifically include the following steps:

[0168] S410, acquiring an image of the sealing nail to be inspected;

[0169] S420, inputting the image of the sealing nail to be detected into the sealing nail welding defect detection model, detecting the image of the sealing nail to be detected by the sealing nail welding defect detection model, and obtaining a sealing nail welding defect detection result.

[0170] Among them, the above-mentioned sealing nail welding defect detection model is trained based on the sealing nail welding defect detection model training method described in any of the aforementioned embodiments.

[0171] Therefore, by obtaining the target detection model obtained by training the sealing nail welding defect detection model training method provided by any of the aforementioned embodiments, and performing model inference on the sealing nail image to be detected in the target domain based on this target detection model, a more accurate defect detection result corresponding to the sealing nail image to be detected can be obtained, thereby greatly improving the accuracy of sealing nail defect detection and significantly reducing the missed kill rate.

[0172] Based on the sealing nail welding defect detection model training method provided in the above embodiment, for the same inventive concept, the present application also provides a sealing nail welding defect detection model training device corresponding to the above sealing nail welding defect detection model training method. The sealing nail welding defect detection model training device is introduced in detail below through Figure 5.

[0173] FIG5 shows a schematic diagram of the structure of a sealing pin welding defect detection model training device provided in an embodiment of the present application. The sealing pin welding defect detection model training device 500 shown in FIG5 includes:

[0174] A first acquisition module 501 is configured to acquire a source model trained by a source domain dataset in a source domain; the source domain dataset includes a plurality of first sealing nail sample images and their corresponding first defect detection labels;

[0175] A second acquisition module 504 is configured to acquire a first span vector in the source domain and a second span vector corresponding to a support set in the target domain; the first span vector is determined based on the source model; the support set includes a plurality of second sealing nail sample images and their corresponding second defect detection labels; the first span vector is used to represent the statistical feature distribution of the source domain, and the second span vector is used to represent the feature statistical distribution of the target domain;

[0176] A first processing module 503 is configured to process the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain corresponding target generalization features;

[0177] The first training module 504 is used to train the source model based on the target generalization feature to obtain a target detection model, and the target detection model is used to detect sealing pin welding defects.

[0178] The embodiment of the present application provides a sealing nail welding defect detection model training device, which obtains the source model obtained by training the source domain data set by setting the corresponding functional modules, and obtains the first span vector obtained based on the source model and the second span vector corresponding to the support set in the target domain, and performs stylized processing on the sample features of the second sealing nail sample image in the target domain support set according to the first span vector corresponding to the source domain and the second span vector corresponding to the target domain, and obtains the corresponding target generalization feature, which includes the feature style of both the source domain and the target domain. In this way, by using this stylized target generalization feature to continue training the source model in the target domain, a target detection model that can be effectively generalized in the target domain is finally obtained, which can effectively improve the accuracy of the target detection model in sealing nail defect detection.

[0179] Compared to the prior art, a defect detection model in an embodiment of the present application utilizes a first span vector corresponding to the source domain and a second span vector corresponding to the target domain to stylize the support set sample features, and uses this processed target generalization feature to train the source model. This improves the generalization and accuracy of the trained sealing nail defect detection model, effectively reducing the occurrence of model collapse in the target domain. In addition, this embodiment can quickly continue to train the source model using a small number of labeled target domain sealing nail sample images, reducing the cost of manual expert annotation, and at the same time significantly improving the accuracy of sealing nail defect detection and reducing the miss rate.

[0180] The following is a detailed description of the sealing nail welding defect detection model training device 500, as shown below:

[0181] According to some embodiments of the present application, optionally, the first processing module 503 processes the sample features of the second sealing staple sample image based on the first span vector and the second span vector to obtain the corresponding target generalization features, which may include:

[0182] A first determining submodule may be configured to determine an LCCS statistic of the BN statistical data based on the first span vector and the second span vector;

[0183] The first obtaining submodule can be used to process the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization features.

[0184] According to some embodiments of the present application, optionally, before obtaining the first span vector based on the source domain and the second span vector corresponding to the support set in the target domain, the sealing nail welding defect detection model training device may further include:

[0185] The first determining module may be configured to determine a first number of feature representations corresponding one-to-one to a first number of second sealing nail sample images in a support set;

[0186] The second determining module may be configured to determine a first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set;

[0187] The third determination module may be configured to determine a second span vector based on the first number of cross-domain feature vectors.

[0188] According to some embodiments of the present application, optionally, the second span vector may include a first vector matrix and a second vector matrix;

[0189] The first vector matrix may include means of a first number of cross-domain eigenvectors, and the second vector matrix may include variances of the first number of cross-domain eigenvectors.

[0190] According to some embodiments of the present application, optionally, the second determining module determining the first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set may include:

[0191] Based on the first number of feature representations and support set BN statistics, a first number of cross-domain feature vectors are obtained through aggregation or dimensionality reduction processing.

[0192] According to some embodiments of the present application, optionally, before determining the first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set, the sealing nail welding defect detection model training device may further include:

[0193] The second processing module can be used to process the support set data through an exponential moving average device to obtain support set BN statistical data.

[0194] According to some embodiments of the present application, optionally, before determining the LCCS statistic of the BN statistical data based on the first span vector and the second span vector, the sealing pin welding defect detection model training device may further include:

[0195] The fourth determination module can be used to bind multiple candidate values ​​of the BN parameter in the LCCS statistic to the batch normalization layer in the source model based on the cross entropy loss minimization principle of the support set, and use grid search to determine the initialization value of the BN parameter from the multiple candidate values;

[0196] The determining of the LCCS statistic of the BN statistical data based on the first span vector and the second span vector may include:

[0197] An LCCS statistic is determined based on the first span vector, the second span vector, and initialization values ​​of the BN parameters.

[0198] According to some embodiments of the present application, optionally, the first obtaining submodule processes the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization feature, which may include:

[0199] The first obtaining unit can be used to update the LCCS statistic in the current iteration process by the stochastic gradient descent method during the training of the source model based on the support set, so as to obtain the LCCS statistic in the next iteration process;

[0200] The second obtaining unit can be used to process the sample features of the second sealing nail sample image based on the LCCS statistics in the next iterative process to obtain the target generalization features.

[0201] According to some embodiments of the present application, optionally, the first obtaining submodule processes the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization feature, which may include:

[0202] Based on the LCCS statistic and the scaling parameter corresponding to the source domain, the sample features of the second sealing nail sample image are processed to obtain the target generalization features;

[0203] The scaling parameters corresponding to the source domain are determined based on the source model.

[0204] According to some embodiments of the present application, optionally, the sealing nail welding defect detection model training device may further include:

[0205] The first recovery module can be used to restore the parameter values ​​of some elements of the current training model in the second number of iterations to the corresponding original parameter values ​​in the source model through the target mask tensor during the m training periods of training the source model based on the support set.

[0206] According to some embodiments of the present application, optionally, the target mask tensor is a mask tensor recovered with a small probability determined by using a Bernoulli distribution;

[0207] The target mask tensor has the same shape as the element distribution in the current trained model at the second iteration.

[0208] According to some embodiments of the present application, optionally, the first training module 504 trains the source model based on the target generalization feature to obtain the target detection model, which may include:

[0209] The source model is trained based on the target generalization features and the second defect detection label to obtain the target detection model.

[0210] According to some embodiments of the present application, optionally, after training the source model based on the target generalization feature to obtain the target detection model, the sealing pin welding defect detection model training device may further include:

[0211] The defect detection module can be used to input the image of the sealing nail to be detected in the target domain into the target detection model to obtain the defect detection result corresponding to the image of the sealing nail to be detected.

[0212] FIG6 is a schematic structural diagram of a sealing pin welding defect detection model training device provided by an embodiment of the present application.

[0213] The electronic device 600 may include a processor 601 and a memory 602 storing computer program instructions.

[0214] Specifically, the processor 601 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0215] The memory 602 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 602 may include removable or non-removable (or fixed) media. Where appropriate, the memory 602 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 602 is a non-volatile solid-state memory.

[0216] In certain embodiments, the memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present application.

[0217] The processor 601 reads and executes computer program instructions stored in the memory 602 to implement any one of the sealing pin welding defect detection model training methods in the above embodiments.

[0218] In some examples, the electronic device 600 may further include a communication interface 603 and a bus 610. As shown in FIG6, the processor 601, the memory 602, and the communication interface 603 are connected via the bus 610 and communicate with each other.

[0219] The communication interface 603 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0220] Bus 610 includes hardware, software or both, and the components of online data flow metering equipment are coupled to each other. For example, but not limitation, bus 610 may include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 610 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.

[0221] Illustratively, the electronic device 600 may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA).

[0222] The electronic device 600 can execute the sealing pin welding defect detection model training method in the embodiment of the present application, thereby realizing the sealing pin welding defect detection model training method and device described in combination with the aforementioned embodiment.

[0223] In addition, in combination with the sealing pin welding defect detection model training method in the above embodiment, the embodiment of the present application may provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the sealing pin welding defect detection model training methods in the above embodiment is implemented. Examples of computer-readable storage media include non-transitory computer-readable storage media, such as portable disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, etc.

[0224] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.

[0225] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0226] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0227] Aspects of the present application have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed via the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. This processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or the flowchart and the combination of the boxes in the block diagram and / or the flowchart can also be implemented by the dedicated hardware that performs the specified function or action, or can be implemented by the combination of dedicated hardware and computer instructions.

[0228] The above description is only a specific embodiment of the present application. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the scope of protection of the present application.

Claims

1. A sealing nail welding defect detection model training method, comprising: Obtain a source model trained by a source domain dataset in a source domain; The source domain dataset includes a plurality of first sealing nail sample images and their corresponding first defect detection labels; Obtaining a first span vector of the source domain and a second span vector corresponding to a support set in a target domain; wherein the first span vector is determined based on the source model; and wherein the support set includes a plurality of second sealing nail sample images and their corresponding second defect detection labels; The first span vector is used to represent the statistical feature distribution of the source domain, and the second span vector is used to represent the feature statistical distribution of the target domain; processing the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain corresponding target generalization features; The source model is trained based on the target generalization features to obtain a target detection model, and the target detection model is used to detect sealing pin welding defects.

2. The method according to claim 1, wherein The processing of the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain corresponding target generalization features includes: Determining an LCCS statistic of BN statistics based on the first span vector and the second span vector; The sample features of the second sealing nail sample image are processed based on the LCCS statistic to obtain the target generalization feature.

3. The method according to claim 1 or 2, wherein: Before obtaining the first span vector based on the source domain and the second span vector corresponding to the support set in the target domain, the method further includes: Determine a first number of feature representations corresponding one-to-one to a first number of second sealing nail sample images in the support set; Determining a first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set; The second span vector is determined based on the first number of cross-domain feature vectors.

4. The method according to claim 3, wherein: The second span vector includes a first vector matrix and a second vector matrix; The first vector matrix includes means of the first number of cross-domain eigenvectors, and the second vector matrix includes variances of the first number of cross-domain eigenvectors.

5. The method according to claim 3, wherein: The determining a first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set includes: Based on the first number of feature representations and the support set BN statistics, the first number of cross-domain feature vectors are obtained through aggregation or dimensionality reduction processing.

6. The method according to claim 3, wherein: Before determining a first number of cross-domain feature vectors based on the first number of feature representations and support set BN statistics corresponding to the support set, the method further includes: The support set is processed by an exponential moving average method to obtain the support set BN statistics.

7. The method according to claim 2, wherein: Before determining the LCCS statistic of the BN statistical data based on the first span vector and the second span vector, the method further includes: Based on the cross entropy loss minimization principle of the support set, a plurality of candidate values of the BN parameter in the LCCS statistic are respectively bound to the batch normalization layer in the source model, and a grid search is used to determine the initialization value of the BN parameter from the plurality of candidate values; The determining, based on the first span vector and the second span vector, an LCCS statistic of BN statistical data includes: The LCCS statistic is determined based on the first span vector, the second span vector, and the initialization value of the BN parameter.

8. The method according to claim 7, wherein: The determining the LCCS statistic based on the first span vector, the second span vector, and the initialization value of the BN parameter includes: Determining the LCCS statistic by a first calculation formula based on the first span vector, the second span vector, and the initialization value of the BN parameter; The first calculation formula is: Among them, μ LCCS , σ LCCS is the LCCS statistic, μ s , σ s is the first span vector, η s , ρ s ,η spt , ρ spt is the initialization value of the BN parameter, M spt ,∑ spt is the second span vector.

9. The method according to claim 2, wherein: The processing of the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization feature includes: In the process of training the source model based on the support set, the LCCS statistic in the current iteration process is updated by a stochastic gradient descent method to obtain the LCCS statistic in the next iteration process; The sample features of the second sealing nail sample image are processed based on the LCCS statistics in the next iteration process to obtain the target generalization features.

10. The method according to claim 2, wherein: The processing of the sample features of the second sealing nail sample image based on the LCCS statistic to obtain the target generalization feature includes: processing the sample features of the second sealing nail sample image based on the LCCS statistic and the scaling parameter corresponding to the source domain to obtain the target generalization feature; The scaling parameters corresponding to the source domain are determined based on the source model.

11. The method according to claim 10, wherein: The processing of the sample features of the second sealing nail sample image based on the LCCS statistic and the scaling parameter corresponding to the source domain to obtain the target generalization feature includes: Based on the LCCS statistic and the scaling parameter corresponding to the source domain, processing the sample features of the second sealing nail sample image using a second calculation formula to obtain the target generalization feature; The second calculation formula is: Among them, Z BN is the target generalization feature, Z is the sample feature of the second sealing nail sample image, γs and βs are the scaling parameters corresponding to the source domain, μ LCCS , σ LCCS is the LCCS statistic.

12. The method according to claim 1, wherein The method further comprises: During multiple training epochs of training the source model based on the support set, in the second number of iterations of the current training epoch, the parameter values of some elements of the current training model in the second number of iterations are restored to the corresponding original parameter values in the source model through the target mask tensor.

13. The method according to claim 12, wherein: The target mask tensor is a mask tensor recovered with a small probability determined by using Bernoulli distribution; The target mask tensor has the same shape as the element distribution in the current training model at the second number of iterations.

14. The method according to claim 1, wherein The training of the source model based on the target generalization feature to obtain a target detection model includes: The source model is trained based on the target generalization feature and the second defect detection label to obtain the target detection model.

15. The method according to claim 1, wherein After training the source model based on the target generalization feature to obtain the target detection model, the method further includes: The image of the sealing nail to be detected in the target domain is input into the target detection model to obtain a defect detection result corresponding to the image of the sealing nail to be detected.

16. The method according to claim 1, wherein The first span vector is source domain BN statistical data corresponding to the source domain.

17. A method for detecting sealing pin welding defects, the method comprising: Acquire an image of the sealing nail to be detected; Inputting the image of the sealing nail to be detected into a sealing nail welding defect detection model, detecting the image of the sealing nail to be detected by the sealing nail welding defect detection model to obtain a sealing nail welding defect detection result; The sealing pin welding defect detection model is trained based on the sealing pin welding defect detection model training method according to any one of claims 1 to 13.

18. A sealing nail welding defect detection model training device, comprising: A first acquisition module is used to acquire a source model trained by a source domain dataset in a source domain; The source domain dataset includes a plurality of first sealing nail sample images and their corresponding first defect detection labels; a second acquisition module, configured to acquire a first span vector of the source domain and a second span vector corresponding to a support set in a target domain; the first span vector is determined based on the source model; the support set includes a plurality of second sealing nail sample images and their corresponding second defect detection labels; the first span vector is used to characterize the statistical feature distribution of the source domain, and the second span vector is used to characterize the feature statistical distribution of the target domain; a first processing module, configured to process the sample features of the second sealing nail sample image based on the first span vector and the second span vector to obtain corresponding target generalization features; The first training module is used to train the source model based on the target generalization feature to obtain the target detection The target detection model is used to detect sealing pin welding defects.

19. An electronic device comprising: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the steps of the sealing pin welding defect detection model training method according to any one of claims 1 to 16 are implemented.

20. A computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the steps of the sealing pin welding defect detection model training method according to any one of claims 1 to 16.

Citation Information

Patent Citations

  • Image defect detection model training method and device, and computer equipment

    CN113610787A

  • Multi-source cross-domain expression recognition method and device and storage medium

    CN114612961A

  • Cross-scene strip steel surface defect detection method based on domain adaptation

    CN115035097A

  • Domain-adaptive object surface defect detection method and system, and storage medium

    CN115564752A

  • Negative migration suppression method for cross-domain classification and recognition of apparent defects

    CN116777896A

Cited By

  • Small sample target detection method and device based on style augmentation and storage medium

    CN121437867A