A potato surface defect data enhancement method and system based on a mask conditional generative adversarial network

By using masked conditional generative adversarial networks, the problems of inaccurate defect image generation and poor background consistency in existing technologies are solved. This enables the generation of defect images with continuous structure, consistent background, and controllable categories, thereby improving the detection accuracy and generalization ability of the potato surface defect detection model.

CN122492558APending Publication Date: 2026-07-31GUILIN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUILIN UNIVERSITY OF TECHNOLOGY
Filing Date
2026-04-01
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies lack methods for generating and augmenting defect images that achieve structural continuity, consistent background, and controllable categories for a few types of defects under the constraint of a clearly defined defect region. This results in inaccurate generation locations or poor background consistency, affecting the training effect and generalization ability of deep learning detection models.

Method used

We employ a mask-based conditional generative adversarial network (GAN) to generate high-quality defect images by combining mask feature encoding, spatial attention guidance, and multi-condition feature fusion with structural consistency and background consistency constraints.

Benefits of technology

It improves the detection accuracy and generalization ability of the defect detection model under conditions with few samples, and the generated defect images show excellent performance in terms of structural continuity, background consistency and category controllability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122492558A_ABST
    Figure CN122492558A_ABST
Patent Text Reader

Abstract

This invention relates to the fields of intelligent agricultural product detection and computer vision technology, and particularly to a method and system for enhancing potato surface defect data based on a mask-based conditional generative adversarial network. The method includes: acquiring a defect image of the potato surface and a corresponding binary defect mask, and performing size normalization; inputting the binary defect mask into a mask feature encoding network to encode the defect region, extracting its spatial structural features, and generating spatial attention weights; based on the spatial attention weights, spatially weighted modulating random noise features to form fused features; inputting the fused features into a generative network to generate a potato surface defect image containing the target defect; and inputting the generated defect image, the binary defect mask, and the corresponding defect category into a discriminant network for joint discrimination. This invention improves the quality of the generated defect image in terms of structural continuity, texture realism, and overall distribution consistency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of intelligent detection of agricultural products and computer vision technology, and in particular to a method and system for enhancing potato surface defect data based on masked conditional generative adversarial networks. Background Technology

[0002] In the field of automated grading and quality inspection of agricultural products, machine vision-based surface defect detection technology is widely used for quality assessment of tuber crops such as potatoes. However, in actual production and collection processes, the frequency of occurrence of different types of defects varies significantly. Among them, defects such as cracks and holes are often minority samples, and the insufficient number of samples seriously restricts the training effect and generalization ability of deep learning detection models.

[0003] In existing technologies, common data augmentation methods include traditional enhancement techniques such as geometric transformations and color perturbations. However, these methods only perform simple transformations on existing samples and are difficult to effectively increase the diversity of defect morphology. In recent years, generative adversarial networks have been introduced into the field of defect image generation. However, generative networks usually only take random noise or overall conditions as input, lacking explicit constraints on the spatial location and morphology of defects. This leads to inaccurate generated defect locations or inconsistencies with the real distribution. In addition, this approach often ignores background consistency constraints in non-defect areas, causing unnecessary texture perturbations in the generated image outside the defect area, thereby reducing the training stability of subsequent models.

[0004] Therefore, there is a need for a method, system, and medium for generating and data augmenting defect images that achieve structural continuity, consistent background, and controllable categories for a few types of defects under the constraint of a clearly defined defect region. Summary of the Invention

[0005] The main objective of this invention is to provide a method and system for enhancing potato surface defect data based on masked conditional generative adversarial networks. This aims to address the problem that existing technologies lack methods for generating and enhancing defect images with continuous structure, consistent background, and controllable categories for a few types of defects under clearly defined defect region constraints.

[0006] To achieve the above objectives, this invention proposes a method for enhancing potato surface defect data, which includes the following steps:

[0007] Obtain defect images of potato surfaces and corresponding binary defect masks, and perform size normalization on the defect images and binary defect masks.

[0008] The binary defect mask is input into the mask feature encoding network to encode the defect region, extract the spatial structure features of the defect region, and generate spatial attention weights to characterize the importance of the defect region based on the spatial structure features.

[0009] Based on spatial attention weights, random noise features are spatially weighted and modulated, and the noise features guided by spatial attention, mask spatial features, and defect category condition information are fused to form fused features for defect generation.

[0010] The fused features are input into the generative network to generate a potato surface defect image containing the target defect;

