Esophageal endoscope image generation system and method based on improved StyleGAN2-ADA network

By improving the StyleGAN2-ADA network, and utilizing the fusion of mask feature vectors and class conditional vectors, combined with multi-scale feature guidance and loss optimization, the problem of class imbalance in small samples during esophageal endoscopy image generation is solved, generating high-quality medical images that support lesion segmentation and lesion grading tasks.

CN121482530APending Publication Date: 2026-02-06SOUTHWEAT UNIV OF SCI & TECH
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511597120.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-04
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

Existing technologies for generating esophageal endoscopy images suffer from problems such as small sample class imbalance and scarce data samples, resulting in poor image quality stability and insufficient diversity in the generated small sample class images, which cannot effectively support medical analysis tasks such as lesion segmentation and lesion grading.

Method used

An improved StyleGAN2-ADA network is adopted, which generates latent vectors by fusing mask feature vectors and class conditional vectors. It combines a multi-scale feature-guided auxiliary classifier with latent spatial distance loss and contrastive loss to optimize the generator training process, so as to adapt to scenarios with small samples and imbalanced data.

Benefits of technology

Generating high-quality, diverse, and precise esophageal endoscopic images enhances the data support capabilities for subsequent analysis tasks, ensuring the authenticity of medical features and the accuracy of details in the generated images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121482530A_ABST
    Figure CN121482530A_ABST
Patent Text Reader

Abstract

The invention discloses an esophageal endoscope image generation system and method based on an improved StyleGAN2-ADA network. The system comprises a generator and a discriminator. The generator comprises a mapping network and a synthesis network; the discriminator comprises a discrimination network, adopts an adaptive discriminator to enhance an ADA mechanism, and dynamically adjusts the image enhancement intensity according to the training accuracy of the discriminator; the method comprises the following steps: S1, fusing multi-vector features of a mapping network; s2, performing a multi-scale feature guided auxiliary classifier method on the discriminant network; s3, in the generative network, calculating a potential spatial distance loss and a comparison loss method; according to the method, the problems of non-uniform sample types and scarcity of data samples in medical images such as esophageal endoscopes are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of esophageal endoscopy image generation, specifically relating to an esophageal endoscopy image generation system and method based on an improved StyleGAN2-ADA network. Background Technology

[0002] Based on publicly available research literature and authorized patent information both domestically and internationally, current technical solutions for addressing image class imbalance and image generation construct solutions from both data and algorithmic perspectives. At the data level, oversampling and undersampling are the core methods. Oversampling techniques (such as the SMOTE algorithm) supplement data by interpolating new samples within the feature space of smaller sample classes, but this can easily lead to model overfitting and deviations between the generated samples and the actual data distribution. Undersampling techniques balance class proportions by reducing the size of large sample classes, but this may result in the loss of key feature information in large sample classes. At the algorithmic level, the focus is on loss function optimization and ensemble learning. Loss function optimization (such as Focal Loss) enhances the learning of difficult-to-classify samples by adjusting cross-entropy loss weights, but it suffers from difficulties in precisely setting weight parameters and can affect the model's generalization ability. Ensemble learning (such as Bagging and Boosting) improves the equalization effect by integrating multiple classifiers, but its computational complexity is high and its adaptability to sample distribution is limited. In image generation technology, traditional methods (such as those based on Markov random fields) can capture the correlation of local image features, but they suffer from high computational costs and poor generation quality in complex scene image generation. In recent years, Generative Adversarial Networks (GANs) have become mainstream technologies, with StyleGAN2 showing outstanding performance in high-resolution realistic image generation. However, when faced with small-sample imbalanced data, insufficient learning of small-sample class features leads to poor quality stability and insufficient diversity in the generated small-sample class images, failing to effectively solve the class imbalance problem. In summary, existing technologies struggle to achieve efficient and accurate image generation in medical scenarios such as esophageal endoscopy images, which require small samples and high generation quality, thus limiting the application of subsequent analysis of esophageal endoscopy images (such as lesion segmentation and lesion grading). Summary of the Invention

