A GAN-based unbalanced medical image classification method, system, and electronic device
By using the LEGAN model to detect and enhance sparse samples within classes, and combining this with an information entropy constraint to generate diverse data, the problem of intra-class imbalance in medical image classification is solved, thereby improving the model's classification performance and data quality.
Patent Information
- Application Number
- CN202311112350.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-29
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2043-08-29
AI Technical Summary
Existing technologies for medical image classification suffer from imbalanced data issues between and within classes, leading to a decline in the performance of deep learning models, especially poor classification results for minority classes. Traditional methods struggle to effectively generate high-quality and diverse within-class samples.
An improved GAN model (LEGAN) based on Local Outlier Factor (LOF) and information entropy is adopted. By detecting sparse intra-class samples and performing affine transformations, combined with information entropy constraints, more diverse intra-class samples are generated, a balanced training dataset is constructed, and the ResNet18 model is used for classification.
It effectively improves the classification performance of imbalanced medical images, generates high-quality and diverse medical images, solves the problem of imbalanced distribution of samples within classes, and improves the robustness and classification accuracy of the model.
Smart Images

Figure CN117173464B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer applications, and more specifically, to a GAN-based method, system, and electronic device for non-equilibrium medical image classification. Background Technology
[0002] In recent years, the application of deep learning technology in biomedical image processing has made rapid progress. Convolutional Neural Network (CNN) models for image classification, in particular, have received widespread research and application. CNNs and their derived architectures often require large amounts of labeled data for model training, but acquiring labeled data is time-consuming, labor-intensive, and prone to errors. In real-world medical images, the acquisition of labeled data heavily relies on the subjective experience and professional level of physicians and is also easily affected by image quality. Therefore, acquiring labeled image data is even more difficult, easily leading to problems such as data scarcity, insufficient annotation, and severe class imbalance.
[0003] Imbalanced data is one of the main reasons for the degraded performance of deep learning models. Because traditional CNN models and their derivatives are designed for balanced data, they often bias the decision boundary towards the minority class when faced with imbalanced data, resulting in poor classification performance for the minority class. Therefore, machine learning algorithms based on the assumption of balanced data contradict the imbalanced data situation in real-world applications, causing deep learning models to tend to learn the majority class while ignoring the minority class, ultimately leading to a significant performance drop. Based on this, the imbalanced data problem caused by small datasets and limited labeled samples is a major challenge in medical image classification.
[0004] Image augmentation techniques are used to augment minority class samples in imbalanced datasets and are a common method to address insufficient sample size. Traditional image augmentation methods are numerous; for example, they can improve image quality, correct brightness or contrast, or augment data through geometric transformations such as rotation, cropping, scaling, and deformation. However, in medical images, adjusting brightness or performing cropping and deformation alters the information in the original data, leading to distortion in the augmented data. Therefore, their impact is very limited. Another classic oversampling scheme is the SMOTE model-based sample synthesis method. The SMOTE model is a linear interpolation-based oversampling method that generates new samples by randomly sampling a point on a line segment between sample points. However, when generating new samples near the decision boundary, the classification boundary may become more blurred. Furthermore, when a large number of samples need to be generated, new samples may be repeatedly generated, and the quality of the generated data is often unsatisfactory.
[0005] Generative Adversarial Networks (GANs) have garnered significant attention in academia due to their exceptional data synthesis capabilities and have been widely applied in fields such as industry, medicine, and security. In medical imaging, GANs are used to learn the underlying real-world distribution from a limited set of images, and then generate more diverse medical image data based on this learned distribution. Therefore, GAN sample generation can effectively mitigate the impact of data scarcity on medical data analysis.
[0006] However, when using GAN methods to generate samples to solve imbalanced data classification problems, it is necessary to consider not only inter-class imbalance but also intra-class imbalance. It is worth noting that in medical data, although multiple samples belong to the same category, there is often diversity among them. For example, in medical dermatology testing data, there are seven major categories, but the data types within each category exhibit different characteristics. When using GANs to learn the distribution of such data, it is difficult to learn the distribution of minority class samples within a class. Furthermore, using a GAN model that has only learned the distribution of majority class samples within a class for data augmentation will increase intra-class data bias. Although GAN-based inter-class sample augmentation schemes have been extensively studied, very few have considered the problem of intra-class data imbalance.
[0007] In current research, most researchers prefer to directly use GANs to augment images and then use the augmented dataset to train the model. However, as mentioned above, in imbalanced data classification, inter-class imbalance is not the only factor causing a decline in classifier performance. An effective sample augmentation mechanism should be to use synthetic data to cover the underrepresented parts of the original minority class sample distribution. That is, the focus of generating data should be on addressing the sparse and underrepresented parts of the intra-class samples. Based on this, this invention proposes an improved GAN model (LEGAN) that balances inter-class samples while placing greater emphasis on the diversity of intra-class samples. Summary of the Invention
[0008] To address the aforementioned technical problems, this invention proposes a GAN model structure based on Local Outlier Factor (LOF) and information entropy, namely LEGAN. The LEGAN model focuses on solving the intra-class pattern collapse problem caused by intra-class imbalance. This invention integrates two strategies to generate more diverse intra-class samples, thereby mitigating pattern collapse. First, a GAN model training mechanism based on Local Outlier Factor (LOF) is proposed. LOF is used to detect intra-class imbalanced sparse and dense sample points, and affine transformations are performed on sparse sample points to enhance the diversity of sample data and features. Then, dense samples and enhanced sparse samples are jointly trained on LEGAN, enabling it to effectively focus on the sample distribution in sparse regions. Second, a decentralization constraint term based on information entropy is also proposed. This method uses information entropy to measure the diversity of generated samples and feeds the result back to the generator to incentivize it to evolve towards a better direction.
[0009] According to a first aspect of the present invention, a GAN-based non-equilibrium medical image classification method is provided, comprising:
[0010] Step S1: Collect image data from the medical field to construct an imbalanced dataset;
[0011] Step S2: Divide the collected dataset into a training sample set and a test sample set;
[0012] Step S3: Construct the initial GAN model. Use the training set to pre-train the completed GAN model and obtain the initial weights.
[0013] Step S4: Construct the LOF model and use the LOF algorithm to separate dense and sparse region samples in each class of data;
[0014] Step S5: Use data augmentation schemes to augment sparse samples within the class;
[0015] Step S6: Mix the enhanced sparse samples and the original dense samples to construct a new training dataset;
[0016] Step S7: Build the LEGAN model and train it using the new training dataset.
[0017] Step S8: Use the trained LEGAN model to generate small sample data in the imbalanced data so that the original training set reaches a balanced state.
[0018] Step S9: Construct a ResNet18 model and train the ResNet18 model using the balanced dataset obtained in step S8.
[0019] Step S10: Input test data and perform performance testing on the trained ResNet18 model.
[0020] Based on the above technical solution, the present invention can also be improved as follows.
[0021] Optionally, the initial GAN model constructed in step S3 is selected as the SNGAN model; the construction of the initial GAN model, using the pre-trained GAN model on the training set to obtain the initial weights, further includes:
[0022] First, the SNGAN model is pre-trained using the complete data to obtain the optimal initial weights. Then, each class of samples is trained, and finally, the weights are transferred.
[0023] Optionally, the objective function of the SNGAN model is set as follows:
[0024]
[0025] The generator's input is random noise z, which follows a Gaussian distribution p. z (z); The generator outputs pseudo-samples G(z), and the discriminator takes pseudo-samples G(z) and real samples x as inputs, and outputs the discrimination probabilities D(G(z)) and D(x), where x is data from the training sample set and z is noise samples randomly sampled from a Gaussian distribution.
[0026] Optionally, step S4 uses a local anomaly factor to detect sparse samples within a class; the construction of the LOF model and the use of the LOF algorithm to separate dense and sparse region samples in each class of data further includes:
[0027] Before performing sparse point detection, an autoencoder model is trained and used to extract high-dimensional latent space features from the original image. The extracted high-dimensional latent space features are then used as input to the LOF algorithm.
[0028] Optionally, in step S5, flipping and rotating are used to amplify sparse samples within a class.
[0029] Optionally, in step S7, reconstruction loss and information entropy loss are used to improve the original SNGAN model; training the LEGAN model using the new training dataset includes:
[0030] Train a classifier C to distinguish between dense and sparse samples within a class;
[0031] Calculate the number n of dense and sparse samples in the training batch. d and n s ;
[0032] The information entropy score is fed back to the generator as an additional constraint.
[0033] L1 loss is used to measure the difference in reconstruction between the generated sample and the original sample.
[0034] Optionally, the amount of data generated for the small sample in step S8 is obtained based on the data of the class with the largest amount of data.
[0035] Optionally, the convolutional neural network model constructed in step S9 is a classification model with pre-trained weights.
[0036] According to a second aspect of the present invention, a GAN-based non-equilibrium medical image classification system is provided, comprising:
[0037] The data acquisition module is used to collect image data in the medical field to construct an imbalanced dataset; the collected dataset is divided into a training sample set and a test sample set.
[0038] The first building module is used to build the initial GAN model. The completed GAN model is pre-trained using the training set to obtain the initial weights.
[0039] The second building module is used to construct an outlier detection LOF model and use the LOF algorithm to separate dense and sparse region samples in each class of data; use data augmentation schemes to augment sparse samples within the class; and mix the augmented sparse samples with the original dense samples to construct a new training dataset.
[0040] The third building module is used to build the LEGAN model. It trains the LEGAN model using a new training dataset and uses the trained LEGAN model to generate small sample data from the imbalanced dataset to balance the original training set.
[0041] The fourth building module is used to build a convolutional neural network model, train the convolutional neural network model using the obtained balanced dataset, and input test data to perform performance testing on the trained convolutional neural network model.
[0042] According to a third aspect of the present invention, an electronic device is provided, including a memory and a processor, the processor being configured to execute a computer program stored in the memory to implement the steps of the above-described GAN-based nonequilibrium medical image classification method.
[0043] The technical effects and advantages of this invention are as follows:
[0044] This invention proposes a data augmentation scheme based on LEGAN, which can not only effectively generate high-quality and diverse medical images, but also effectively improve the classification performance of imbalanced medical images.
[0045] This invention proposes a sparse sample point detection method based on LOF (List of Elements), which divides intra-class samples into dense and sparse samples. Before training the GAN model, an affine transformation is performed on the sparse samples to enhance their diversity, thereby enabling better capture of the distribution of sparse sample points during training. This solves the problem that traditional GAN models cannot effectively focus on the generation of intra-class sparse samples.
[0046] Furthermore, this invention proposes a decentralized constraint term based on information entropy, which can improve the diversity of samples within a class. By introducing information entropy to measure the diversity of samples generated by the GAN model during training, the measurement results are fed back to the generator to constrain it to evolve in a better direction.
[0047] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description
[0048] Figure 1 A flowchart of a GAN-based non-equilibrium medical image classification method is provided in this embodiment of the invention;
[0049] Figure 2 This is a flowchart of the LEGAN data augmentation process provided in an embodiment of the present invention;
[0050] Figure 3 This is a structural diagram of the SNGAN model provided in an embodiment of the present invention;
[0051] Figure 4 A schematic diagram of sparse sample detection and affine transformation based on LOF provided for an embodiment of the present invention;
[0052] Figure 5 A schematic diagram illustrating the calculation process of k-distance and reach-distance provided in an embodiment of the present invention;
[0053] Figure 6 The structure diagram of the EGAN model based on information entropy provided by this invention;
[0054] Figure 7 This is a structural diagram of the ResNet18 model provided by the present invention;
[0055] Figure 8 This invention provides a schematic diagram of the physical structure of an electronic device. Detailed Implementation
[0056] 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 some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] Understandably, given the deficiencies in the prior art, this invention proposes a GAN-based non-equilibrium medical image classification method. Figure 1 and Figure 2 The example illustrates a flowchart of a GAN-based non-equilibrium medical image classification method, see below. Figure 1 and Figure 2 As shown, the method includes the following steps:
[0058] Step S1, Imbalanced Data Acquisition: Construct an imbalanced dataset by acquiring image data from the medical field;
[0059] In this embodiment, the datasets used are three publicly available lightweight medical image datasets: BloodMNIST, OrgancMNIST, and PathMNIST. These three datasets are derived from MedMNIST V2, a standardized biomedical dataset similar to the MNIST dataset. All images in the three datasets were preprocessed to a 28x28 pixel size. PathMNIST is a dataset for predicting the survival rate of colorectal cancer histological sections, containing 9 classes. OrganCMNIST is a dataset for classifying body organs, containing 11 classes. BloodMNIST is a dataset based on individual normal cells, divided into 8 classes.
[0060] Step S2: Divide the collected dataset into a training sample set and a test sample set;
[0061] It should be noted that the training sample set is used for training the LEGAN model and the ResNet18 classifier model, while the test sample set is used for testing the final ResNet18 classification model.
[0062] Step S3: Construct the initial SNGAN model. Use the training set to pre-train the completed SNGAN model and obtain the initial weights.
[0063] Considering that the collected data contains small sample data that cannot effectively support the subsequent training of the LEGAN model, we first use the complete data to pre-train SNGAN to obtain the optimal initial weights, and then transfer the weights to the subsequent LEGAN model.
[0064] Furthermore, the initial SNGAN model structure constructed in step S3 is as follows: Figure 3 As shown. In the SNGAN model, the generator's input is random noise z, which follows a Gaussian distribution p. z (z). The generator outputs generated samples G(z). The discriminator takes generated samples G(z) and real samples x as input, and outputs the discrimination probabilities D(G(z)) and D(x). Traditional adversarial generative networks have a problem: if the discriminator D is too powerful, the generator G will exhibit vanishing gradients, making the loss function unable to converge; if the generator G is trained too well, the discriminator D will exhibit exploding gradients. Based on this, SNGAN uses the Wasserstein distance as a metric for the cost of generated data versus original data. After forming a joint distribution of training samples and generated samples, the lower bound of the expected value is taken for optimization. The objective function is set as follows:
[0065]
[0066] Where x represents data from the training sample set; z represents noise samples randomly sampled from a Gaussian distribution. To prevent gradient explosion and gradient vanishing, an additional gradient penalty term is added to force the discriminator D to satisfy the continuity constraint of the loss 1-Lipschitz function, thereby enhancing the controllability of the gradient. The gradient penalty formula is as follows:
[0067]
[0068]
[0069] Where GP is the gradient penalty term. yes The distribution, It is the gradient of the discriminator. Indicates the distribution along the true data P r and the generated data distribution P g The sampling is performed on the straight line between the given and undefined points. ε is a random parameter from the real domain, with a value between 0 and 1. Based on this, the loss function of SNGAN can be defined as follows:
[0070]
[0071] Where λ is the gradient penalty coefficient. Furthermore, SNGAN controls the gradient to be less than or equal to 1 by normalizing the weight matrix W. The normalized weight matrix can be expressed as follows:
[0072]
[0073] By normalizing the W weight matrix to an expression with a spectral norm always equal to 1, the gradient can be controlled to be always less than or equal to 1, thereby further improving the problems of unstable GAN training and mode collapse.
[0074] Step S4: Construct an LOF model and use the LOF algorithm to separate the dense region and sparse region samples in each class of data;
[0075] Furthermore, in step S4, the local outlier factor (LOF) is used to detect the sparse samples within the class. LOF is a density-based outlier detection method that can better detect the sparse sample points within the class. In addition, to enhance the diversity of the sparse samples within the class, affine transformation is used to enhance the sparse samples, so that the GAN can better focus on the generation of such samples. Before performing sparse point detection, first train an autoencoder model, and use the encoder En to extract the high-dimensional latent space features of the original image. The extracted latent space features are used as the input of the LOF algorithm, and the specific algorithm design is as follows;
[0076] Calculate the k-distance: Given a data object p and any positive integer k, calculate the set of k-nearest neighbors of p. The set composed of k data objects of p is denoted as N k (p). The data object that is the k-th nearest to p is denoted as q k , then the k-distance of p is the distance from p to q, denoted as Dist k (p). For any q ∈ N k (p), then there is Dist(p,q) ≤ Dist k (p) holds. Figure 4 (a) shows a schematic diagram of k-distance calculation when k = 6.
[0077] Reachable distance: Given data objects p and q, then the reachable distance of p relative to q is expressed as follows:
[0078] Dist r (p,q) = max{Dist(p,q), Dist k (q)}
[0079]
[0080] Figure 4 (b) shows a schematic diagram of reachable distance calculation for two data objects q1 and q2. It can be seen from the figure that the distance from p to q1 is far, so the reachable distance is the actual distance Dist(p,q1). The distance from p to q2 is close, that is, Dist(p,q2) < Dist6(q2), so the reachable distance of p and q2 is Dist6(q2).
[0081] Local reachability density: The local reachability density of a data object p can be defined as the density of p's k nearest neighbors N. k The reciprocal of the average reachability distance of (p). The local reachability density Lrd of P. k (p) can be expressed using an equation as follows:
[0082]
[0083] The formula for local reachability density shows that the smaller the mean reachability distance of p relative to its k nearest neighbors, the greater the local density.
[0084] Local outliers: The local outliers of data object p are represented as:
[0085]
[0086] As can be seen from the formula, LOF p Let be the mean of the ratios of the local reachability density of all k nearest neighbors of p to the reachability density of p. Therefore, LOF p The closer the value is to 1, the closer the local density of object p is to its k nearest neighbors, and the smaller the anomaly of p. LOF p A value less than 1 indicates that object p is located in a highly dense region. Conversely, LOF... p The larger the value, the greater the probability that p is a sparse point. Based on this, the focus of this invention is to screen out points with a large LOF, that is, sparse points among the in-class samples.
[0087] Step S5: Use traditional data augmentation techniques to augment sparse samples within the class;
[0088] Furthermore, in step S5, two traditional data augmentation methods, flipping and rotation (90°, 180° and 270°), are used to amplify the sparse samples within the class detected in step S4. Figure 5 The process of intra-class sparse sample detection and enhancement in steps 4 and 5 is illustrated visually. The sparse sample detection process is detailed in step 4 and can be summarized as follows: The encoder extracts high-dimensional hidden layer features from each class of training data; then, the LOF algorithm is used to further divide intra-class samples into dense and sparse samples based on the extracted high-dimensional hidden layer features. Since the purpose of detecting sparse samples is to increase their number, thereby reducing the distribution difference between them and dense samples and better training the subsequent LEGAN model, we use affine transformation to enhance the sparse samples. Specifically, in this invention, we use one flip and three rotations (90°, 180°, and 270°) to enhance the intra-class sparse samples, thus achieving intra-class sparse sample enhancement.
[0089] Step S6: Mix the enhanced sparse samples and the original dense samples to construct a new training dataset;
[0090] Step S7: Construct the LEGAN model and train it using the new training set.
[0091] Furthermore, in step S7, the LEGAN model was constructed based on SNGAN. The structural design of the LEGAN model is as follows: Figure 6 As shown, LEGAN is a novel model proposed in this invention, a further improvement upon SNGAN. A new additional constraint term is designed on top of the original SNGAN loss function to enhance the diversity of intra-class samples. This constraint term uses the information entropy of the samples generated by LEGAN as the constraint metric. Information entropy is related to the probability of an event occurring; the higher the probability of an event, the lower the information entropy. Therefore, it is desirable that intra-class data generation does not always occur in a single data pattern, but rather generates different data patterns. Reflected in intra-class data generation, this means avoiding an extremely high probability of generating one type of data while having an extremely low probability of generating another; the information entropy of the generated data should be maximized. Specifically, during the LEGAN model training process, the samples generated by the generator should simultaneously contain samples from dense regions and samples from sparse regions. Therefore, information entropy is used to measure the generation of these two types of samples.
[0092] First, a classifier C is trained to distinguish between dense and sparse samples within a class. Since dense and sparse samples have clear classification boundaries, the trained classifier can effectively identify these two classes. In this invention, ResNet18 is used as the classification model. The ResNet18 model structure is as follows... Figure 7 As shown, cross-entropy loss is used as the objective function of ResNet18, and its equation is as follows:
[0093]
[0094] Where y ik and p ik Let represent the true label and predicted probability of the i-th sample belonging to the k-th class, respectively.
[0095] During LEGAN training, a trained classifier is used to classify dense samples x. d and sparse samples x s Then calculate the number n of dense and sparse samples in a training batch. d and n s Therefore, the generation probabilities of dense and sparse samples in a batch can be obtained as follows:
[0096]
[0097] Ultimately, the generation probabilities of two types of samples can be used to derive the information entropy of the samples in a batch. The functional expression for measuring information entropy is shown below:
[0098]
[0099] As can be seen from the formula for information entropy, when only samples from dense regions are generated, the information entropy L... e The initial value is 0. As more diverse samples from sparse regions are generated, the information entropy gradually increases. Based on this, the information entropy score is fed back to the generator as an additional constraint, forcing the generator to produce more diverse data.
[0100] Furthermore, to generate higher quality sample data, this invention incorporates a reconstruction loss. The reconstruction loss is designed using L1 loss. Specifically, L1 loss is used to measure the reconstruction difference between the generated samples and the original samples. The design of the reconstruction loss is as follows:
[0101]
[0102] Where x and x′ represent the original data and the generated data, respectively. The loss of the generator in EGAN is ultimately defined as follows:
[0103] L G =L g -λ1L e +λ2L h
[0104] Where L g Let λ1 and λ2 represent the loss of the original SNGAN generator, respectively. e and L h The weight.
[0105] Step S8: Use the trained LEGAN model to generate small sample data from the imbalanced data so that the original training set reaches a balanced state.
[0106] It should be noted that the amount of data generated for the small sample in step S8 is based on the data of the class with the largest amount of data among the multiple classes, so that the original unbalanced data can eventually reach a balanced state.
[0107] Step S9: Construct a ResNet18 model and train it using the balanced dataset obtained in S8.
[0108] It should be noted that the specific model structure of ResNet18 is as follows: Figure 7As shown, the ResNet18 model constructed in step S9 is a classification model with pre-trained weights. Using this model for training in step S8 to obtain balanced data enhances the model's robustness and improves the final classification performance. A key feature of ResNet18 is the introduction of the concept of residual blocks, used to address the vanishing and exploding gradient problems in deep convolutional neural networks. In residual blocks, shortcut connections directly connect the input to the output, allowing the network to learn residual information, thus improving feature extraction and processing.
[0109] Step S10: Input test data and perform performance testing on the trained ResNet18 model.
[0110] In summary, the embodiments of this invention propose a data augmentation scheme based on LEGAN, which can not only effectively generate high-quality and diverse medical images, but also effectively improve the classification performance of imbalanced medical images.
[0111] According to a second aspect of the embodiments, the present invention also provides a GAN-based non-equilibrium medical image classification system, comprising:
[0112] The data acquisition module is used to collect image data in the medical field to construct an imbalanced dataset; the collected dataset is divided into a training sample set and a test sample set.
[0113] The first building module is used to build the initial GAN model. The completed GAN model is pre-trained using the training set to obtain the initial weights.
[0114] The second building module is used to construct an outlier detection LOF model and use LOF to separate dense and sparse region samples in each class of data; it uses data augmentation schemes to augment sparse samples within each class; and it mixes the augmented sparse samples with the original dense samples to construct a new training dataset.
[0115] The third building module is used to build the LEGAN model. It trains the LEGAN model using a new training dataset and uses the trained LEGAN model to generate small sample data from the imbalanced dataset to balance the original training set.
[0116] The fourth building module is used to build a convolutional neural network model, train the convolutional neural network model using the obtained balanced dataset, and input test data to perform performance testing on the trained convolutional neural network model.
[0117] It is understood that the GAN-based non-equilibrium medical image classification system provided by the present invention corresponds to the GAN-based non-equilibrium medical image classification method provided in the foregoing embodiments. The relevant technical features of the GAN-based non-equilibrium medical image classification system can be referred to the relevant technical features of the GAN-based non-equilibrium medical image classification method, and will not be repeated here.
[0118] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8 As shown, the electronic device includes a processor 810, a communications interface 820, a memory 830, and a communication bus 840. The processor 810, communications interface 820, and memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions from the memory 830 to execute the steps of the GAN-based unbalanced medical image classification method described above.
[0119] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0120] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0121] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0122] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A non-equilibrium medical image classification method based on GAN, characterized in that, The method includes the following steps: Step S1: Collect image data from the medical field to construct an imbalanced dataset; Step S2: Divide the collected dataset into a training sample set and a test sample set; Step S3: Construct the initial GAN model. Use the training set to pre-train the completed GAN model and obtain the initial weights. Step S4: Construct an outlier detection LOF model and use the LOF algorithm to separate dense and sparse region samples in each class of data; including: using local anomaly factor to detect sparse samples within the class; before performing sparse point detection, first train an autoencoder model, use the encoder to extract high-dimensional latent space features of the original image, and use the extracted high-dimensional latent space features as input to the LOF algorithm. Step S5: Use data augmentation schemes to augment sparse samples within the class; Step S6: Mix the enhanced sparse samples and the original dense samples to construct a new training dataset; Step S7, construct the LEGAN model, using reconstruction loss and information entropy loss to improve the original SNGAN model, and train the LEGAN model using a new training dataset, including: Train a classifier C to distinguish between dense and sparse samples within a class; Calculate the number of dense and sparse samples in the training batch. and ; The information entropy score is fed back to the generator as an additional constraint. L1 loss is used to measure the difference in reconstruction between the generated sample and the original sample; Step S8: Use the trained LEGAN model to generate small sample data in the imbalanced data to bring the original training set to a balanced state. Step S9: Construct a ResNet18 model and train the ResNet18 model using the obtained balanced dataset; Step S10: Input test data and perform performance testing on the trained ResNet18 model.
2. The GAN-based non-equilibrium medical image classification method according to claim 1, characterized in that, In step S3, the initial GAN model is selected as the SNGAN model; the construction of the initial GAN model, using the pre-trained GAN model on the training set to obtain the initial weights, further includes: First, the SNGAN model is pre-trained using the complete data to obtain the optimal initial weights. Then, each class of samples is trained, and finally, the weights are transferred.
3. The non-equilibrium medical image classification method based on GAN according to claim 2, characterized in that, The objective function of the SNGAN model is set as follows: The generator's input is random noise z, which follows a Gaussian distribution. The generator's output data consists of pseudo-samples. The discriminator uses spurious samples The input consists of a real sample x and the output consists of the discriminant probabilities D(G(z)) and D(x), where x is data from the training sample set and z is a noise sample randomly sampled from a Gaussian distribution.
4. The non-equilibrium medical image classification method based on GAN according to claim 1, characterized in that, In step S5, flipping and rotating are used to amplify sparse samples within a class.
5. The GAN-based non-equilibrium medical image classification method according to claim 1, characterized in that, In step S8, the amount of data generated for the small sample is based on the largest type of data.
6. The non-equilibrium medical image classification method based on GAN according to claim 1, characterized in that, The convolutional neural network model constructed in step S9 is a classification model with pre-trained weights.
7. A non-equilibrium medical image classification system based on GAN, characterized in that, include: The data acquisition module is used to collect image data in the medical field to construct an imbalanced dataset; the collected dataset is divided into a training sample set and a test sample set. The first building module is used to build the initial GAN model. The completed GAN model is pre-trained using the training set to obtain the initial weights. The second building module is used to construct an outlier detection LOF model and use the LOF algorithm to separate dense and sparse region samples in each class of data. This includes: using local anomaly factors to detect sparse samples within a class; training an autoencoder model before sparse point detection; using the encoder to extract high-dimensional latent space features from the original image; using the extracted high-dimensional latent space features as input to the LOF algorithm; and using data augmentation schemes to augment sparse samples within a class, mixing the augmented sparse samples with the original dense samples to construct a new training dataset. The third building block, used to construct the LEGAN model, improves the original SNGAN model using reconstruction loss and information entropy loss, and trains the LEGAN model using a new training dataset, including: Train classifier C to distinguish between dense and sparse samples within a class; calculate the number of dense and sparse samples in the training batch. and The information entropy score is fed back to the generator as an additional constraint; L1 loss is used to measure the reconstruction difference between the generated samples and the original samples; and the trained LEGAN model is used to generate small sample data in the imbalanced data to balance the original training set. The fourth building module is used to build the ResNet18 model, train the ResNet18 model using the obtained balanced dataset, and input test data to perform performance testing on the trained ResNet18 model.
8. An electronic device, characterized in that, It includes a memory and a processor, wherein the processor is used to execute a computer program stored in the memory to implement the steps of a GAN-based nonbalanced medical image classification method as described in any one of claims 1-6.
Citation Information
Patent Citations
Dynamic grid optimization-based LOF (Local Outlier Factor) clustering data anomaly point detection method and detection system
CN107256237A
Unbalanced hyperspectral image classification method
CN114882368A