[0011] The generated defect image, binary defect mask, and corresponding defect category are input into the discrimination network for joint discrimination to constrain the authenticity of the generated defect image and the consistency of the defect category.

[0012] During the training of the generative network, structural consistency constraints are introduced to enhance the continuity of the crack structure for a limited number of crack defects.

[0013] Background consistency constraints are introduced in non-defect areas to suppress interference of the generation process on the background texture of non-defect areas, thereby obtaining potato surface defect samples for data augmentation.

[0014] Preferably, the mask feature encoding network includes multiple layers of convolutional blocks and residual blocks for extracting high-dimensional features from the input mask, wherein the input mask is denoted as M and the high-dimensional features are denoted as F. m .

[0015] Preferably, the step of spatially weighting and modulating random noise features based on spatial attention weights, and fusing the spatially attention-guided noise features, mask spatial features, and defect category condition information to form a fused feature for defect generation, further includes:

[0016] By introducing defect category conditions, the embedded vectors are mapped to the same channel dimension as the mask features and noise features and then concatenated to form fused features.

[0017] The fusion features are jointly extracted through multi-layer convolutional blocks and residual blocks, enabling the generator network to simultaneously perceive defect location, structure, and category information, thereby achieving controllable generation of multiple types of defects.

[0018] Preferably, the step of spatially weighting and modulating random noise features based on spatial attention weights, and fusing the spatially attention-guided noise features, mask spatial features, and defect category condition information to form a fused feature for defect generation, further includes:

[0019] Spatial attention weights are generated and applied to the noise features of the input network, while ensuring that the outputs of the feature encoding network and spatial attention maintain the same spatial resolution as the input mask.

[0020] This invention also discloses a potato surface defect data enhancement system, the potato surface defect data enhancement system comprising:

[0021] The data input module is used to acquire images of potato surface defects and their corresponding binary defect masks.

[0022] The mask feature encoding module is used to input the binary defect mask into the mask feature encoding network, and extract the spatial features of the defect region through multi-layer convolution and residual operations;

[0023] The spatial attention generation module calculates spatial attention weights based on mask features;

[0024] The random noise mapping module generates random noise vectors and maps them to noise features with the same dimension as the mask feature space.

[0025] The defect category condition embedding module is used to map defect category conditions to category features with the same channel dimensions as mask features and noise features;

[0026] The feature fusion module is used to concatenate mask features, spatial attention-weighted noise features, and category condition features along the channel dimension to form fused features;

[0027] A generation module is used to generate images of potato surface defects based on fused features through a generative network;

[0028] The discrimination module is used to jointly discriminate between the generated potato surface defect image and the real potato surface defect image. The discrimination includes authenticity discrimination and defect category consistency discrimination.

[0029] The output module is used to output the generated potato surface defect image.

[0030] Preferably, the potato surface defect data enhancement system further includes:

[0031] The structural consistency constraint module is used to calculate the constraint loss based on the edge structure for a preset minority of crack defects;

[0032] The background consistency constraint module is used to calculate the pixel-level consistency loss of non-defect areas and apply background consistency constraints to non-defect areas.

[0033] The present invention also discloses a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program, when executed by a processor, performs the steps of the potato surface defect data enhancement method as described in any of the above technical solutions.

[0034] This invention improves the quality of generated defect images in terms of structural continuity, texture realism, and overall distribution consistency by introducing mask feature encoding, spatial attention guidance, multi-condition feature fusion, and constraints on the structural consistency of minority class defects and the background consistency of non-defect regions, while ensuring the controllable generation of defect spatial location and category. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the processes shown in these drawings without creative effort.

[0036] Figure 1 This is a schematic flowchart of the preparation method of the potato surface defect data enhancement method provided in an embodiment of the present invention;

[0037] Figure 2 This is a network structure diagram of the defect detection model in the potato surface defect data enhancement system provided by the present invention;

[0038] Figure 3 This is a schematic diagram of structural consistency constraints and background consistency constraints for minority class defects provided in an embodiment of the present invention;

[0039] Figure 4 This is a schematic diagram of the structure of a generative network provided in an embodiment of the present invention;

[0040] Figure 5 This is a schematic diagram of the structure of a mask feature encoding and spatial attention generation module provided in an embodiment of the present invention. Detailed Implementation

[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0042] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.

[0043] Furthermore, the use of terms such as "first" and "second" in this invention is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. Additionally, the technical solutions of the various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. When the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed by this invention.