[0003] To address the aforementioned technical problems, this invention proposes an esophageal endoscopy image generation system and method based on an improved StyleGAN2-ADA network, which solves the problems of uneven sample categories and scarce data samples in medical images such as esophageal endoscopy.

[0004] The technical solution of the present invention is as follows:

[0005] An esophageal endoscopy image generation system based on an improved StyleGAN2-ADA network includes a generator and a discriminator; the generator includes a mapping network and a synthesis network; the discriminator includes a discriminator network.

[0006] The generator takes a random latent vector z as input, which is transformed into a style vector w through a mapping network. Then, it generates an image through hierarchical style modulation and progressive upsampling of the synthesis network. The discriminator extracts features through convolutional dimensionality reduction and outputs real and generated images. At the same time, it relies on an adaptive discriminator enhancement mechanism. The adaptive discriminator is used to dynamically adjust the image enhancement intensity according to the discriminator accuracy during training to adapt to small sample or uneven data scenarios and ensure training stability.

[0007] Preferably, the input to the mapping network is: a random noise vector z, a category condition vector c, and a mask feature vector m obtained by the mask feature extraction module, and the output of the mapping network is: a latent vector w.

[0008] Preferably, the generating network is used to convert the random noise vector z, the category condition vector c, and the mask feature vector m obtained by the mask feature extraction module into a style vector w through the mapping network, and then generate an image through hierarchical style modulation and progressive upsampling of the synthesis network.

[0009] The discriminant network is used to extract features through convolutional dimensionality reduction and output either real or generated results, or binary classification results. At the same time, relying on the adaptive discriminator enhancement mechanism, the image enhancement intensity is dynamically adjusted according to the accuracy of the discriminant network during training to adapt to scenarios with small samples or uneven data, thus ensuring training stability.

[0010] Preferably, a method for generating esophageal endoscopic images based on an improved StyleGAN2-ADA network includes the following steps:

[0011] Step S1: Method for multi-vector feature fusion of the mapping network;

[0012] Step S2: A method for using a multi-scale feature-guided auxiliary classifier on the discriminative network;

[0013] Step S3: In the generative network, calculate the potential spatial distance loss and the contrastive loss.

[0014] Preferably, step S1 includes the following steps:

[0015] Step S11: By preprocessing and extracting features from the masked lesion image, a masked feature vector m encoding the spatial morphology and location information of the lesion is obtained;

[0016] Step S12: In the generator's mapping network, the random noise vector z, the category condition vector c, and the mask feature vector m are concatenated and fused to generate a latent vector w containing category and lesion morphology information.

[0017] Preferably, step S2 includes the following steps:

[0018] Step S21: Extract features from the shallow, middle and deep layers of the discriminator: the shallow layer retains high-resolution texture details, the middle layer focuses on the local semantics of lesions with medium resolution, and the deep layer encodes the low-resolution global structure.

[0019] Step S22: A lightweight classifier is connected after each feature layer. This classifier uses a binary cross-entropy loss formula, the calculation formula of which is:

[0020]

[0021] Where p is the probability predicted by the classifier that the input image is a real image; y is the label, where y=1 for real images and y=0 for generated images;

[0022] The discriminator loss formula is:

[0023]

[0024] Where E represents expectation; It is the data distribution of real images. It is the data distribution for generating images. It is the probability predicted by the master discriminator for the real image x. It is the probability predicted by the main discriminator for the generated image g;

[0025] Step S23: The classifier outputs the binary classification results, namely the real and generated results. The loss of the main classifier and the loss of each auxiliary classifier are weighted and summed. The middle layer has the highest weight to enhance the semantic learning of lesions.

[0026] Preferably, step S3 includes the following steps:

[0027] Step S31: After the mapping network outputs w and before the synthesis network generates the image, style modulation and image generation are performed based on the latent style vector w. Simultaneously, latent spatial distance loss is combined to enhance the latent spatial representation of the few-sample class, thereby effectively balancing the generation ratio of samples from each class. The formula for calculating the latent spatial distance loss is:

[0028]

[0029] Where N is the batch sample size; The latent vector of the i-th sample generated by the generator; Let be the latent vector of the i-th true sample of the few-sample class; The square of the L2 norm is used to measure the spatial distance between two potential vectors.

[0030] Step S32: The global contrastive learning loss forces the generator to align with the true features from the perspective of feature distribution. It optimizes the model by constraining the distance between the two classes of samples in the feature space, reducing the intra-class feature distance of positive sample pairs and increasing the inter-class feature distance of negative sample pairs. This results in the clustering of similar features and clearer boundaries between dissimilar classes. The contrastive loss calculation formula is as follows:

[0031]

[0032] in, The contrastive loss function is used to measure the similarity between the features of the generated image and the features of the real image. N is the number of samples in the batch, Sim[i,j] represents the feature similarity between the i-th generated image and the j-th real image, and τ is the temperature coefficient, τ=0.1;

[0033] Step S33: Calculate the generator's total loss based on the latent spatial distance loss function and the contrastive loss. The calculation formula is as follows:

[0034]

[0035] in, For the adversarial losses of GANs; , These are the weight parameters.

[0036] The beneficial effects of the esophageal endoscopy image generation system and method based on the improved StyleGAN2-ADA network of this invention are as follows:

[0037] 1. This invention proposes an improved StyleGAN2-ADA network for generating esophageal endoscopy images. A mask feature vector and a category condition vector are introduced into the mapping network and concatenated with random noise vectors to generate a latent vector containing lesion information. Simultaneously, a latent spatial distance loss is embedded to constrain the generation distribution using the latent vectors of real samples. By utilizing multi-vector feature fusion to guide the generation process, the medical feature realism of the generated esophageal endoscopy images is effectively improved.

[0038] 2. This invention proposes a multi-scale feature-guided auxiliary classifier structure, which is embedded in a GAN discriminator to construct a multi-branch auxiliary supervision system. By adding lightweight classifiers to the shallow, middle, and deep feature layers of the discriminator, multi-scale feature supervision of the generated image is achieved. Each feature layer is followed by a classifier composed of convolutional dimensionality reduction and fully connected layers to output true / false judgment results. Finally, the loss of the main classifier and the losses of each auxiliary classifier are weighted and summed, with the middle layer having the highest weight to strengthen the semantic learning of lesions. This overcomes the limitation of traditional GAN ​​discriminators that rely solely on the final layer supervision and are unable to capture multi-level information of medical images, thus improving the accuracy of the generated image details and lesion semantics.

[0039] 3. This invention proposes a fusion mechanism of latent spatial distance loss and global contrast loss, embedded in the generator loss. The former measures the distance between the generated image and the real few-sample latent vectors, promoting distribution alignment to balance categories; the latter constrains the feature distribution of the generated image and the real image, narrowing the distance between similar categories and widening the distance between categories to enhance discriminative power. The two work synergistically to enable the generated image to possess both category diversity and lesion accuracy, providing a high-quality data source for downstream analysis. Attached Figure Description

[0040] To more clearly illustrate the purpose, design concept, and innovation of the esophageal endoscopy image generation system and method based on the improved StyleGAN2-ADA network proposed in this invention, the invention will be described in detail below with reference to the accompanying drawings and tables.

[0041] Figure 1 This is an overall framework diagram of the present invention.

[0042] Figure 2 This is a diagram of the mask feature extraction module of the present invention.

[0043] Figure 3 This is a block diagram of the auxiliary classifier design of the present invention. Detailed Implementation

[0044] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0045] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.

[0046] An esophageal endoscopy image generation system based on an improved StyleGAN2-ADA network includes a generator and a discriminator; the generator includes a mapping network and a synthesis network; the discriminator includes a discriminator network.

