A small sample industrial part defect detection generation enhancement method and related equipment
By parameterizing the geometric features of industrial parts and constructing a geometric generative adversarial network, visual images conforming to the geometric parameters are generated, solving the problem of insufficient generalization ability of detection models under small sample conditions and achieving efficient defect detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN INST OF INFORMATION TECH
- Filing Date
- 2026-04-02
- Publication Date
- 2026-07-21
AI Technical Summary
Existing technologies lack generalization ability in industrial part defect detection under small sample conditions. Traditional methods struggle to generate high-quality geometrically consistent images, and generators are prone to overfitting, resulting in insufficient accuracy and reliability of the detection model in small sample environments.
By classifying and parameterizing the geometric features of industrial parts, a geometric generative adversarial network is constructed. This network generates enhanced samples using random noise and geometric parameters, and achieves a geometric-visual bidirectional mapping through a closed-loop mechanism of generator, recognizer, and discriminator, generating visual images that conform to the geometric parameters.
It significantly improves the accuracy and reliability of defect detection under small sample conditions, and the generated enhanced samples can effectively expand the distribution of training data and improve the generalization performance of the model.
Smart Images

Figure CN121962818B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial intelligent inspection technology, and in particular to a method for generating and enhancing defects in small-sample industrial parts and related equipment. Background Technology
[0002] With the rapid development of deep learning in the field of industrial intelligent inspection, visual inspection methods based on convolutional neural networks have become the mainstream. For example, models such as Faster R-CNN, YOLO series, and Mask R-CNN perform excellently on large-scale data, achieving high-precision localization and classification in industrial part defect detection. However, due to the extreme scarcity of defect samples in industrial production, especially the special defect types of critical parts, traditional large-model supervised learning methods are often difficult to apply directly, resulting in insufficient generalization ability of detection models in small-sample environments.
[0003] To alleviate the problem of sample scarcity, existing technologies mainly explore the following types of methods: data augmentation, generative methods, and modeling based on prior geometric features. Data augmentation methods increase sample diversity through rotation, scaling, cropping, and noise perturbation, but their ability to simulate specific defects in parts is limited, making it difficult to cover complex defect morphologies. Generative methods, such as conditional generative adversarial networks (GANs), can generate defect images under input categories or attributes, increasing the amount of training data for small samples. However, traditional GANs mainly use noise as the generation input, lacking explicit control over the geometric structure of parts, resulting in insufficient geometric consistency and physical interpretability of the generated images. Modeling methods based on prior geometric features synthesize images by explicitly extracting parameters such as part size, aperture, and curvature, but they usually rely on differentiable rendering or traditional rendering pipelines, which are computationally complex and difficult to scale to large-scale training.
[0004] Furthermore, existing methods still face bottlenecks in terms of geometric consistency between generated samples and real parts, defect diversity, and stability during small-sample training. The one-way generation process cannot ensure that the generated images strictly follow the input parameters, and in small-sample environments, the generator is prone to overfitting or generating low-quality images. Summary of the Invention
[0005] This invention provides a method and related equipment for generating and enhancing defects in small-sample industrial parts, with the aim of improving the reliability and accuracy of defect detection under small-sample conditions.
[0006] To achieve the above objectives, the present invention provides a generative enhancement method for small-sample industrial part defect detection, comprising:
[0007] Step 1: Obtain images of industrial parts samples for training, and classify and parameterize the geometric features of the industrial parts samples to obtain global shape parameters, local structure parameters, and defect control parameters.
[0008] Step 2: Introduce random noise, and use the random noise, global shape parameters, local structural parameters and defect control parameters of industrial parts samples to train the constructed geometric generative adversarial network structure to obtain the defect detection model;
[0009] Step 3: Input the industrial parts to be inspected into the defect detection model for defect detection and obtain the detection results;
[0010] The structure of a geometric generative adversarial network includes a generator, a recognizer, and a discriminator;
[0011] The generator is used to generate a target image based on a noise vector, global shape parameters, local structure parameters, and defect control parameters;
[0012] The recognizer is used to predict the corresponding global shape parameters, local structure parameters, and defect control parameters from the target image;
[0013] The discriminator is used to distinguish whether the input sample comes from the true sample distribution and to evaluate the degree of matching between the sample and the geometric parameters.
[0014] Furthermore, global shape parameters include aspect ratio, area percentage, attitude angle, and Hu moments, which reflect the overall shape properties that remain unchanged despite rotation and scale.
[0015] Furthermore, local structural parameters include edge sharpness, angular density, and local concavity-convexity ratio, which characterizes the degree of concavity in the outer contour of the shape.
[0016] Furthermore, the defect control parameter is the defect category, which is used to control the presentation of defect types during the generation process.
[0017] Furthermore, the expression for generating the target image based on the noise vector, global shape parameters, local structure parameters, and defect control parameters is as follows:
[0018] ;
[0019] in, Represents the target image. This represents the generator backbone network. Indicates a noise embedding layer. Indicates the parameter embedding layer. Represents the noise vector. This represents a geometric parameter vector, which consists of global shape parameters, local structural parameters, and defect control parameters.
[0020] Furthermore, the optimization goals of the recognizer include:
[0021] The parameter reconstruction loss, used to constrain the consistency between the predictive results of the recognizer and the true geometric parameter labels under supervised samples, is expressed as follows:
[0022] ;
[0023] in, This represents the parameter reconstruction loss value. This represents the result of recognizing the geometric parameters corresponding to the real image. This represents the Euclidean distance, used to measure the difference between the identified parameters and the true labels;
[0024] The cycle consistency loss is expressed as follows:
[0025] ;
[0026] in, This represents the cycle consistency loss value. This represents a geometric parameter recognition network.
[0027] Furthermore, the optimization objective of the discriminator is the adversarial loss function, which is expressed as:
[0028] ;
[0029] in, Let represent the adversarial loss values. The first term expects the real image to be classified as true under the corresponding parameter conditions, and the second term expects the generated image to be classified as false under the input parameter conditions. This represents the discriminator backbone network. Represents the true sample distribution. Indicates a noise embedding layer. Indicates the parameter embedding layer. Represents the noise vector. This represents a vector of geometric parameters.
[0030] The present invention also provides a generative enhancement device for defect detection of small sample industrial parts, comprising:
[0031] The parameterization module is used to acquire images of industrial parts samples for training and to classify and parameterize the geometric features of the industrial parts samples to obtain global shape parameters, local structure parameters, and defect control parameters.
[0032] The pre-training module is used to introduce random noise and pre-train the constructed geometric generative adversarial network structure using random noise, global shape parameters, local structural parameters, and defect control parameters of industrial parts samples to obtain a defect detection model.
[0033] The generation module is used to generate enhanced samples containing specified defect categories using a geometric generation enhancement model;
[0034] The training module is used to train the defect detection model using augmented samples and training component samples, and then use the trained defect detection model for defect detection of industrial component images.
[0035] The structure of a geometric generative adversarial network includes a generator, a recognizer, and a discriminator;
[0036] The generator is used to generate a target image based on a noise vector, global shape parameters, local structure parameters, and defect control parameters;
[0037] The recognizer is used to predict the corresponding global shape parameters, local structure parameters, and defect control parameters from the target image;
[0038] The discriminator is used to distinguish whether the input sample comes from the true sample distribution and to evaluate the degree of matching between the sample and the geometric parameters.
[0039] The present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a generative enhancement method for defect detection of small sample industrial parts.
[0040] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements a generative enhancement method for defect detection of small sample industrial parts.
[0041] The above-described solution of the present invention has the following beneficial effects:
[0042] This invention classifies and parameterizes the geometric features of industrial component samples used for training, obtaining global shape parameters, local structural parameters, and defect control parameters. Random noise is introduced, and the constructed geometric generative adversarial network structure is pre-trained using the random noise, the global shape parameters, local structural parameters, and defect control parameters of the industrial component samples to obtain a geometric generative enhancement model, which is used to generate enhanced samples. The enhanced samples and training component samples are used to train a defect detection model, which is then used for defect detection of industrial component images. Compared with existing technologies, the geometric generative adversarial network structure provided by this invention includes a generator, a recognizer, and a discriminator. It achieves forward generation from geometric parameters to visual images and backward reasoning from images to geometric parameters. This closed-loop mechanism realizes complementary mapping between geometric parameters and visual features, thereby improving the reliability and accuracy of defect detection under small sample conditions.
[0043] Other beneficial effects of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0044] Figure 1 This is a flowchart illustrating an embodiment of the present invention;
[0045] Figure 2 This is a schematic diagram of the geometric generative adversarial network structure in an embodiment of the present invention;
[0046] Figure 3 This is a schematic diagram of the enhancement device in an embodiment of the present invention;
[0047] Figure 4 This is a schematic diagram of a terminal device in an embodiment of the present invention. Detailed Implementation
[0048] To make the technical problems, solutions, and advantages of this invention clearer, a detailed description will be provided below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0049] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0050] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a locking connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0051] Furthermore, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0052] This invention addresses existing problems by providing a generative enhancement method and related equipment for defect detection of small sample industrial parts.
[0053] like Figure 1 As shown, an embodiment of the present invention provides a generative enhancement method for defect detection of small-sample industrial parts, comprising:
[0054] Step 1: Obtain images of industrial parts samples for training, and classify and parameterize the geometric features of the industrial parts samples to obtain global shape parameters, local structure parameters, and defect control parameters.
[0055] Step 2: Introduce random noise, and use the random noise, global shape parameters, local structural parameters and defect control parameters of industrial parts samples to train the constructed geometric generative adversarial network structure to obtain the defect detection model;
[0056] Step 3: Use the geometric generation enhancement model to generate enhanced samples containing the specified defect categories;
[0057] Step 4: Train the defect detection model using augmented samples and training component samples, and then use the trained defect detection model for defect detection of industrial component images.
[0058] Specifically, such as Figure 2 As shown, the geometric generative adversarial network structure includes a generator G, a recognizer R, and a discriminator D;
[0059] Generator G is used to generate the target image based on the noise vector, global shape parameters, local structure parameters, and defect control parameters;
[0060] The recognizer R is used to predict the corresponding global shape parameters, local structure parameters, and defect control parameters from the target image;
[0061] The discriminator D is used to distinguish whether the input sample comes from the true sample distribution and to evaluate the degree of matching between the sample and the geometric parameters.
[0062] Since the geometric features of industrial parts include both macroscopic differences in overall shape and microscopic local disturbances and structural defects, traditional CAD or point cloud parameters are often difficult to infer directly from images and have too high a dimension, which is not conducive to the stability of small sample training. In order to achieve the modeling goal of the geometry-vision bidirectional generation mechanism, this invention first systematically parameterizes the geometric attributes of industrial parts and establishes a learnable geometric parameter space, so that the model can generate the visual image from the geometric parameters and the geometric parameters from the image under limited sample conditions.
[0063] In this embodiment of the invention, the geometric features of a part are divided into three types of parameters: global shape parameters, local structural parameters, and defect control parameters, which are used to characterize the core differences in shape, edge structure, and surface quality.
[0064] Specifically, global shape parameters include aspect ratios, which characterize the overall length and width of the part and reflect global scale differences. Area percentage is used to characterize the proportion of the bounding box occupied by the target and reflect the overall compactness. An attitude angle used to characterize the angle between the principal direction of a part and the horizontal axis. And Hu moments used to reflect the overall shape properties that are rotationally and scale-invariant. .
[0065] Specifically, local structural parameters include edge sharpness, which characterizes the rate of change of local edge grayscale. Angle density is used to characterize the number of corner points per unit area and reflect the complexity of details. Local concavity-convexity ratio, used to characterize the degree of concavity in the outer contour of a shape. .
[0066] Specifically, the defect control parameters use a category coding format to characterize the types of defects that may exist on the surface of the part. Defined as... ,in Indicates a defect-free sample. Corresponding to preset Typical defect categories (such as scratches, dents, burrs, rust, etc.) are defined. This parameter is input into the network in the form of one-hot encoding or embedding vectors to control the presentation of defect types during the generation process, enabling the model to generate corresponding surface features for different defect categories.
[0067] Based on the three types of parameters mentioned above, the geometric parameter vector for each part sample can be determined as follows: The vector During the training phase, the network serves as a supervised labeled input to learn the mapping from image features to geometric space. During the inference phase, the network can inversely control the structural distribution of visual samples based on the generated geometric parameters, thereby achieving bidirectional controllable generation of geometric and visual data.
[0068] In this embodiment of the invention, the generator receives a joint input of a noise vector and a geometric parameter vector, and generates a target image after embedding layer mapping and nonlinear decoding. The backbone network of the generator adopts multi-layer residual blocks and progressive upsampling modules to ensure the structural continuity of the generated details.
[0069] Specifically, the expression for generating the target image based on the noise vector, global shape parameters, local structure parameters, and defect control parameters is as follows:
[0070] ;
[0071] in, Represents the target image. This represents the generator backbone network. Indicates a noise embedding layer. Indicates the parameter embedding layer. This represents a noise vector, which is a random noise vector, and its purpose is to introduce generative diversity. This represents a geometric parameter vector, which consists of global shape parameters, local structural parameters, and defect control parameters.
[0072] In this embodiment of the invention, the generator backbone network employs multi-layer residual blocks and progressive upsampling modules to ensure the structural continuity of the generated details.
[0073] It should be noted that the recognition R provided in this embodiment of the invention adopts an end-to-end differentiable architecture, which is used to automatically recover the corresponding geometric parameter vector from real or generated part images, and form a bidirectional aligned geometric-visual mapping relationship with the generator.
[0074] The recognizer consists of two cascaded modules, which are as follows:
[0075] Visual feature extraction module: The input image is encoded using a convolutional neural network and outputs a high-dimensional visual feature map. This convolutional neural network can be composed of multiple convolutional layers, batch normalization and non-linear activation functions stacked together to gradually extract the local edges, texture and global structure information of the image.
[0076] The geometric decoding module: It obtains a fixed-dimensional feature vector from the visual feature map through global average pooling, then performs a non-linear mapping via a multilayer perceptron, ultimately regressing the complete geometric parameter vector. This module uses an end-to-end training method, and its parameters are optimized through backpropagation.
[0077] In this embodiment of the invention, the output layer of the geometry decoding module is configured with a corresponding activation function and numerical constraints based on the parameter type. For parameters with bounded values (such as area percentage)... The preferred embodiment employs a sigmoid activation function, uses sin / cos encoding for angle parameters to avoid periodic boundary problems, and uses a softmax activation function to output the category probability distribution for defect categories. This ensures the rationality of the regression parameters while maintaining the differentiability of the entire recognizer.
[0078] Specifically, the forward mapping of the recognizer is defined as:
[0079] ;
[0080] in, This indicates that the input is a real image of the part; The result of recognizing the geometric parameters corresponding to the real image; This represents the reverse geometry recognition module, whose structure consists of a convolutional feature extraction layer and a multilayer perceptron (MLP), used to achieve cross-modal regression from visual space to geometric parameter space.
[0081] Specifically, the optimization goals of the recognizer include:
[0082] The parameter reconstruction loss, used to constrain the consistency between the predictive results of the recognizer and the true geometric parameter labels under supervised samples, is expressed as follows:
[0083] ;
[0084] in, This represents the parameter reconstruction loss value. This represents the result of recognizing the geometric parameters corresponding to the real image. This represents the Euclidean distance, used to measure the difference between the identified parameters and the true labels;
[0085] To maintain closed-loop consistency between geometry, image, and geometry in unsupervised sample scenarios, this invention proposes a cycle consistency loss. Starting from a real image, geometric parameters are predicted by a recognizer, the image is reconstructed by a generator, and finally, the parameters are re-estimated by the recognizer to ensure consistency between the two estimations. The expression for the cycle consistency loss is:
[0086] ;
[0087] in, This represents the cycle consistency loss value. This represents a geometric parameter recognition network;
[0088] It should be noted that when calculating the cycle consistency loss, the generator... The parameters are fixed, and only the recognizer is updated. The parameters are set to ensure the clarity of the optimization objective.
[0089] Ultimately, the overall optimization objective of the recognizer is defined as:
[0090] ;
[0091] in, The weighting coefficients for the cycle consistency constraints are preferred. The value range is 0.2 to 0.7: when there are sufficient labeled samples in the training data, a smaller value can be selected. Values (e.g., 0.2–0.3) primarily indicate supervised learning; when the proportion of unlabeled samples is large, the value can be appropriately increased. The coefficient is set to 0.5–0.7 to strengthen self-supervised constraints. This coefficient can be dynamically adjusted based on the performance on the validation set, enabling the system to achieve a balance between parameter recovery accuracy and geometric closure consistency.
[0092] In this embodiment of the invention, the geometric decoding module can also be implemented using a differentiable hybrid architecture, as detailed below:
[0093] Based on the contour features extracted by the front-end convolutional network, a differentiable geometric computation operator is introduced to explicitly calculate some geometric parameters (such as aspect ratio, Hu moment, etc.), while the remaining parameters are still obtained by neural network regression. This implementation method can further improve the accuracy of geometric parameter recovery while maintaining the end-to-end trainability of the recognizer.
[0094] It should be noted that the above implementation methods are merely illustrative and do not constitute a limitation of the present invention. Those skilled in the art can replace or adjust the internal structure of the geometric decoding module according to actual needs. As long as its overall architecture conforms to the cascaded differentiable architecture defined in the present invention and can be jointly optimized through reconstruction loss and cycle consistency loss, it falls within the protection scope of the present invention.
[0095] The discriminator in this embodiment of the invention adopts a conditional adversarial architecture to distinguish whether the input image comes from the real sample distribution and to evaluate the degree of matching between the image and the input geometric parameters. It uses a multi-layer convolutional downsampling structure to gradually extract the local and global features of the image and incorporates the geometric parameter information into the discrimination process through a dual-input design.
[0096] Specifically, the discriminator consists of two processing paths:
[0097] (1) Image feature extraction path: The input image is passed through multiple convolutional layers, batch normalization layers and LeakyReLU activation function to gradually downsample and obtain a high-dimensional visual feature map, and then the image feature vector is obtained by global pooling. .
[0098] (2) Parameter embedding path: Input geometric parameter vector Mapped to parameter feature vectors via fully connected layers Its dimensions and Alignment.
[0099] Will and The concatenation is performed, the result is fed into subsequent fully connected layers, and finally the conditional probability is output through the Sigmoid activation function. , indicating that given geometric parameters Under these conditions, the image The probability derived from the true sample distribution.
[0100] Specifically, the discriminator's optimization objective is an adversarial loss function, used to constrain the samples generated by the generator to be consistent with the distribution of the real image. Its expression is:
[0101] ;
[0102] in, This represents the adversarial loss value of the discriminator. The first term expects the real image to be classified as real under the corresponding parameter conditions, and the second term expects the generated image to be classified as fake under the input parameter conditions. Represents the true sample distribution. This represents the discriminator backbone network. Represents the true sample distribution. Indicates a noise embedding layer. Indicates the parameter embedding layer. Represents the noise vector. This represents a vector of geometric parameters.
[0103] The recognizer is dedicated to accurately recovering geometric parameters from an image, while the discriminator evaluates the visual realism of the image under given parameters. Together, they constrain the generator to not only generate visually realistic images, but also ensure the semantic consistency between the generated content and the input parameters, thereby comprehensively improving the quality of the geometry-visual bidirectional mapping.
[0104] The generator in this embodiment of the invention is used to receive the joint input of noise vector and geometric parameter vector, and generate the target image after embedding layer mapping and nonlinear decoding. Its core design is to ensure that the geometric structure of the generated image strictly corresponds to the input parameters through geometric consistency constraints.
[0105] Specifically, the generator's input consists of two parts: a random noise vector. Used to introduce generative diversity, geometric parameter vector Used to control the structural properties of the generated image, both are passed through a noise embedding layer. With parameter embedding layer The mapping is performed as a high-dimensional feature representation, and the concatenation is then performed along the channel dimension before being input into the generator backbone network. The expression for generating the target image is:
[0106] ;
[0107] in, This represents the generated target image. Indicates feature concatenation operation;
[0108] The generator backbone network employs multi-layer residual blocks and a progressive upsampling module to progressively decode low-dimensional latent space features into high-resolution images. The residual block structure helps alleviate the gradient vanishing problem and ensures the training stability of deep networks; the progressive upsampling module generates part images with fine structure and continuous edges by progressively enlarging the feature map size.
[0109] To ensure that the geometric structure of the generated image is consistent with the input parameters, this embodiment of the invention introduces a geometric consistency constraint, and the geometric parameter back-mapping is implemented by the recognizer. The back-mapping expression is as follows:
[0110] ;
[0111] in, Used to predict the corresponding geometric parameters from the generated image;
[0112] The geometric consistency loss function is defined as:
[0113] ;
[0114] in, The loss function is the Euclidean norm, used to measure the difference between the geometric parameters of the generated image after being back-calculated by the recognizer and the original input parameters. The gradient of this loss function can be back-propagated to the generator through the recognizer, driving the generator to adjust its output so that the geometric information contained in the generated image is highly consistent with the input parameters.
[0115] Furthermore, the generator must also be subject to adversarial constraints from the discriminator to ensure the visual realism of the generated image. According to the conditional discriminator architecture adopted in this embodiment of the invention, the adversarial loss of the generator is defined as maximizing the probability that the discriminator classifies the generated sample as true, and its expression is:
[0116] ;
[0117] in, For a conditional discriminator with given geometric parameters The output probability under the given condition. When optimizing the generator, by minimizing... This allows the generated image to be accepted as a real sample by the discriminator under the corresponding parameter conditions.
[0118] Considering the above two constraints, the optimization objective of the generator is:
[0119] ;
[0120] in, This is a balance coefficient, with a value range of [0,1], used to weigh the importance of generation realism against geometric consistency. The possible values are 0.3 to 0.7: when When the value is large, the geometric consistency constraint dominates, and the generated result is more consistent with the input parameters in terms of shape, edges, and other structures; when... When the value is small, the adversarial loss dominates, and the generated image focuses more on visual realism. In actual training, It can be dynamically adjusted based on the performance of the validation set to achieve the optimal balance between geometric fidelity and visual realism.
[0121] It should be noted that when optimizing the generator, the recognizer... and discriminator The parameters are fixed, only the generator is updated. and related embedding layers , The parameters are set to ensure the clarity of the optimization goals for each module.
[0122] To verify the feasibility of the provided method, this invention embodiment uses the following experimental environment for verification, the specific process of which is as follows:
[0123] In terms of hardware, a high-performance computer was used as the experimental platform, equipped with an E5-2680V4 CPU, 64GB of memory, and a Tesla V100 professional computing card.
[0124] In terms of software, it used the Ubuntu 22.04 operating system, Python 3.9 programming language, and PyTorch 1.13 deep learning framework;
[0125] The network structure design of each module is as follows:
[0126] The generator G first processes the noise vector through an embedding layer. and geometric parameter vector A non-linear mapping is performed to map the two data points to the same feature dimension, and then they are concatenated to form a joint low-dimensional feature representation. This feature is then processed by five residual convolutional blocks (ResNetBlock×5) to extract multi-scale features. Each residual block consists of a convolutional layer, a batch normalization layer, and a ReLU activation function, and residual connections are used to maintain the continuity of the image structure and enhance gradient propagation. Next, a progressive upsampling module gradually enlarges the feature map to 64×64, 256×256, and 1024×1024 resolutions through three levels of upsampling and convolution operations. Each upsampling level is followed by two convolutional layers to refine the generated details, ultimately outputting the generated image. .
[0127] The recognizer R employs an end-to-end differentiable regression architecture. First, it uses four convolutional feature extraction layers (Conv×4, kernel=3, stride=2, padding=1). Each convolutional layer is followed by a batch normalization layer and a LeakyReLU activation function to progressively downsample the input image to a 64×64×512 feature map, extracting mid-to-high-level spatial structure information. Subsequently, the convolutional feature map undergoes global average pooling to obtain a fixed-dimensional feature vector, which is then input into a two-layer fully connected network (FC-512, FC-128), finally outputting a geometric parameter vector. This is used for subsequent parameter reconstruction loss, geometric consistency constraints, and cyclic consistency constraints.
[0128] The discriminator D employs a conditional PatchGAN architecture. The input image is first processed through four convolutional layers (Conv×4, kernel=4, stride=2, padding=1) to progressively extract local features. Each convolutional layer is followed by InstanceNorm and LeakyReLU activation functions. Simultaneously, the geometric parameter vector... After mapping through a fully connected layer, the spatial conditional features are expanded to the same size as the convolutional feature map through spatial replication, and then concatenated with the convolutional features along the channel dimension. The concatenated features are then fused through two convolutional layers (Conv×2, kernel=4, stride=1, padding=1), finally outputting a 30×30 probability matrix. Each element corresponds to the true / false probability of an image patch in the input image, thereby determining the authenticity of the image and its degree of matching with the input parameters at a local scale.
[0129] The deep learning training parameter configuration of this invention is as follows. This invention uses the Adam optimizer to jointly optimize the network parameters, wherein the generator... Recognizer and discriminator All use the same optimizer hyperparameters: the learning rate is set to... First-order momentum decay coefficient Second-order momentum decay coefficient The total number of training epochs is set to 200, and the batch size is set to 16. The network parameters are updated once after each batch is trained, including the discriminator. and generator Alternating updates, recognizer With generator Synchronized updates.
[0130] To verify the effectiveness of the method of this invention in data augmentation in scenarios with few samples, a comparative experiment was conducted on a dataset of self-captured M6 screw images. This dataset contains 80 images, including 40 images of qualified products and 40 images of defective products (covering 4 typical defect types, 10 images of each type), with each image accompanied by a corresponding defect annotation. During the experiment, 50% of the images were used as the training set and 50% as the test set. Three control groups were set up in the experiment:
[0131] The baseline group directly uses the original 40 images to train the classification model without any data augmentation, serving as a performance benchmark.
[0132] The traditional augmentation group uses conventional data augmentation methods to expand the original images, including random rotation (±30°), horizontal / vertical translation (±10%), Gaussian noise injection (σ=0.01), and brightness adjustment (±20%), expanding the training set to 80 images.
[0133] The method group of this invention first trains the proposed geometric-visual bidirectional controllable generative network on the original 40 images to learn the bidirectional mapping relationship between the geometric parameter space and the image space; then, by randomly sampling in the geometric parameter space (equal sampling of defect category parameters and application of small perturbations to continuous geometric parameters), 40 synthetic images are generated and a mixed training set containing the original images and the generated images is constructed.
[0134] To verify the effectiveness of the generated samples for downstream classification tasks, this experiment selects two classic convolutional neural networks as baseline classification models:
[0135] (1) ResNet-18: As a representative of lightweight residual networks, it contains 4 residual stages and a total of 18 convolutional layers. It is suitable for small-scale image classification tasks. The input image resolution is uniformly adjusted to 224×224.
[0136] (2) MobileNet-V2: As a representative of lightweight networks, it adopts inverse residual structure and depthwise separable convolution, with small number of parameters and high computational efficiency, and is suitable for resource-constrained scenarios. The input image resolution is also adjusted to 224×224.
[0137] The hyperparameters for training the classification model are configured as follows: The Adam optimizer is used, and the initial learning rate is set to... The weight decay coefficient is set to The loss function used was cross-entropy loss; the number of training epochs was set to 100, and the batch size was set to 16; the learning rate adjustment strategy used was cosine annealing decay. All experiments were repeated 5 times under the same hardware environment and random seeds, and the average accuracy was used as the final evaluation metric.
[0138] The experimental results are shown in Table 1 below:
[0139] Table 1 Experimental Results
[0140]
[0141] Table 1 shows that the generalization ability of the classification model is significantly limited under extremely small sample conditions (only 40 training images). In the baseline group, the average accuracies of ResNet-18 and MobileNet-V2 are 0.70 and 0.66, respectively, with relatively large standard deviations, indicating that the models are highly sensitive to the distribution of the training set and have a significant risk of overfitting. Without introducing a structured data augmentation mechanism, it is difficult to learn stable and discriminative defect feature representations relying solely on a limited number of samples.
[0142] After expanding the training samples to 80 images through operations such as random rotation, translation, noise injection, and brightness perturbation, the accuracy of the two models in the traditional augmentation group improved to 0.78 and 0.75, respectively, representing an absolute improvement of approximately 8% to 9% compared to the baseline group. This result indicates that pixel-space-based local perturbations can alleviate the problem of insufficient samples to some extent and improve the robustness of the model to translation invariance and illumination changes. However, the improvement is still limited, mainly because traditional augmentation only performs local perturbations within the neighborhood of the original data distribution and does not change the underlying geometric structure distribution of the samples, making it difficult to introduce new semantic diversity.
[0143] In this embodiment of the invention, the Luzhong method group achieved the highest performance on both classification models. The accuracy of ResNet-18 improved to 0.87, and the F1-score reached 0.86; the accuracy of MobileNet-V2 improved to 0.83, and the F1-score was 0.82. Meanwhile, the standard deviation of the experimental results of this group was significantly lower than that of the baseline group and the traditional augmentation group, with overall fluctuations controlled within ±0.03 to ±0.04, indicating a more stable model training process.
[0144] Compared to the baseline group, the method provided in this embodiment of the invention significantly improves classification accuracy under conditions of few samples; its performance improvement is even more significant compared to the traditional augmentation group. The results show that by introducing generated samples to construct a hybrid training set, the distribution range of training data can be effectively expanded, the model's ability to discriminate defective features can be enhanced, and generalization performance can be improved.
[0145] This invention classifies and parameterizes the geometric features of industrial component samples used for training, obtaining global shape parameters, local structure parameters, and defect control parameters. Random noise is introduced, and the constructed geometric generative adversarial network structure is pre-trained using the random noise, the global shape parameters, local structure parameters, and defect control parameters of the industrial component samples to obtain a geometric generative enhancement model, which is used to generate enhanced samples. The enhanced samples and training component samples are used to train a defect detection model, which is then used for defect detection of industrial component images. Compared with existing technologies, the geometric generative adversarial network structure provided in this invention includes a generator, a recognizer, and a discriminator. It achieves forward generation from geometric parameters to visual images and backward reasoning from images to geometric parameters. This closed-loop mechanism realizes complementary mapping between geometric parameters and visual features, thereby improving the reliability and accuracy of defect detection under small sample conditions.
[0146] Corresponding to the generative enhancement method for small-sample industrial part defect detection described in the above embodiments, such as Figure 3 As shown, this embodiment of the invention also provides a generative enhancement device 100 for defect detection of small sample industrial parts, the generative enhancement device 100 comprising:
[0147] The parameterization module 101 is used to acquire training industrial part sample images and classify the geometric features of the training industrial part samples to obtain global shape parameters, local structure parameters and defect control parameters.
[0148] The pre-training module 102 is used to introduce random noise and pre-train the constructed geometric generative adversarial network structure using random noise, global shape parameters, local structural parameters and defect control parameters of industrial parts samples to obtain a geometric generative enhancement model.
[0149] The generation module 103 is used to generate enhanced samples containing specified defect categories using the geometric generation enhancement model;
[0150] Training module 104 is used to train the defect detection model using enhanced samples and training component samples, and to use the trained defect detection model for defect detection of industrial component images.
[0151] The structure of a geometric generative adversarial network includes a generator, a recognizer, and a discriminator;
[0152] The generator is used to generate a target image based on a noise vector, global shape parameters, local structure parameters, and defect control parameters;
[0153] The recognizer is used to predict the corresponding global shape parameters, local structure parameters, and defect control parameters from the target image;
[0154] The discriminator is used to distinguish whether the input sample comes from the true sample distribution and to evaluate the degree of matching between the sample and the geometric parameters.
[0155] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0156] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0157] This invention also provides a terminal device, such as... Figure 4 As shown, the terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 4 The diagram shows only one processor, a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100. When the processor D100 executes the computer program D102, it implements the above-described method for enhancing the generation of defects in small sample industrial parts.
[0158] The terminal device D10 can be a desktop computer, laptop, handheld computer, server, server cluster, or cloud server, etc. This terminal device may include, but is not limited to, a processor D100 and a memory D101. Those skilled in the art will understand that... Figure 4 This is merely an example of terminal device D10 and does not constitute a limitation on terminal device D10. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0159] The processor D100 can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0160] In some embodiments, the memory D101 may be an internal storage unit of the terminal device D10, such as a hard disk or memory of the terminal device D10. In other embodiments, the memory D101 may be an external storage device of the terminal device D10, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the terminal device D10. Furthermore, the memory D101 may include both internal and external storage units of the terminal device D10. The memory D101 is used to store the operating system, applications, boot loader, data, and other programs, such as the program code of the computer program. The memory D101 can also be used to temporarily store data that has been output or will be output.
[0161] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0162] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0163] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a generative enhancement method for detecting defects in small sample industrial parts.
[0164] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a building device / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0165] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A generative enhancement method for defect detection of small sample industrial parts, characterized in that, include: Step 1: Obtain images of industrial parts samples for training, and classify and parameterize the geometric features of the industrial parts samples to obtain global shape parameters, local structure parameters, and defect control parameters. Step 2: Introduce random noise, and use the random noise, global shape parameters, local structural parameters, and defect control parameters of the training industrial parts samples to pre-train the constructed geometric generative adversarial network structure to obtain a geometric generative enhancement model. The global shape parameters include aspect ratio, area ratio, pose angle, and Hu moments to reflect the overall shape properties that are rotational and scale-invariant. The local structural parameters include edge sharpness, angle density, and local concavity-convexity ratio to characterize the degree of concavity of the outer contour of the shape. The defect control parameters are defect categories, which are used to control the presentation of defect types during the generation process. Step 3: Use the geometry generation enhancement model to generate enhanced samples containing the specified defect categories; Step 4: Train the defect detection model using the enhanced samples and the training industrial component samples, and use the trained defect detection model for defect detection of industrial component images. The geometric generative adversarial network structure includes a generator, a recognizer, and a discriminator; The generator is used to generate a target image based on a noise vector, global shape parameters, local structure parameters, and defect control parameters. The expression for this is: ; in, Represents the target image. This represents the generator backbone network. Indicates a noise embedding layer. Indicates the parameter embedding layer. Represents the noise vector. This represents a geometric parameter vector, which consists of global shape parameters, local structure parameters, and defect control parameters. The recognizer is used to predict the corresponding global shape parameters, local structure parameters, and defect control parameters from the target image; The discriminator is used to distinguish whether the input sample comes from the real sample distribution and to evaluate the degree of matching between the sample and the geometric parameters.
2. The generation enhancement method for small-sample industrial part defect detection according to claim 1, characterized in that, The optimization objectives of the identifier include: The parameter reconstruction loss, used to constrain the consistency between the predictive results of the recognizer and the true geometric parameter labels under supervised samples, is expressed as follows: ; in, This represents the parameter reconstruction loss value. This represents the result of recognizing the geometric parameters corresponding to the real image. Represents a vector of geometric parameters. This represents the Euclidean distance, used to measure the difference between the identified parameters and the true labels; The cycle consistency loss is expressed as follows: ; in, This represents the cycle consistency loss value. This represents a geometric parameter recognition network. This represents the generator backbone network. Indicates a noise embedding layer. Indicates the parameter embedding layer. This represents the noise vector.
3. The generation enhancement method for small-sample industrial part defect detection according to claim 1, characterized in that, The optimization objective of the discriminator is the adversarial loss function, whose expression is: ; in, This represents the adversarial loss value of the discriminator. The first term expects the real image to be classified as real under the corresponding parameter conditions, and the second term expects the generated image to be classified as fake under the input parameter conditions. This represents the discriminator backbone network. Represents the true sample distribution. Indicates a noise embedding layer. Indicates the parameter embedding layer. Represents the noise vector. This represents a vector of geometric parameters.
4. A generative enhancement device for defect detection of small sample industrial parts, characterized in that, include: The parameterization module is used to acquire images of industrial parts samples for training and to classify and parameterize the geometric features of the industrial parts samples to obtain global shape parameters, local structure parameters, and defect control parameters. A pre-training module is used to introduce random noise and pre-train the constructed geometric generative adversarial network structure using the random noise, global shape parameters, local structural parameters, and defect control parameters of the industrial parts samples used for training, to obtain a geometric generative enhancement model. The global shape parameters include aspect ratio, area ratio, pose angle, and Hu moments that reflect the overall shape properties that are rotational and scale-invariant. The local structural parameters include edge sharpness, angle density, and local concavity-convexity ratio that characterizes the degree of concavity of the outer contour of the shape. The defect control parameters are defect categories used to control the presentation of defect types during the generation process. A generation module is used to generate enhanced samples containing specified defect categories using the geometry generation enhancement model; The training module is used to train the defect detection model using the enhanced samples and the training industrial parts samples, and to use the trained defect detection model for defect detection of industrial parts images. The geometric generative adversarial network structure includes a generator, a recognizer, and a discriminator; The generator is used to generate a target image based on a noise vector, global shape parameters, local structure parameters, and defect control parameters. The expression for this is: ; in, Represents the target image. This represents the generator backbone network. Indicates a noise embedding layer. Indicates the parameter embedding layer. Represents the noise vector. This represents a geometric parameter vector, which consists of global shape parameters, local structure parameters, and defect control parameters. The recognizer is used to predict the corresponding global shape parameters, local structure parameters, and defect control parameters from the target image; The discriminator is used to distinguish whether the input sample comes from the real sample distribution and to evaluate the degree of matching between the sample and the geometric parameters.
5. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the generative enhancement method for small sample industrial part defect detection as described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the generative enhancement method for small sample industrial part defect detection as described in any one of claims 1 to 3.