[0044] This invention addresses the problems of insufficient sample size for minority classes of defects, unstable defect structure generation, and significant interference of the generated results with the background area in potato surface defect detection. It proposes a data augmentation method and system based on conditional generative adversarial networks.

[0045] By introducing defect mask conditions and defect category conditions during the generation process, and constructing a structural consistency constraint mechanism for a small number of defect types, precise control over the location, shape, and category of defect generation can be achieved, thereby generating high-quality defect samples with continuous structure and consistent background. This can be used to improve the detection accuracy and generalization ability of the defect detection model under conditions with few samples.

[0046] Based on this, such as Figures 1-5 This invention provides a method for enhancing potato surface defect data, comprising the following steps:

[0047] Step S10: Obtain the defect image of the potato surface and the corresponding binary defect mask, and perform size normalization processing on the defect image and the binary defect mask.

[0048] Step S20: Input the binary defect mask into the mask feature encoding network to encode the defect region, extract the spatial structure features of the defect region, and generate spatial attention weights to characterize the importance of the defect region based on the spatial structure features.

[0049] Step S30: Based on spatial attention weights, spatial weighted modulation is performed on random noise features, and the noise features guided by spatial attention, mask spatial features, and defect category condition information are fused to form fused features for defect generation.

[0050] Step S40: Input the fused features into the generator network to generate a potato surface defect image containing the target defect;

[0051] Step S50: Input the generated defect image, binary defect mask and corresponding defect category into the discrimination network for joint discrimination, so as to constrain the authenticity of the generated defect image and the consistency of the defect category.

[0052] Step S60: During the training of the generative network, structural consistency constraints are introduced to enhance the continuity of the crack structure for the preset minority class of crack defects.

[0053] Step S70: Introduce background consistency constraints in the non-defect area to suppress the interference of the generation process on the background texture of the non-defect area, and obtain potato surface defect samples for data augmentation.

[0054] In this embodiment, for a small number of predefined crack-like defect categories, edge consistency constraints are introduced during the training process of the generative network. The specific formula is as follows:

[0055] ;

[0056] in, This refers to the convolution operation of the Sobel operator in the x-direction. This refers to the convolution operation of the Sobel operator in the y-direction. For the generated potato surface defect image, H represents the height of the potato surface defect image, and W represents the width of the potato surface defect image.

[0057] More specifically, in this embodiment, the binary defect mask is represented as M; the edge consistency constraint is represented as... The edge consistency constraint is expressed as Used to enhance crack continuity and refine the details of local structures; while also combating loss. To ensure the authenticity of the generated images.

[0058] During the training of the generative network, a background consistency constraint loss is introduced for the non-defective regions 1-M. Background consistency constraint loss The specific calculation formula is as follows:

[0059]

[0060] Background consistency constraint loss This is used to preserve the original background texture information and prevent the generation process from introducing artifacts into non-defect areas. At the same time, it combines edge constraints and class discrimination loss to make the generated image realistic in the defect area and consistent in the background area, ensuring that the generated image can be directly used for data augmentation tasks.

[0061] More detailed images of potato surface defects were generated. Used to expand minority class defect samples, forming an enhanced dataset D aug This dataset is used to train downstream defect detection models, thereby improving detection accuracy and generalization ability under conditions of few samples; the potato surface defect data augmentation method involved in this invention uses adversarial loss in combination. Loss Classification Perceived loss Pixel-level reconstruction loss Crack edge constraint Consistency with background This enables the generation of images to achieve high fidelity and diversity across multiple dimensions, including structure, category, and texture.

[0062] In one embodiment, the mask feature encoding network includes multiple layers of convolutional blocks and residual blocks for extracting high-dimensional features from the input mask, wherein the input mask is denoted as M and the high-dimensional features are denoted as F. m .

[0063] In detail, the mask feature encoding network in step S20 is represented as f mask (·), the mask feature encoding network contains multiple layers of convolutional blocks and residual blocks, used to extract high-dimensional features (represented as F) of the input mask M. m ).

[0064] Furthermore, in this step, the preprocessed binary defect mask M is input into the mask feature encoding network f. mask (·), high-dimensional spatial features of the defect region are extracted through multi-layer convolution operations and residual connections, specifically:

[0065] ;

[0066] In step S50, the generated potato surface defect image is... Real images of potato surface defects The input images are respectively input into the discriminant network (D(·)) and jointly judged by combining the corresponding defect mask and defect category conditions. The discriminant network includes an adversarial discriminant branch and a defect category discriminant branch. The adversarial discriminant branch is used to judge the authenticity of the input image, and its adversarial loss is defined as:

[0067] ;

[0068] The defect category discrimination branch is used to determine the category consistency of the generated images, and its classification loss is defined as:

[0069] ;

[0070] In one embodiment, step S30, which involves spatially weighted modulation of random noise features based on spatial attention weights, and fusing the spatially attention-guided noise features, mask spatial features, and defect category condition information to form a fused feature for defect generation, further includes:

[0071] Step S31: Introduce defect category conditions, and then stitch them together to form fused features after mapping the embedding vectors to the same channel dimension as the mask features and noise features;

[0072] Step S32: The fusion features are jointly extracted through multi-layer convolutional blocks and residual blocks, enabling the generator network to simultaneously perceive the location, structure and category information of defects, so as to achieve the controllable generation of multiple types of defects.

[0073] In detail, in step S30, a random noise vector Z is generated and converted into a noise feature representation with the same spatial dimension as the mask feature through a fully connected mapping or a convolutional mapping:

[0074] ;

[0075] Among them, F z This is a noise characteristic.

[0076] More specifically, the defect category condition is represented by C, which is mapped to two features (i.e., mask features F) through an embedding vector mapping. m and noise characteristics F z Features with the same channel dimensions are concatenated to form a fused feature, as shown in the following formula:

[0077] ;

[0078] ;

[0079] in, As a feature of fusion, For category condition features, For mask features, Noise characteristics, Spatial attention weights, For defect category conditions, To add element by element, This is for element-wise multiplication.

[0080] Then merge features The input generator network (G(·)) generates a surface defect image of the target potato through multi-layer residual convolution and progressive upsampling operations. This step achieves high-quality generation of multiple types of defects within a specified region by jointly constraining the spatial location and category information of defects and random perturbations. Specifically:

[0081]

[0082] In one embodiment, step S30, which involves spatially weighted modulation of random noise features based on spatial attention weights, and fusing the spatially attention-guided noise features, mask spatial features, and defect category condition information to form a fused feature for defect generation, further includes:

[0083] Step S33: Generate spatial attention weights and weight the noise features input to the generation network, ensuring that the outputs of the feature encoding network and spatial attention maintain the same spatial resolution as the input mask.

[0084] Furthermore, this embodiment introduces a spatial attention mechanism based on the mask features, and then generates a spatial attention weight map by performing convolutional mapping on the mask features and normalizing them through the Sigmoid activation function.

[0085] The spatial attention mechanism involved in this invention outputs through a spatial attention module. This mechanism adaptively assigns pixel-level importance to defect regions by performing channel aggregation and spatial convolution on mask features. The spatial attention module in this invention generates attention weights A through convolution operations and activation functions, which are used to address the noise features F input to the generation network. s The weighted average is calculated using the following formula:

[0086] ;

[0087] Among them, W s For convolution kernel parameters, (·) represents the Sigmoid activation function. Spatial attention weights are used to characterize the spatial importance of the defect region while maintaining the same spatial resolution as the original mask. This step aims to focus the generation process on the defect region by explicitly modeling its spatial distribution, thereby suppressing interference from irrelevant features of non-defect regions.

[0088] In detail, the generation attention weight A ensures that the generated results are focused on the defective region, and the outputs of the feature encoding network and the spatial attention module maintain the same spatial resolution as the input mask to facilitate fusion.

[0089] This invention also discloses a potato surface defect data enhancement system, which includes:

[0090] The data input module is used to acquire images of potato surface defects and their corresponding binary defect masks.

[0091] The mask feature encoding module is used to input the binary defect mask into the mask feature encoding network, and extract the spatial features of the defect region through multi-layer convolution and residual operations;

[0092] The spatial attention generation module calculates spatial attention weights based on mask features;

[0093] The random noise mapping module generates random noise vectors and maps them to noise features with the same dimension as the mask feature space.

[0094] The defect category condition embedding module is used to map defect category conditions to category features with the same channel dimensions as mask features and noise features;

[0095] The feature fusion module is used to concatenate mask features, spatial attention-weighted noise features, and category condition features along the channel dimension to form fused features;

[0096] A generation module is used to generate images of potato surface defects based on fused features through a generative network;

[0097] The discrimination module is used to jointly discriminate between the generated potato surface defect image and the real potato surface defect image. The discrimination includes authenticity discrimination and defect category consistency discrimination.

[0098] The output module is used to output the generated potato surface defect image.

[0099] In one embodiment, the potato surface defect data enhancement system further includes:

[0100] The structural consistency constraint module is used to calculate the constraint loss based on the edge structure for a preset minority of crack defects;

[0101] The background consistency constraint module is used to calculate the pixel-level consistency loss of non-defect areas and apply background consistency constraints to non-defect areas.

[0102] Specifically, the data input module is used to acquire potato surface defect image I, which is specifically represented as follows:

[0103] ;

[0104] And the binary defect mask M corresponding one-to-one with the potato surface defect image I, specifically represented as:

[0105] ;

[0106] This potato surface defect data augmentation system constrains the network during training by jointly optimizing the loss function, specifically as follows:

[0107] ;

[0108] in, To combat the losses, To classify losses, In order to perceive loss, For pixel-level reconstruction loss, To constrain the crack edge, For background consistency constraints.

[0109] In this invention, a trained generative network is used to generate images of potato surface defects, constructing the enhanced defect dataset Daug. To verify the effectiveness of the method in terms of defect generation quality, quantitative evaluation and comparative experimental analysis are conducted on the generation results.

[0110] In the experiment, Fréchet Inception Distance (FID) was selected as the quality evaluation index for generated images, used to measure the difference between the distribution of generated defective images and the distribution of real defective images. The smaller the FID value, the closer the generated image is to the real sample in terms of overall distribution, structural features, and visual quality.

[0111] First, the method of this invention is compared with several existing generative adversarial network methods, including Mask-cGAN (comparative example 1) which only introduces mask and category conditions, cGAN (comparative example 2) which only introduces category conditions, and Pix2Pix method based on mask conditions (comparative example 3). Under the same training data and experimental settings, FID calculation is performed on defect images generated by different models, and the comparison results are shown in the table below:

[0112] Table 1. FID values ​​of the model of the present invention and comparative embodiments 1-3

[0113] Model Method FID ↓ Mask-cGAN (Comparative Example 1) 198.74 cGAN (Comparative Example 2) 170.53 Pix2Pix (Comparative Example 3) 139.66 This invention model 116.47

[0114] Experimental results show that the MG-PatchGAN method proposed in this invention is significantly lower than the comparative method in terms of FID index, indicating that by introducing masking conditions, category conditions and spatial attention mechanism, the overall quality and distribution consistency of the generated defective images can be effectively improved.

[0115] Furthermore, to verify the generation stability and consistency of the method of the present invention across different defect categories, FID evaluation was performed on the generation results of three types of defects: crack defects, hole defects, and scar defects, and the results were compared with those of the comparison method described above. The results are shown in the table below:

[0116] Table 2. FID values ​​of the model of the present invention and comparative embodiments 1-3

[0117] Model Method Crack (defect) Hole (hole defect) Scab (scar defect) Average FID ↓ Mask-cGAN 173.44 226.79 195.99 198.74 cGAN 143.17 216.16 152.26 170.53 Pix2Pix 135.70 142.39 140.89 139.66 Model in this embodiment 106.49 119.36 123.56 116.47

[0118] Experimental results show that the FID values ​​of the method of the present invention are significantly lower than those of existing methods for various types of defects. In particular, in the task of generating a few types of crack defects, it can effectively improve the continuity of the defect structure and the clarity of the edges.

[0119] The above experiments demonstrate that the data augmentation method based on masked conditional generative adversarial networks proposed in this invention can achieve better generation quality in multi-category defect generation tasks, providing high-quality data augmentation samples for subsequent defect detection models, thereby effectively improving the training effect and generalization ability of defect detection models under conditions of few samples.

[0120] The present invention also discloses a computer-readable storage medium, wherein the storage medium is a computer-readable storage medium and stores a computer program thereon, and when the computer program is executed by a processor, it performs the steps of the potato surface defect data enhancement method of any of the above technical solutions.

[0121] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0122] The aforementioned computer-readable storage medium may be included in a device for detecting potato surface defects; or it may exist independently and not assembled into a device for detecting potato surface defects.

[0123] It is understood that the present invention may also relate to a device for detecting surface defects of potatoes, the device comprising:

[0124] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method for detecting potato surface defects based on YOLOv8 as described in Embodiment 1 above.

[0125] The device for detecting potato surface defects in this application embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. The device for detecting potato surface defects disclosed above is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments in this application.

[0126] It should be understood that the various parts disclosed in this invention can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.