[0047] The generator takes a random latent vector z as input, which is transformed into a style vector w through a mapping network. Then, it generates an image through hierarchical style modulation and progressive upsampling of the synthesis network. The discriminator extracts features through convolutional dimensionality reduction and outputs real and generated images. At the same time, it relies on an adaptive discriminator enhancement mechanism. The adaptive discriminator is used to dynamically adjust the image enhancement intensity according to the discriminator accuracy during training to adapt to small sample or uneven data scenarios and ensure training stability.

[0048] The inputs to the mapping network in this implementation scheme are: random noise vector z, category condition vector c, and mask feature vector m obtained by the mask feature extraction module. The output of the mapping network is: latent vector w.

[0049] The generative network in this implementation scheme is used to transform the random noise vector z, the category condition vector c, and the mask feature vector m obtained by the mask feature extraction module into a style vector w through a mapping network, and then generate an image through hierarchical style modulation and progressive upsampling of the synthesis network.

[0050] The discriminant network is used to extract features through convolutional dimensionality reduction and output either real or generated results, or binary classification results. At the same time, relying on the adaptive discriminator enhancement mechanism, the image enhancement intensity is dynamically adjusted according to the accuracy of the discriminant network during training to adapt to scenarios with small samples or uneven data, thus ensuring training stability.

[0051] A method for generating esophageal endoscopic images based on an improved StyleGAN2-ADA network includes the following steps:

[0052] Step S1: Method for multi-vector feature fusion of the mapping network;

[0053] Step S2: A method for using a multi-scale feature-guided auxiliary classifier on the discriminative network;

[0054] Step S3: In the generative network, calculate the potential spatial distance loss and the contrastive loss.

[0055] Step S1 of this implementation plan includes the following steps:

[0056] Step S11: By preprocessing and extracting features from the masked lesion image, a masked feature vector m encoding the spatial morphology and location information of the lesion is obtained;

[0057] Step S12: In the generator's mapping network, the random noise vector z, the category condition vector c, and the mask feature vector m are concatenated and fused to generate a latent vector w containing category and lesion morphology information.

[0058] Step S2 of this implementation plan includes the following steps:

[0059] Step S21: Extract features from the shallow, middle and deep layers of the discriminator: the shallow layer retains high-resolution texture details, the middle layer focuses on the local semantics of lesions with medium resolution, and the deep layer encodes the low-resolution global structure.

[0060] Step S22: A lightweight classifier is connected after each feature layer. This classifier uses a binary cross-entropy loss formula, the calculation formula of which is:

[0061]

[0062] Where p is the probability predicted by the classifier that the input image is a real image; y is the label, where y=1 for real images and y=0 for generated images;

[0063] The discriminator loss formula is:

[0064]

[0065] Where E represents expectation; It is the data distribution of real images. It is the data distribution for generating images. It is the probability predicted by the master discriminator for the real image x. It is the probability predicted by the main discriminator for the generated image g;

[0066] Step S23: The classifier outputs the binary classification results, namely the real and generated results. The loss of the main classifier and the loss of each auxiliary classifier are weighted and summed. The middle layer has the highest weight to enhance the semantic learning of lesions.

[0067] Step S3 of this implementation plan includes the following steps:

[0068] Step S31: After the mapping network outputs w and before the synthesis network generates the image, style modulation and image generation are performed based on the latent style vector w. Simultaneously, latent spatial distance loss is combined to enhance the latent spatial representation of the few-sample class, thereby effectively balancing the generation ratio of samples from each class. The formula for calculating the latent spatial distance loss is:

[0069]

[0070] Where N is the batch sample size; The latent vector of the i-th sample generated by the generator; Let be the latent vector of the i-th true sample of the few-sample class; The square of the L2 norm is used to measure the spatial distance between two potential vectors.

[0071] Step S32: The global contrastive learning loss forces the generator to align with the true features from the perspective of feature distribution. It optimizes the model by constraining the distance between the two classes of samples in the feature space, reducing the intra-class feature distance of positive sample pairs and increasing the inter-class feature distance of negative sample pairs. This results in the clustering of similar features and clearer boundaries between dissimilar classes. The contrastive loss calculation formula is as follows:

[0072]

[0073] in, The contrastive loss function is used to measure the similarity between the features of the generated image and the features of the real image. N is the number of samples in the batch, Sim[i,j] represents the feature similarity between the i-th generated image and the j-th real image, and τ is the temperature coefficient, τ=0.1;

[0074] Step S33: Calculate the generator's total loss based on the latent spatial distance loss function and the contrastive loss. The calculation formula is as follows:

[0075]

[0076] in, For the adversarial losses of GANs; , These are the weight parameters.

[0077] When this implementation plan is implemented,

[0078] This invention relates to a method for generating esophageal endoscopy images based on an improved StyleGAN2-ADA network, primarily addressing the issues of uneven sample categories and scarce data samples in medical images such as esophageal endoscopy images. This method aims to expand the dataset by generating high-quality medical images, ensuring that the medical features of scarce categories can be fully learned in subsequent tasks (such as lesion segmentation and lesion grading). Based on the improved StyleGAN2-ADA model, a "multi-vector feature fusion" generation scheme is proposed. This scheme guides the generator to adjust the generation ratio of samples from each category while achieving category discrimination of unlabeled medical images, thereby achieving a balanced category distribution. A multi-scale feature-guided auxiliary classifier is added to the discriminator, providing multi-scale semantic supervision through a multi-branch classification head to optimize the feature space. A contrastive learning enhancement method is introduced into the generator to strengthen the category consistency and feature realism of the generated images. This method can automatically learn the visual features of sample categories, generating images with high realism and category representativeness, improving the poor performance of traditional data augmentation methods in medical scenarios, providing balanced and high-quality data source support for esophageal endoscopy image analysis, and validating its effectiveness through downstream tasks such as segmentation.

[0079] When this implementation plan is further implemented,

[0080] This invention proposes a scheme for generating esophageal endoscopic images based on an improved StyleGAN2-ADA model, the network structure of which is as follows: Figure 1 As shown, the core modules of the StyleGAN2-ADA model are the generator module and the discriminator module: the generator takes a random latent vector z as input, which is transformed into a style vector w through a mapping network, and then generates an image through hierarchical style modulation and progressive upsampling of the synthesis network; the discriminator extracts features through convolutional dimensionality reduction and outputs a binary classification result of "real / generated". At the same time, relying on the adaptive discriminator enhancement (ADA) mechanism, the image enhancement intensity is dynamically adjusted according to the discriminator accuracy during training to adapt to small sample or uneven data scenarios and ensure training stability.

[0081] To address the limitations of esophageal endoscopy image generation, such as insufficient medical feature targeting, uneven distribution of generated categories, and lack of multi-scale semantic supervision, this solution makes three key improvements to the StyleGAN2-ADA model: First, in the generator's mapping network, the random noise vector z, the category condition vector c, and the mask feature vector m obtained from the mask feature extraction module are fused and used as input to the mapping network. In the synthesis network, the latent vector w generated after fusion is used for style modulation and image generation, ensuring that the generated image satisfies both category attributes and possesses the morphological and locational features of real lesions. Second, a multi-scale feature-guided auxiliary classifier is added to the discriminator's loss function. Based on multiple inter-layer features output by the discriminator, a secondary discrimination of the image's authenticity is performed. Compared to relying solely on the single discrimination result output by the discriminator, this module optimizes the feature space distribution by deeply mining the discriminative value of shallow, intermediate, and deep features, enhancing the model's ability to distinguish between real and fake images, thereby improving the generator's learning accuracy of real image features. Finally, latent spatial distance loss and contrastive loss are introduced into the generator's loss function: the latent spatial distance loss calculates the Euclidean distance between the latent vectors generated by the generator and the latent vectors of the ground truth samples in the minority class, prompting the generator to generate more esophageal images that conform to the features of the minority class, thereby achieving balanced optimization for each class; the contrastive loss function is constructed by measuring the similarity between the generated image and the ground truth image in the feature space. With this mechanism, the generator is guided to generate samples that are closer to the ground truth images in terms of class features, effectively improving the quality and class consistency of the generated images and avoiding feature shift or blurring problems in the generated images.