[0127] The above description is merely a specific embodiment of the present invention, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0128] This invention introduces mask feature encoding, spatial attention guidance, multi-condition feature fusion, and constraints on the structural consistency of minority class defects and the background consistency of non-defect regions. While ensuring the controllable generation of defect spatial location and category, it effectively improves the quality of generated defect images in terms of structural continuity, texture realism, and overall distribution consistency. Furthermore, the method of this invention achieves better results in the FID index compared to existing conditional generative adversarial network methods, indicating that this invention can significantly improve the quality of defect generation under limited sample conditions, thereby providing higher-value data augmentation samples for subsequent defect detection models.

[0129] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural transformations made using the contents of the present invention's specification and drawings under the inventive concept of the present invention, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.

Claims

1. A method for augmenting potato surface defect data, characterized in that, The potato surface defect data enhancement method includes the following steps: Obtain defect images of potato surfaces and corresponding binary defect masks, and perform size normalization on the defect images and binary defect masks. The binary defect mask is input into the mask feature encoding network to encode the defect region, extract the spatial structure features of the defect region, and generate spatial attention weights to characterize the importance of the defect region based on the spatial structure features. Based on the spatial attention weights, the random noise features are spatially weighted and modulated, and the spatial attention-guided noise features, the mask spatial features, and the defect category condition information are fused to form a fused feature for defect generation. The fused features are input into the generative network to generate a potato surface defect image containing the target defect; The generated defect image, binary defect mask, and corresponding defect category are input into the discrimination network for joint discrimination to constrain the authenticity of the generated defect image and the consistency of the defect category. During the training of the generative network, structural consistency constraints are introduced to enhance the continuity of the crack structure for a limited number of crack defects. Background consistency constraints are introduced in non-defect areas to suppress interference of the generation process on the background texture of non-defect areas, thereby obtaining potato surface defect samples for data augmentation.

2. The potato surface defect data enhancement method as described in claim 1, characterized in that, The mask feature encoding network includes multiple layers of convolutional blocks and residual blocks, used to extract high-dimensional features from the input mask, where the input mask is denoted as M and the high-dimensional features are denoted as F. m .

3. The potato surface defect data enhancement method as described in claim 2, characterized in that, The step of spatially weighted modulation of random noise features based on spatial attention weights, and fusing the spatially attention-guided noise features, mask spatial features, and defect category condition information to form a fused feature for defect generation, further includes: By introducing defect category conditions, the embedded vectors are mapped to the same channel dimension as the mask features and noise features and then concatenated to form fused features. The fusion features are jointly extracted through multi-layer convolutional blocks and residual blocks, enabling the generator network to simultaneously perceive defect location, structure, and category information, thereby achieving controllable generation of multiple types of defects.

4. The potato surface defect data enhancement method as described in claim 3, characterized in that, The step of spatially weighted modulation of random noise features based on spatial attention weights, and fusing the spatially attention-guided noise features, mask spatial features, and defect category condition information to form a fused feature for defect generation, further includes: Spatial attention weights are generated and applied to the noise features of the input network, while ensuring that the outputs of the feature encoding network and spatial attention maintain the same spatial resolution as the input mask.

5. A potato surface defect data augmentation system, characterized in that, The potato surface defect data enhancement system includes: The data input module is used to acquire images of potato surface defects and their corresponding binary defect masks. The mask feature encoding module is used to input the binary defect mask into the mask feature encoding network, and extract the spatial features of the defect region through multi-layer convolution and residual operations; The spatial attention generation module calculates spatial attention weights based on mask features; The random noise mapping module generates random noise vectors and maps them to noise features with the same dimension as the mask feature space. The defect category condition embedding module is used to map defect category conditions to category features with the same channel dimensions as mask features and noise features; The feature fusion module is used to concatenate mask features, spatial attention-weighted noise features, and category condition features along the channel dimension to form fused features; A generation module is used to generate images of potato surface defects based on fused features through a generative network; The discrimination module is used to jointly discriminate between the generated potato surface defect image and the real potato surface defect image. The discrimination includes authenticity discrimination and defect category consistency discrimination. The output module is used to output the generated potato surface defect image.

6. The potato surface defect data enhancement system as described in claim 5, characterized in that, The potato surface defect data enhancement system also includes: The structural consistency constraint module is used to calculate the constraint loss based on the edge structure for a preset minority of crack defects; The background consistency constraint module is used to calculate the pixel-level consistency loss of non-defect areas and apply background consistency constraints to non-defect areas.

7. A computer-readable storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it performs the steps of the potato surface defect data enhancement method as described in any one of claims 1 to 4.