[0082] Through the above improvements, the model can generate high-quality esophageal endoscopic images that conform to the target class distribution, thus providing strong support for alleviating the class imbalance problem in datasets. The specific technical details are described below:

[0083] Multi-vector feature fusion generation scheme

[0084] In the field of medical image analysis, such as esophageal endoscopy, there are problems such as the difficulty in accurately determining the category of unlabeled data and the uneven distribution of samples across categories. This leads to the generated medical images being unable to effectively serve subsequent tasks such as lesion segmentation and lesion grading. Existing methods using StyleGAN2-ADA to generate medical images rely solely on random noise and simple category labels, failing to fully extract key information such as lesion location and morphology contained in the masked segmentation image. Furthermore, they struggle to specifically enhance the representation of a small number of categories in the latent space, resulting in insufficient category diversity and medical feature realism in the generated images. To address this, this invention proposes a "multi-vector feature fusion" generation scheme, which involves preprocessing and feature extraction of the masked lesion image (the masked feature extraction image is shown in the figure below). Figure 2 As shown in the figure, a mask feature vector m encoding the spatial morphology and location information of the lesion is obtained; in the mapping network of the generator, the random noise vector z, the category condition vector c, and the mask feature vector m are concatenated and fused to generate a latent vector w containing category and lesion morphology information.

[0085] (2) Multi-scale feature-guided auxiliary classifier

[0086] The Multi-Scale Feature-Guided Auxiliary Classifier (MSFG-AC) is a multi-branch auxiliary supervision structure embedded in the GAN discriminator. By adding auxiliary classification heads to different feature layers (shallow, mid-layer, and deep) of the discriminator, it achieves multi-scale semantic supervision of the generated images. This structure is suitable for medical image generation tasks such as esophagoscopy, and can simultaneously enhance the learning of image texture details (shallow layer), local semantics of lesions (mid-layer), and global structure (deep layer).

[0087] Traditional GAN ​​discriminators only provide supervision signals through the final output layer, making it difficult to capture the multi-layered semantic information of medical images (such as esophageal mucosal texture and ulcer edges). To address this issue, this invention extracts features from the shallow, medium, and deep layers of the discriminator: the shallow layer preserves high-resolution texture details, the medium layer focuses on medium-resolution local semantics of lesions, and the deep layer encodes low-resolution global structures. Each feature layer is followed by a lightweight classifier (composed of convolutional dimensionality reduction and fully connected layers), which uses a binary classification cross-entropy loss formula as shown in Equation (4-1):

[0088] (4-1)

[0089] Where p is the probability predicted by the classifier that the input image is a real image; y is the label, where y=1 for real images and y=0 for generated images.

[0090] The formula for the auxiliary classifier is shown below:

[0091] (4-3)

[0092] (4-4)

[0093] (4-5)

[0094] Where E represents expectation; It is the data distribution of real images. It is the data distribution for generating images. It is a shallow auxiliary classifier. It is a mid-level auxiliary classifier. It is a deep auxiliary classifier.

[0095] The original discriminator loss formula is as follows:

[0096] (4-2)

[0097] in, It is the probability predicted by the master discriminator for the real image x. It is the probability predicted by the master discriminator for the generated image g.

[0098] The formula for the total loss of the discriminator is as follows:

[0099] (4-6)

[0100] in, , , The values ​​are 0.1, 0.5, and 0.3 respectively.

[0101] The classifier outputs a binary classification result (real / generated). Finally, the loss of the main classifier is weighted and summed with the losses of each auxiliary classifier (the main classifier outputs a global judgment based on the deepest features, while the auxiliary classifiers supplement local judgments at each scale). The middle layers have the highest weights, reinforcing the semantic learning of lesions. The flowchart for the design of the multi-scale feature-guided auxiliary classifier is shown below. Figure 3 As shown.

[0102] (3) Potential spatial distance loss and contrast loss

[0103] In the synthetic network, style modulation and image generation are performed based on the latent vector w. Simultaneously, latent spatial distance loss is combined to enhance the latent spatial representation of fewer sample classes, thereby effectively balancing the generation ratio of samples from each class. This ensures that the generated images possess both rich class diversity and accurate reproduction of the morphological and locational features of medical lesions, providing a high-quality and balanced data source for downstream intelligent medical image analysis tasks. The latent spatial distance loss formula is shown in equation (4-7):

[0104] (4-7)

[0105] Where N is the number of samples in the batch; The latent vector of the i-th sample generated by the generator; Let be the latent vector of the i-th true sample of the few-sample class; It is the square of the L2 norm, used to measure the spatial distance between two potential vectors.

[0106] In equation (4-7), the greater the distance between the generated vector and the true vector of the minority class, the greater the loss value. The backpropagator will push the generator to adjust the parameters so that the two vectors generated in the next round are closer, thereby aligning the generated vector of the minority class with the true distribution in the latent space.

[0107] Global contrastive learning loss forces the generator to align with real features from the perspective of feature distribution. It achieves optimization by constraining the distance between the two classes of samples in the feature space, reducing the intra-class feature distance of positive sample pairs and increasing the inter-class feature distance of negative sample pairs. This results in the clustering of similar features and clear boundaries between dissimilar classes. The loss calculation formula is shown in Equation (4-8):

[0108] (4-8)

[0109] in, The contrastive loss function is used to measure the similarity between the features of the generated image and the features of the real image; N is the number of samples in the batch; Sim[i,j] represents the feature similarity between the i-th generated image and the j-th real image; τ is the temperature coefficient (controlling the similarity weight), and in this invention, τ=0.1.

[0110] The formula for the total generator loss is shown in equation (4-9):

[0111] (4-9)

[0112] in, For the adversarial losses of GANs; , Weight parameters (usually taken as...) [0.1-1.0]、 [1.0-5.0]. In equation (4-3), the potential spatial distance loss, the contrast loss, and the loss of the original generator constitute the total generator loss. This is achieved by adjusting the weight parameters. By balancing the contribution of different losses, a more realistic image can be generated.

Claims

1. An esophageal endoscopic image generation system based on an improved StyleGAN2-ADA network, characterized in that, It includes a generator and a discriminator; the generator includes a mapping network and a synthesis network; the discriminator includes a discriminator network; The generator takes a random latent vector z as input, which is transformed into a style vector w through a mapping network. Then, it generates an image through hierarchical style modulation and progressive upsampling of the synthesis network. The discriminator extracts features through convolutional dimensionality reduction and outputs real and generated images. At the same time, it relies on an adaptive discriminator enhancement mechanism. The adaptive discriminator is used to dynamically adjust the image enhancement intensity according to the discriminator accuracy during training to adapt to small sample or uneven data scenarios and ensure training stability.

2. The esophageal endoscopy image generation system based on the improved StyleGAN2-ADA network according to claim 1, characterized in that, The inputs to the mapping network are: a random noise vector z, a category condition vector c, and a mask feature vector m obtained by the mask feature extraction module. The output of the mapping network is: a latent vector w.

3. The esophageal endoscopy image generation system based on the improved StyleGAN2-ADA network according to claim 1, characterized in that, The generating network is used to convert random noise vector z, category condition vector c, and mask feature vector m obtained by the mask feature extraction module into style vector w through a mapping network, and then generate an image through hierarchical style modulation and progressive upsampling of the synthesis network. The discriminant network is used to extract features through convolutional dimensionality reduction and output either real or generated binary classification results. At the same time, relying on the adaptive discriminator enhancement mechanism, the image enhancement intensity is dynamically adjusted according to the accuracy of the discriminant network during training to adapt to scenarios with small samples or uneven data and ensure training stability.

4. A method for generating esophageal endoscopic images based on an improved StyleGAN2-ADA network, characterized in that, Includes the following steps: Step S1: Method for multi-vector feature fusion of the mapping network; Step S2: A method for using a multi-scale feature-guided auxiliary classifier on the discriminative network; Step S3: In the generative network, calculate the potential spatial distance loss and the contrastive loss.

5. The method for generating esophageal endoscopic images based on the improved StyleGAN2-ADA network according to claim 4, characterized in that, Step S1 includes the following steps: Step S11: By preprocessing and extracting features from the masked lesion image, a masked feature vector m encoding the spatial morphology and location information of the lesion is obtained; Step S12: In the generator's mapping network, the random noise vector z, the category condition vector c, and the mask feature vector m are concatenated and fused to generate a latent vector w containing category and lesion morphology information.

6. The method for generating esophageal endoscopic images based on the improved StyleGAN2-ADA network according to claim 4, characterized in that, Step S2 includes the following steps: Step S21: Extract features from the shallow, middle and deep layers of the discriminator respectively: the shallow layer retains high-resolution texture details, the middle layer focuses on the local semantics of lesions with medium resolution, and the deep layer encodes the low-resolution global structure. Step S22: A lightweight classifier is connected after each feature layer. This classifier uses the binary cross-entropy loss formula, which is calculated as follows: ; Where p is the probability predicted by the classifier that the input image is a real image; y is the label, y=1 for real images and y=0 for generated images; The discriminator loss formula is: ; Where E represents the expectation; It is the data distribution of real images. It is the data distribution for generating images. It is the probability predicted by the master discriminator for the real image x. It is the probability predicted by the main discriminator for the generated image g; Step S23: The classifier outputs a binary classification result, namely the real and generated results. The loss of the main classifier and the loss of each auxiliary classifier are weighted and summed. The middle layer has the highest weight to enhance the semantic learning of lesions.

7. The method for generating esophageal endoscopic images based on the improved StyleGAN2-ADA network according to claim 4, characterized in that, Step S3 includes the following steps: Step S31: After the mapping network outputs w and before the synthesis network generates the image, style modulation and image generation are performed based on the latent style vector w. Simultaneously, latent spatial distance loss is combined to enhance the latent spatial representation of the few-sample class, thereby effectively balancing the generation ratio of samples from each class. The formula for calculating the latent spatial distance loss is: ; Where N is the batch sample size; The latent vector of the i-th sample generated by the generator; Let be the latent vector of the i-th true sample of the few-sample class; The square of the L2 norm is used to measure the spatial distance between two potential vectors. Step S32: The global contrastive learning loss forces the generator to align with the true features from the perspective of feature distribution. Optimization is achieved by constraining the distance between the two classes of samples in the feature space, reducing the intra-class feature distance of positive sample pairs and increasing the inter-class feature distance of negative sample pairs. This results in the clustering of similar features and clearer boundaries between dissimilar classes. The contrastive loss function is calculated as follows: ; in, The contrastive loss function is used to measure the similarity between the features of the generated image and the features of the real image. N is the number of samples in the batch, Sim[i,j] represents the feature similarity between the i-th generated image and the j-th real image, and τ is the temperature coefficient, τ=0.1; Step S33: Calculate the generator's total loss based on the latent spatial distance loss function and the contrastive loss function. The calculation formula is as follows: ; in For the adversarial losses of GANs; , These are the weight parameters.

Citation Information

Cited By

  • Insulator defect generation method based on small sample

    CN122116053A

  • A Method and System for Small Sample Magnetic Anomaly Data Augmentation and Boundary Recognition Based on StyleGAN2-ADA

    CN122391665B