Chest disease screening and classifying system based on self-supervised learning

The strongly enhanced chest disease screening and classification system based on self-supervised learning solves the problems of tiny lesions and category imbalance in chest X-rays, and improves the model's recognition ability and diagnostic accuracy.

CN120597974APending Publication Date: 2025-09-05TAIYUAN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510965018.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-14
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

Existing technologies have the risk of misdiagnosis or missed diagnosis in chest X-ray diagnosis, especially for small diffuse features and class imbalance problems, which leads to poor performance of the model during training and diagnosis.

Method used

A strongly enhanced chest disease screening and classification system based on self-supervised learning is adopted. Through a strong data augmentation module, a strongly enhanced contrastive learning network, nearest neighbor contrast loss and distribution difference minimization loss, combined with a hierarchical instance-level contrastive learning framework, the model's sensitivity to tiny lesions and its ability to identify rare diseases are improved.

Benefits of technology

It effectively alleviates the model's difficulty in identifying tiny lesions and the problem of category imbalance, improves the model's stability and generalization ability, and improves the accuracy of screening and classification of chest diseases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120597974A_ABST
    Figure CN120597974A_ABST
Patent Text Reader

Abstract

The invention discloses a chest disease screening and classification system based on self-supervised learning. The chest disease screening and classification system comprises a strong enhancement chest disease screening and classification module and a hierarchical instance-level chest disease screening and classification module. The hierarchical instance-level chest disease screening and classification model performs comparative learning at a hierarchical level and an instance level, and combines a diversified small-batch strategy and a virtual negative sample generation module to ensure that virtual samples which are similar to but not completely the same as real negative samples are dynamically generated while each class can be fully learned in model training iteration; and a more stable and effective training signal is provided for comparison training. Experimental results show that the chest disease screening and classification system based on self-supervised learning provided by the invention shows excellent screening performance and robustness on public and private data sets, and provides reliable technical support for intelligent diagnosis of medical images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of medical image processing algorithms in computer vision, and in particular to a chest disease screening and classification system based on self-supervised learning. Background Art

[0002] Chest diseases, including pneumonia, tuberculosis, pneumoconiosis, and lung cancer, are among the leading health issues worldwide, leading to high mortality and disability rates. Early detection and accurate diagnosis of these diseases are crucial to improving patient survival. However, due to the complex symptoms of chest diseases, traditional diagnostic methods such as physical examinations and laboratory tests often rely on imaging studies as a key basis. Chest X-rays are widely used in clinical diagnosis due to their low cost, ease of acquisition, and low radiation dose. Chest X-rays remain the core of screening, diagnosis, and management of various chest diseases.

[0003] The interpretation of chest X-rays has a high professional threshold and currently relies primarily on manual interpretation by experienced radiologists. Due to the complexity and diversity of chest disease manifestations, the potential for multiple diseases to coexist, and factors such as differences in physician clinical experience and high workload, the risk of misdiagnosis or missed diagnosis is common during actual diagnosis and treatment. Therefore, there is an urgent need to develop intelligent auxiliary diagnosis systems to assist radiologists in improving the efficiency and accuracy of image reading, thereby enabling rapid and accurate evaluation of medical images.

[0004] In recent years, deep learning technology has developed rapidly, especially models with convolutional neural networks (CNN) as the core have achieved remarkable results in the field of image processing and analysis. CNN has also been widely used in medical image modalities. When a large amount of data and manually annotated labels are available, convolutional neural networks can automatically learn to approximate the relationship between data and its labels, and are in a leading position in many medical image analysis applications. Computer-aided diagnosis based on deep learning has also made significant progress in the field of medical image analysis. Using deep learning models such as convolutional neural networks to automatically analyze chest X-rays can not only improve the detection rate of diseases, but also reduce the workload of radiologists and reduce human errors.

[0005] In traditional computer vision tasks, the success of deep learning models like CNNs relies heavily on large-scale labeled datasets. However, this reliance also presents significant challenges. Manually labeling data is extremely costly, especially for tasks involving complex categories, fine-grained classification, or specialized knowledge, such as medical image analysis. The data labeling process is even more expensive, time-consuming, and labor-intensive, typically requiring significant human input. Human labelers can become fatigued from long-term, high-intensity work, which can affect data quality. Furthermore, manual labeling is subjective, and different labelers may produce different labeling results due to differences in understanding, leading to inconsistent or even erroneous data and compromising the model's generalization capabilities.

[0006] To reduce reliance on manual labeling while improving the learning capabilities of models, self-supervised learning (SSL) has received widespread attention in recent years. Self-supervised learning is a data-driven learning method that does not require manual labeling. It constructs supervisory signals by mining inherent structural information from unlabeled data. This method enables the model to learn efficiently without the need for external labeled information. Self-supervised learning has been widely applied to various tasks in the field of computer vision, demonstrating excellent versatility and potential. On multiple benchmarks, it has demonstrated performance approaching or even exceeding that of supervised learning. With the continuous development of self-supervised learning technology, it is expected to become an important direction in the field of deep learning, providing new solutions for computer-aided diagnosis of chest diseases in chest X-ray images.

[0007] In addition, the imaging features of many chest diseases on chest X-rays exhibit a small, diffuse distribution, resulting in low contrast between the lesions and normal tissue, which makes manual diagnosis difficult. For example, lesions in pneumoconiosis, interstitial lung disease, early-stage tuberculosis, and certain types of pneumonia may appear as grid-like, patchy, or diffuse shadows, and the morphology of lesions varies greatly between patients. Some lesions, such as those in early-stage pneumoconiosis, may only appear as fuzzy, small, diffuse areas in the lung field, which can be easily missed by radiologists when reading the films.

[0008] Therefore, how to improve the model's sensitivity to such tiny diffuse features is one of the problems that the computer-aided diagnosis system urgently needs to solve.

[0009] Chest X-ray data also suffers from a significant class imbalance problem. In actual medical imaging data, chest X-ray data for healthy individuals is typically far greater than data for patients with chest diseases. Furthermore, within disease categories, the number of samples for different diseases can also be extremely unbalanced. For example, common bacterial pneumonia is relatively abundant in the imaging databases of medical institutions, while imaging data for pneumoconiosis, rare types of lung cancer, or certain genetic chest diseases is extremely scarce. This imbalance in data distribution not only causes the model to favor the majority class during training, reducing its ability to recognize minority diseases, but can also result in insufficient generalization in actual applications, making it difficult to accurately diagnose rare cases. Therefore, how to utilize limited minority class data to improve the model's ability to recognize rare diseases is a key challenge in medical imaging analysis. Summary of the Invention

[0010] Based on the above ideas, the present invention proposes a chest disease screening and classification system based on self-supervised learning, which provides reliable technical support for intelligent diagnosis of medical images.

[0011] In order to achieve the above purpose, the following technical solutions are adopted: A self-supervised learning-based strongly enhanced chest disease screening and classification system includes a strongly enhanced chest disease screening and classification module and a hierarchical instance-level chest disease screening and classification module. The strongly enhanced chest disease screening and classification module includes a strong data augmentation module, a strongly enhanced contrastive learning network, a nearest neighbor contrast loss, and a distribution difference minimization loss: The strong data augmentation module combines weak and strong augmentation to generate weak and strong augmentation samples, which are used to generate more complex semantic information in the image. The following augmentation types were considered: X-axis shearing, Y-axis shearing, X-axis translation, Y-axis translation, rotation, auto-contrast, inversion, equalization, exposure, toning, contrast, brightness, and sharpness. Unlike natural images, large-scale cropping operations in chest X-rays can easily lose information about certain subtle lesions, leading to incorrect learning by the model. Therefore, large-scale cropping operations are not included in the transformation types.

[0012] Specifically, the weak enhancement part is generated by following the data enhancement strategy in most existing contrastive learning methods, that is, the above enhancement methods are applied randomly in sequence to generate weakly enhanced images. For strong data enhancement, the following three types of data enhancement operations are considered: (1) Geometric enhancement methods such as rotation, translation, and shearing, which perturb the spatial structure of the image to make the model more deformable, thereby improving the ability to recognize lesions at different angles, positions, or scales. Due to differences in patient body shape, posture, respiratory status, and imaging angles, there are often obvious geometric differences between images. By introducing such geometric perturbations, the model's dependence on the spatial position of the lesion can be alleviated, and the model's robustness on data of different quality can be improved. (2) Non-geometric enhancement methods such as automatic contrast, histogram equalization, brightness adjustment, and sharpening, the transformation of the image in pixel or color space can simulate different imaging conditions and effectively deal with image quality differences or imaging equipment differences. For example, some lesions such as early pneumoconiosis, mild lung marking thickening, or subtle pleural thickening often appear as low-contrast, blurred edges, and difficult-to-distinguish feature areas in the original chest X-ray film. The application of non-geometric enhancement technology can enhance image details and improve the visibility of weak feature areas, thereby improving the model's detection performance for small and diffuse lesions. (3) Color-related enhancement operations such as contrast, brightness, and color saturation adjustment can also simulate a variety of filming conditions to a certain extent, helping to alleviate the domain shift problem caused by different equipment, imaging parameters, and hospital environments. In order to achieve the purpose of strong enhancement, the amplitude of all enhancement operations is set to be larger than that of traditional weak enhancement strategies, aiming to maximize the distortion of the image while ensuring that the image is basically recognizable, so that the model can learn more robust representations during training. When performing strong enhancement on an image, an enhancement is randomly selected from the data enhancement pool and applied to the image with a probability of 0.5. This process is repeated five times to achieve the effect of strong enhancement on the image.

[0013] In the first stage of the strong enhancement contrast learning network, the original samples are processed through the strong data enhancement module mentioned above to generate strong and weak enhancement samples. In the second stage, the strong and weak enhancement sample sets generated in the first stage are used as input, and then the feature representation is extracted through ResNet-50 to map the input image to a high-dimensional feature space. An automatically updated support set is constructed, and the nearest neighbor algorithm is used in the support set to select positive and negative samples. Finally, the training process is optimized by introducing the distribution difference minimization loss, and self-supervised contrast classification is performed to form the final classification model. Unlike previous work that only used enhanced views of the same sample as positive samples, the present invention will learn representations by bringing the enhanced views of the same sample closer to their nearest neighbors in the feature space.

[0014] In order to obtain the most representative nearest neighbors, the present invention uses a support set to retain the embedding of a subset of the dataset in memory. The support set is implemented as a first-in-first-out queue to ensure the diversity of samples in the support set. This allows the latest samples to be continuously added to the support set, while older samples are gradually replaced, maintaining its dynamic update characteristics. The support set is initialized to a dimension of A random matrix, where is the size of the queue, which determines the number of samples stored in the support set. is the size of the embedding. The size of the support set is kept large enough to approximate the full dataset distribution in the embedding space. The support set is dynamically updated at the end of each training epoch: at the end of a training epoch, the support set is updated by taking embeddings and concatenate them to the end of the queue to update the support set, where is the size of a mini-batch. This mechanism ensures that the support set always contains the latest sample distribution information and avoids representation degradation caused by prolonged sample retention. Unlike the memory bank in MoCo v2, which continuously replaces the oldest samples with new ones during training, some features may lag behind the current training state due to its update method based on a momentum encoder, resulting in inaccurate representation of negative samples. The support set of the present invention, on the other hand, introduces new samples and removes old ones during each training round. This ensures that the model always uses the latest data for comparative learning, improving convergence stability. For positive sample pairs, the present invention uses the support set for nearest neighbor search to retrieve positive samples and form positive pairs with strongly enhanced samples from the same image. Unlike the memory bank, which uses stored features as negative samples, the support set of the present invention searches for its nearest neighbor samples in the support set as additional positive samples. These samples form positive pairs with the sample's strongly enhanced sample, enhancing the semantic consistency of the model when processing strongly enhanced views. Specifically, unlike the traditional memory bank, the support set not only stores negative sample features but is also specifically used to retrieve positive samples. After each training sample is augmented, the model further ensures semantic consistency by retrieving the most similar sample from the support set. Directly using strongly augmented samples for comparison can cause drift in the representation space, making it difficult for the model to converge stably. The nearest neighbor matched samples provide a mechanism similar to an "anchor point," enabling a smoother training process and helping the model gradually adapt to stronger augmentations during training.

[0015] For negative samples, the method of this invention is similar to traditional SimSLR. It still obtains negative samples from a small batch and forms negative sample pairs with weakly enhanced samples of the original samples, allowing the model to still learn global discriminative information. Strong enhancement may cause excessive feature deformation, leading to the misclassification of samples of the same class as negative samples. Using weakly enhanced samples for negative sample matching can reduce this risk and improve the stability of contrastive learning.

[0016] In contrastive learning, the commonly used loss function is InfoNCE loss, which aims to bring different views of the same instance closer in the representation space while moving away from the feature vectors of other instances. Its mathematical formula is as follows:

[0017] in and Features extracted from different enhanced views of the same image, is a negative sample, is the temperature coefficient used to control the gradient range of the contrast loss. However, it is obviously not feasible to directly use this loss function to train strongly enhanced sample data. Therefore, this paper optimizes the loss design based on InfoNCE to adapt to the complexity of medical images and alleviate the distribution shift problem caused by strong enhancement.

[0018] This paper improves the positive sample selection method of traditional contrastive learning by introducing the nearest neighbor idea. It searches for the nearest neighbor samples in the support set as additional positive samples. The improved loss is as follows:

[0019] in and Features extracted from different enhanced views of the same image, is the negative sample in the mini-batch, is the temperature parameter, the nearest neighbor operator It is defined by the following formula:

[0020] in is the embedding vector of the current sample, It is a collection of features that supports centralized storage. Represents candidate features.

[0021] Similar to InfoNCE, each embedding vector is L2 normalized before calculating the loss, and L2 normalized before the nearest neighbor calculation. The final loss function is obtained by calculating the average loss of the mini-batch data:

[0022] In order to further avoid feature drift caused by strong enhancement, the present invention starts from the distribution of relative similarity and proposes a distribution difference minimization loss to learn from stronger enhancement.

[0023] Current definition is the ideal distribution of features, which represents the semantic similarity between positive and negative samples, and is the actual distribution of network learning. In the past, in contrastive learning networks, since it was impossible to accurately measure the ideal distribution, Considered as a one-hot distribution, that is, the positive sample satisfies , negative samples satisfy , which means that the model will only blindly bring positive samples closer and push negative samples away, while ignoring the complex semantic relationships between different types of samples. Based on this, the present invention compares the probability and variance of strong and weak augmented positive and negative sample pairs in the feature space. The results show that the initial similarity distribution of strong and weak augmented queries is roughly the same under the same pre-trained network, but after training with the comparative method, the introduction of strong augmentation will reduce network performance.

[0024] This means that the model can use the relative similarity distribution of weakly enhanced queries to guide the representation learning of strongly enhanced queries without directly overfitting the representation of strongly enhanced queries to the positive sample targets, thereby learning richer semantic features from stronger enhancements. The distribution divergence minimization loss function is defined as follows:

[0025] in, is the feature extracted from the weakly enhanced view, is the feature representation of the nearest neighbor sample, and Denote the probability distributions of weakly enhanced samples and nearest neighbor samples, respectively. The optimization goal of this loss is to minimize the difference between these two distributions, making the distribution of nearest neighbor samples and original samples more consistent in the feature space. This effectively prevents feature drift caused by strongly enhanced samples, ensuring that the enhanced features retain the semantic information of the original samples during training, and stabilizes the nearest neighbor search effect, making the positive samples matched in the support set more reliable and avoiding mismatches caused by feature shift after strong enhancement.

[0026] Finally, the loss function of the model combines the above two contrast losses and is defined as follows:

[0027] in, Responsible for learning the nearest neighbor samples and enhancing the similarity of views to improve the utilization of semantic information, Responsible for aligning the similarity distribution of the enhanced view and the nearest neighbor samples, preventing the feature drift problem caused by strong enhancement, and improving the stability of the model. is a hyperparameter that controls the contribution of the distribution difference minimization loss to the total loss.

[0028] The hierarchical instance-level chest disease screening and classification module includes a hierarchical instance-level contrastive learning framework, a diversified mini-batch mechanism, and an adaptive virtual negative sample generation module: The hierarchical instance-level contrastive learning framework enhances the model's feature representation capabilities by simultaneously performing instance-level and category-level contrastive learning (HILC). At the instance level, it emphasizes the similarities and differences between samples, enabling the model to accurately learn individual features. At the category level, by comparing the feature distributions of the majority and minority classes across a wider category space, the model ensures that it captures more representative category features, allowing the network to better learn the multiple subcategories of each class. This hierarchical contrastive learning approach enables the model to not only accurately identify subtle differences in individual samples but also globally optimize inter-category discrimination. Furthermore, the present invention introduces a virtual negative sample generation module that generates virtual negative samples similar to real negative samples and dynamically adapts to the statistical distribution within a mini-batch to ensure the diversity of negative samples. This allows the model to obtain more stable and effective negative sample information without increasing data acquisition costs. The diversified mini-batch mechanism optimizes the sample distribution within the mini-batch through balanced sub-class sampling and diversified sampling based on the feature space, enabling the model to more fully learn the feature variation patterns of the majority class. Furthermore, the diversified mini-batch mechanism provides a more stable feature foundation for the generation of virtual negative samples, further enhancing the effectiveness of contrastive learning.

[0029] In order to ensure that the mini-batch contains as many subclasses of the majority class as possible, rather than over-concentrating on a certain subclass, the diversified mini-batch mechanism introduces subclass balanced sampling. Specifically, for a majority class, assuming it contains multiple subclasses , when constructing a mini-batch, it will ensure that all subclasses are included as much as possible, rather than just random sampling. For example: if traditional mini-batch sampling may select , then the optimized sampling method will ensure are evenly selected. This is achieved through dynamic weight adjustment:

[0030] in Is a subclass The probability of being selected, is the number of samples of the subclass in the current mini-batch. If a subclass has been sampled multiple times, its probability of subsequent selection is reduced to ensure that other subclasses have more opportunities to be sampled. λ is a smoothing parameter that prevents sampling failures when a subclass is completely undersampled. This strategy ensures that samples within a mini-batch are not overly concentrated in a single subclass, but rather cover as many subclasses as possible, improving the balance of the training data.

[0031] In order to ensure that the majority class subclasses sampled in the previous step are sufficiently distributed and diverse in the feature space, it is necessary to perform diversified sampling based on the feature space. First, calculate the mean of the samples in the current mini-batch :

[0032] Where N is the number of samples in the current mini-batch, is the first By calculating the covariance matrix of samples in a small batch You can measure the distribution of samples in the feature space within a small batch:

[0033] This ensures that the samples within a mini-batch come from multiple different feature clusters rather than being concentrated in a single local area. This mechanism ensures the balance and distribution diversity of samples within a mini-batch through subclass-balanced sampling and diversified sampling based on the feature space, enabling the model to learn more comprehensive features of the majority class, improving the model's generalization ability across different sub-classes while avoiding learning bias caused by uneven distribution of factor classes.

[0034] The adaptive virtual negative sample generation module relies on the feature distribution of the majority class samples in the current mini-batch, rather than randomly generating meaningless negative samples. Its calculation formula is as follows:

[0035] in is the generated virtual negative sample, is standard Gaussian noise, ensuring that the generated virtual negative samples have a certain degree of randomness. and They represent the mean of the majority class samples in the mini-batch and the standard deviation of the majority class samples in the mini-batch, respectively, to ensure the rationality of the distribution of negative samples. is the adaptive perturbation factor of the virtual negative sample, which controls the generation intensity of the virtual negative sample. It can be regarded as the radius of generating virtual samples in the feature space, so that the generation of virtual negative samples can better adapt to different stages of model training. Its calculation formula is as follows:

[0036] in is the initial perturbation strength of the virtual negative sample, It is a hyperparameter used to control the dynamic adjustment rate of generating virtual negative samples. is the mean change of the current mini-batch statistical information, which is used to measure whether the feature distribution of mini-batch sampling has changed significantly. Its calculation formula is as follows:

[0037] The beneficial effects of the present invention are: The method of the present invention constructs a chest disease screening and classification system based on self-supervised learning. The invention proposes a contrastive learning framework based on a strong enhancement strategy to address the problem of difficulty in extracting features such as small and diffuse chest disease lesion areas in chest X-ray films. It effectively enhances the model's ability to maintain semantic consistency, effectively alleviates the problem of feature drift caused by strong data enhancement, and improves the model's stability and generalization ability under complex lesion conditions. A hierarchical instance-level contrastive learning framework is constructed to address the widespread problem of extreme class imbalance in chest X-ray image data. It effectively alleviates the adverse effects of uneven class distribution on model performance, enhances the diversity of negative samples, and provides more stable and effective training signals without increasing data acquisition costs. The application of self-supervised learning in the field of medical image analysis provides a new solution to the problem of class imbalance. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is a strongly enhanced chest disease screening and classification model based on self-supervised learning of the present invention; Figure 2 This is a hierarchical instance-level chest disease screening and classification model based on self-supervised learning in the present invention; Figure 3 The strong data enhancement module of the present invention; Figure 4 For the diversified small batch mechanism of the present invention; Figure 5 The adaptive virtual negative sample generation module of the present invention; Figure 6 Comparison of the probability and variance of strong-enhanced and weak-enhanced positive and negative sample pairs in the feature space; Figure 7 This is a comparison of the performance of the strong enhancement chest disease screening and classification model of the present invention on weak and strong enhancement; Figure 8 The performance comparison of the proposed enhanced chest disease screening and classification model with different methods on three datasets is presented. Figure 9Comparison of the AUCs of the proposed enhanced chest disease screening and classification model with different methods on three datasets. Figure 10 Comparison of the convergence process of loss functions of the enhanced chest disease screening and classification models of the present invention; Figure 11 t-SNE visualization of the virtual negative samples of the present invention; Figure 12 The performance of the hierarchical instance-level chest disease screening and classification model based on self-supervised learning of the present invention is compared with other models on different datasets; DETAILED DESCRIPTION

[0039] The present invention is described in detail below with reference to specific embodiments.

[0040] A chest disease screening and classification system based on self-supervised learning, including a strongly enhanced chest disease screening and classification model and a hierarchical instance-level chest disease screening and classification model. The strongly enhanced chest disease screening and classification model system includes a strong data augmentation module, a strongly enhanced contrastive learning network, a nearest neighbor contrast loss, and a distribution difference minimization loss: including the following: The weak enhancement part of A1 follows the data enhancement strategy in most existing contrastive learning methods to generate weakly enhanced images, that is, the above enhancement methods are applied randomly in sequence to generate weakly enhanced images. For strong data enhancement, the following three types of data enhancement operations are considered: (1) Geometric enhancement methods such as rotation, translation, and shearing. By perturbing the spatial structure of the image, the model has stronger deformation invariance, thereby improving the recognition ability of lesions at different angles, positions, or scales. Due to differences in patient body shape, body position, respiratory status, and imaging angle, there are often obvious geometric differences between images. By introducing such geometric perturbations, the model's dependence on the spatial position of the lesion can be alleviated, and the model's robustness on data of different quality can be improved. (2) Non-geometric enhancement methods such as automatic contrast, histogram equalization, brightness adjustment, and sharpening. The transformation of the image in pixel or color space can simulate different imaging conditions and effectively deal with image quality differences or imaging equipment differences. For example, some lesions such as early pneumoconiosis, mild lung marking thickening, or subtle pleural thickening often appear as low-contrast, blurred edges, and difficult-to-distinguish feature areas in the original chest X-ray film. The application of non-geometric enhancement technology can enhance image details and improve the visibility of weak feature areas, thereby improving the model's detection performance for small and diffuse lesions. (3) Color-related enhancement operations such as contrast, brightness, and color saturation adjustment can also simulate a variety of filming conditions to a certain extent, helping to alleviate the domain shift problem caused by different equipment, imaging parameters, and hospital environments. In order to achieve the purpose of strong enhancement, the amplitude of all enhancement operations is set to be larger than that of traditional weak enhancement strategies, aiming to maximize the distortion of the image while ensuring that the image is basically recognizable, so that the model can learn more robust representations during training. When performing strong enhancement on an image, an enhancement is randomly selected from the data enhancement pool and applied to the image with a probability of 0.5. This process is repeated five times to achieve the effect of strong enhancement on the image.

[0041] A2 takes the generated strong and weak enhancement sample sets as input, then extracts their feature representations through ResNet-50 and maps the input image into a high-dimensional feature space. It then constructs an automatically updated support set, uses the nearest neighbor algorithm to select positive and negative samples within the support set, and finally optimizes the training process by introducing a distribution difference minimization loss, performing self-supervised comparative classification to form the final classification model. Unlike using only enhanced views of the same sample as positive samples, this invention learns representations by bringing the enhanced views of the same sample closer to their nearest neighbors in the feature space. In order to obtain the most representative nearest neighbors in step A2, the present invention uses the support set to retain the embedding of the dataset subset in memory.

[0042] The specific steps of step A2 are as follows: A21. Support set settings The support set is implemented as a first-in-first-out queue to ensure the diversity of samples in the support set, so that the latest samples can be continuously added to the support set, while the older samples are gradually replaced, maintaining its dynamic update characteristics. The support set is initialized to a dimension of A random matrix, where is the size of the queue, which determines the number of samples stored in the support set. is the size of the embedding. The size of the support set is kept large enough to approximate the full dataset distribution in the embedding space.

[0043] A22. Support set updates The support set is dynamically updated at the end of each training round: at the end of the training round, the support set is obtained from the current training step. embeddings and concatenate them to the end of the queue to update the support set, where is the size of a mini-batch. This mechanism ensures that the support set always contains the latest sample distribution information and avoids the problem of representation degradation caused by long sample retention time. Unlike the memory library of MoCo v2, the memory library continuously replaces the oldest samples with new samples during training, but because its update method is based on the momentum encoder, some features may lag behind the current training state, resulting in inaccurate representation of negative samples. The support set of the present invention introduces new samples and removes old samples in each training round, which can ensure that the model always uses the latest data for comparative learning and improves convergence stability.

[0044] A23. Positive and negative sample selection For positive sample pairs, the present invention utilizes the support set of the nearest neighbor search to retrieve positive samples and form positive pairs with strongly enhanced samples from the same image. The support set of the present invention differs from a memory bank that uses stored features as negative samples. For each sample, the model searches the support set for its nearest neighbor samples as additional positive samples, forming positive pairs with the sample's strongly enhanced counterpart to enhance the model's semantic consistency when processing strongly enhanced views. Specifically, the support set differs from traditional memory banks in that it not only stores negative sample features but is also specifically used to retrieve positive samples. After each training sample is enhanced, the model further ensures semantic consistency of the enhanced sample by retrieving the most similar sample from the support set. Directly using strongly enhanced samples for comparison can cause drift in the representation space, making it difficult for the model to converge stably. The nearest neighbor matched samples provide a mechanism similar to an "anchor point," enabling a smoother training process and helping the model gradually adapt to stronger enhancements during training. For negative samples, the present invention's method, similar to traditional SimSLR, still obtains negative samples from a minibatch and forms negative pairs with the weakly enhanced counterparts of the original sample, allowing the model to still learn global discriminative information. Strong enhancement may cause excessive deformation of features, leading to misclassification of samples of the same class as negative samples. Using weakly enhanced samples for negative sample matching can reduce this risk and improve the stability of contrastive learning.

[0045] A3 optimizes the loss function The specific steps of step A3 are as follows: A31. Nearest Neighbor Contrastive Loss In contrastive learning, the commonly used loss function is InfoNCE loss, which aims to bring different views of the same instance closer in the representation space while moving away from the feature vectors of other instances. Its mathematical formula is as follows:

[0046] in and Features extracted from different enhanced views of the same image, is a negative sample, is the temperature coefficient used to control the gradient range of the contrast loss. However, it is obviously not feasible to directly use this loss function to train strongly enhanced sample data. Therefore, this paper optimizes the loss design based on InfoNCE to adapt to the complexity of medical images and alleviate the distribution shift problem caused by strong enhancement.

[0047] This paper improves the positive sample selection method of traditional contrastive learning by introducing the nearest neighbor idea. It searches for the nearest neighbor samples in the support set as additional positive samples. The improved loss is as follows:

[0048] in and Features extracted from different enhanced views of the same image, is the negative sample in the mini-batch, is the temperature parameter, the nearest neighbor operator It is defined by the following formula:

[0049] in is the embedding vector of the current sample, It is a collection of features that supports centralized storage. Represents candidate features.

[0050] Similar to InfoNCE, each embedding vector is L2 normalized before calculating the loss, and L2 normalized before the nearest neighbor calculation. The final loss function is obtained by calculating the average loss of the mini-batch data:

[0051] A32. Distribution Difference Minimization Loss In order to further avoid feature drift caused by strong enhancement, the present invention starts from the distribution of relative similarity and proposes a distribution difference minimization loss to learn from stronger enhancement.

[0052] Current definition is the ideal distribution of features, which represents the semantic similarity between positive and negative samples, and is the actual distribution of network learning. In the past, in contrastive learning networks, since it was impossible to accurately measure the ideal distribution, Considered as a one-hot distribution, that is, the positive sample satisfies , negative samples satisfy , which means that the model will only blindly bring positive samples closer and push negative samples away, while ignoring the complex semantic relationships between different types of samples. Based on this, the present invention compares the probability and variance of strong and weak augmented positive and negative sample pairs in the feature space. The results show that the initial similarity distribution of strong and weak augmented queries is roughly the same under the same pre-trained network, but after training with the comparative method, the introduction of strong augmentation will reduce network performance.

[0053] This means that the model can use the relative similarity distribution of weakly enhanced queries to guide the representation learning of strongly enhanced queries without directly overfitting the representation of strongly enhanced queries to the positive sample targets, thereby learning richer semantic features from stronger enhancements. The distribution divergence minimization loss function is defined as follows:

[0054] in, is the feature extracted from the weakly enhanced view, is the feature representation of the nearest neighbor sample, and Denote the probability distributions of weakly enhanced samples and nearest neighbor samples, respectively. The optimization goal of this loss is to minimize the difference between these two distributions, making the distribution of nearest neighbor samples and original samples more consistent in the feature space. This effectively prevents feature drift caused by strongly enhanced samples, ensuring that the enhanced features retain the semantic information of the original samples during training, and stabilizes the nearest neighbor search effect, making the positive samples matched in the support set more reliable and avoiding mismatches caused by feature shift after strong enhancement.

[0055] Finally, the loss function of the model combines the above two contrast losses and is defined as follows:

[0056] in, Responsible for learning the nearest neighbor samples and enhancing the similarity of views to improve the utilization of semantic information, Responsible for aligning the similarity distribution of the enhanced view and the nearest neighbor samples, preventing the feature drift problem caused by strong enhancement, and improving the stability of the model. is a hyperparameter that controls the contribution of the distribution difference minimization loss to the total loss.

[0057] A4 hierarchical instance-level contrastive learning framework The hierarchical instance-level contrastive learning framework enhances the model's feature representation capabilities by simultaneously performing instance-level and category-level contrastive learning (HILC). At the instance level, it emphasizes the similarities and differences between samples, enabling the model to accurately learn individual features. At the category level, it compares the feature distributions of the majority and minority classes across a wider category space, ensuring that the model captures more representative category features, allowing the network to better learn the multiple subcategories of each class. This hierarchical contrastive learning approach enables the model to not only accurately identify subtle differences in individual samples but also globally optimize inter-category discrimination. Furthermore, the present invention introduces a virtual negative sample generation module that generates virtual negative samples similar to real negative samples and dynamically adapts the statistical distribution within a mini-batch to ensure negative sample diversity. This allows the model to obtain more stable and effective negative sample information without increasing data acquisition costs. The diversified mini-batch mechanism optimizes the sample distribution within the mini-batch through balanced sub-class sampling and diversified sampling based on the feature space, enabling the model to more fully learn the feature variation patterns of the majority class. At the same time, the diversified mini-batch mechanism also provides a more stable feature basis for the generation of virtual negative samples, further improving the effectiveness of contrastive learning.

[0058] A5 Diversified Small Batch Mechanism In order to ensure that the mini-batch contains as many subclasses of the majority class as possible, rather than being overly concentrated on a certain subclass, the diversified mini-batch mechanism introduces subclass balanced sampling.

[0059] A51 Specifically, for a majority class, assuming it contains multiple subclasses , when constructing a mini-batch, it will ensure that all subclasses are included as much as possible, rather than just random sampling. For example: if traditional mini-batch sampling may select , then the optimized sampling method will ensure are evenly selected. This is achieved through dynamic weight adjustment:

[0060] in Is a subclass The probability of being selected, is the number of samples of the subclass in the current mini-batch. If a subclass has been sampled multiple times, its probability of subsequent selection is reduced to ensure that other subclasses have more opportunities to be sampled. λ is a smoothing parameter that prevents sampling failures when a subclass is completely undersampled. This strategy ensures that samples within a mini-batch are not overly concentrated in a single subclass, but rather cover as many subclasses as possible, improving the balance of the training data.

[0061] A52 To ensure that the majority of the subclasses of the small batch sampled in the previous step are sufficiently distributed and diverse in the feature space, it is necessary to perform diversified sampling based on the feature space. First, calculate the mean of the samples in the current small batch :

[0062] Where N is the number of samples in the current mini-batch, is the first By calculating the covariance matrix of samples in a small batch You can measure the distribution of samples in the feature space within a small batch:

[0063] This ensures that the samples within a mini-batch come from multiple distinct feature clusters, rather than being concentrated in a single local area. This mechanism ensures the balance and distribution diversity of samples within a mini-batch through balanced subclass sampling and diversified sampling based on the feature space. This allows the model to learn more comprehensive features of the majority class, improving its generalization across different subclasses while avoiding learning bias caused by uneven distribution of factor classes.

[0064] A6. Adaptive Virtual Negative Sample Generation Module The adaptive virtual negative sample generation module relies on the feature distribution of the majority class samples in the current mini-batch, rather than randomly generating meaningless negative samples. Its calculation formula is as follows:

[0065] in is the generated virtual negative sample, is standard Gaussian noise, ensuring that the generated virtual negative samples have a certain degree of randomness. and They represent the mean of the majority class samples in the mini-batch and the standard deviation of the majority class samples in the mini-batch, respectively, to ensure the rationality of the distribution of negative samples. is the adaptive perturbation factor of the virtual negative sample, which controls the generation intensity of the virtual negative sample. It can be regarded as the radius of generating virtual samples in the feature space, so that the generation of virtual negative samples can better adapt to different stages of model training. Its calculation formula is as follows:

[0066] in is the initial perturbation strength of the virtual negative sample, It is a hyperparameter used to control the dynamic adjustment rate of generating virtual negative samples. is the mean change of the current mini-batch statistical information, which is used to measure whether the feature distribution of mini-batch sampling has changed significantly. Its calculation formula is as follows:

[0067] This paper studies the role of contrastive learning networks and loss functions that introduce the nearest neighbor idea, and evaluates the contribution of each module to the final result by comparing the model performance under different experimental settings.

[0068] Table 1 Contribution of each module to the experimental results in the ablation experiment

[0069] Simply applying strong augmentation to SimCLR and MoCo v2 samples reduced the accuracy of the contrastive network. Without the strong augmentation contrastive learning network and the new loss function, the base network using MoCo v2 achieved an accuracy of 67.8% on the pneumoconiosis dataset. However, when strong augmentation was introduced, the accuracy dropped to 66.7%, a decrease of 1.1%. When trained with SimCLR, the initial accuracy was 67.1%. However, after adding strong augmentation, the accuracy dropped to 66.1%, a decrease of 2.1%. This result emphasizes that simply applying strong augmentation to contrastive learning networks is not advisable. Although strong augmentation can generate more diverse images to a certain extent, it can also introduce excessive changes in image structure, making it difficult for the model to maintain instance consistency and stable feature representations, thus affecting contrastive learning performance. Subsequently, using the strong augmentation contrastive learning network and applying the InfoNCE loss to the strongly augmented images achieved an accuracy of 68.3%. This significantly improved accuracy compared to MoCo v2 + StrongAug and SimCLR + StrongAug. After combining the loss function, the final model achieved an accuracy of 69.8% on the pneumoconiosis dataset and performed better than other comparison groups on other datasets.

[0070] In comparative experiments, the present invention comprehensively compared supervised learning and several classic contrastive learning methods, evaluating their performance on three different datasets. The results are shown in Table 2. The proposed model achieved a top-1 classification accuracy of 69.8% on the pneumoconiosis dataset, 68.6% on the NIH Chest X-ray dataset, and 87.5% on the COVID-19 dataset. Compared with existing classic contrastive learning methods, the proposed method achieved a certain degree of improvement on all three datasets, particularly on the pneumoconiosis dataset, where it improved by approximately 2 percentage points compared to MoCo v2. This demonstrates that, for subtle lesion features, the proposed method, by introducing a new loss function and the nearest neighbor approach, can effectively utilize the complex semantic information generated by strongly enhanced data, improving the model's feature extraction and fine-grained feature learning capabilities. The proposed method also demonstrated superior classification performance compared to CLSA, demonstrating that while CLSA can effectively utilize strongly enhanced images, it still cannot effectively extract subtle lesion features in the medical imaging field. Compared to traditional contrastive learning methods that simply use InfoNCE loss, the proposed method achieves better classification results than classic contrastive learning methods by further optimizing the loss function and adding distribution difference minimization loss. However, the proposed method still lags behind the top-1 accuracy of supervised learning, with gaps of 6% and 17% on the pneumoconiosis and NIH Chest X-ray datasets, respectively, and a gap of 6.7% on the COVID-19 dataset.

[0071] Table 2 Comparative experimental results

[0072] The present invention changes the hyperparameters The value of is used to explore the impact of its changes on the classification results of the pneumoconiosis dataset. Experiments were conducted to observe the changes in classification performance. The results are shown in Table 3. = 0, the loss function only contains , the model cannot use the relative similarity distribution of weakly enhanced queries to guide the representation learning of strongly enhanced queries. That is to say, the training mainly relies on nearest neighbor matching for contrast loss calculation, and the distribution of the introduced strongly enhanced samples will deviate from the original samples, resulting in nearest neighbor search matching errors. The model cannot learn stable features, thus affecting the contrast learning effect. When it gradually increases from 0 to 0.2, the classification performance gradually improves, which shows that The introduction of forces the feature distribution of the strongly enhanced samples to be closer to the nearest neighbor matching samples, so that the strongly enhanced samples can still find the nearest neighbors with consistent semantics to improve the quality of positive sample matching. Especially in tasks with complex data distribution such as medical images, it can make model learning more stable. When it is greater than 0.2, it starts to decrease. This means that if the features of the enhanced samples are forced to align with the features of the nearest neighbor matching samples, the model may ignore the natural changes in the data, and samples of different categories become difficult to distinguish, which ultimately leads to a decrease in feature expression ability. Therefore, 0.2 is Optimal values ​​for medical image classification tasks.

[0073] Table 3 Hyperparameters Impact on model performance

[0074] To comprehensively evaluate the contributions of each key module in the proposed method, we designed a series of ablation experiments, gradually removing the hierarchical instance-level contrastive learning framework, virtual negative samples, and the diversified mini-batch strategy. Experiments were conducted on three datasets, systematically evaluating the contribution of each module to classification performance and analyzing its impact on the final performance. The experimental results are shown in Table 4.

[0075] Table 4 Effect of removing each module on model performance in ablation experiments

[0076] The experimental results show that the complete model achieves the best classification performance, achieving the highest Top-1 accuracy on all three datasets. Performance degrades after removing individual components, and the degree of impact varies depending on the module removed, indicating that each module plays a complementary role in improving model performance.

[0077] After removing HILC (without HILC), the accuracy of the three datasets decreased by 1.7%, 3.2%, and 2.1%, respectively. This indicates that the model, by modeling feature information of different granularities through a hierarchical structure, can capture richer class-discriminating features. For medical images with small diffuse lesions, HILC can help the model learn local features and enhance the aggregation of global features, improving the model's generalization performance, playing a significant role in enhancing intra-class consistency and inter-class discrimination in medical image classification. After removing VNG (without VNG), the accuracy decreased by 2.3%, 2.8%, and 2.5%, respectively. VNG generates virtual negative samples based on the real data distribution in the feature space, enabling the contrastive learning process to obtain richer negative samples, which helps improve feature discrimination. Especially in the case of data imbalance, the virtual negative samples generated by VNG can effectively alleviate the class imbalance problem, making the model more stable when processing minority class samples and providing more training information. After removing DMB (without DMB), the accuracy dropped by 3.6%, 4.5%, and 4.4%, respectively. This indicates that samples from different categories are fully learned at each training iteration, enabling the model to more stably learn features from different categories and preventing the model from biasing towards the majority class. This plays a significant role in improving data balance and learning efficiency. When both VNG and DMB are removed simultaneously (without VNG & DMB), the accuracy drops by 6.8%, 6.9%, and 7.0%, respectively, significantly greater than when removing either module individually. This demonstrates that VNG and DMB complement each other, enabling the contrastive learning framework to obtain sufficient negative samples while ensuring a balanced distribution of samples across categories during training. Therefore, removing both modules has a more significant impact than removing either module alone.

[0078] In order to further verify the effectiveness of the diversified small batch strategy, the present invention also conducted additional comparative experiments, and the results are shown in Table 5.

[0079] Table 5 The impact of diverse mini-batch strategies and random sampling strategies on model performance

[0080] By comparing with the traditional random mini-batch sampling strategy, the diversified mini-batch strategy achieved certain performance improvements on all datasets. In particular, on the pneumoconiosis dataset and the NIH Chest X-ray dataset, the diversified mini-batch strategy improved the Top-1 accuracy by 4.0 and 0.8 percentage points, respectively, and the BACC by 3.9 and 1.2 percentage points, respectively, compared with the random sampling strategy. The performance on the COVID-19 dataset also improved, with the Top-1 accuracy increasing by 0.9 percentage points and the BACC increasing by 2.2 percentage points. This result shows that the diversified mini-batch strategy successfully addresses the challenge of insufficient minority class samples by improving the mini-batch selection method, improving the model's detection accuracy on minority classes. It can not only improve the overall performance, but also significantly improve the classification effect of minority classes. It has important application value in the task of class-imbalanced chest disease classification.

[0081] In the comparative experiments, the present invention comprehensively compares supervised learning, several classic contrastive learning methods, and contrastive learning methods that have achieved good results on class-imbalanced medical datasets, and evaluates their performance on different datasets. The results are shown in Table 6. The experimental results show that the method of the present invention achieves the best self-supervised learning classification performance on all three datasets, and outperforms existing mainstream contrastive learning methods in terms of Top-1 classification accuracy and BACC indicators. Among them, HCLe achieves good performance in medical image classification tasks by introducing a hierarchical contrastive learning strategy. However, since it completely ignores the minority class and only uses positive sample pairs for training, it still does not reach the level of the method of the present invention. This shows that the adaptive negative sample generation module proposed in the present invention can more effectively enhance the model's ability to distinguish small sample features.

[0082] Table 6 Comparative experimental results It should be understood that those skilled in the art can make improvements or changes based on the above description, and all such improvements and changes should fall within the scope of protection of the appended claims of the present invention.

Claims

1. A chest disease screening and classification system based on self-supervised learning, characterized in that: Includes a strongly enhanced chest disease screening and classification module and a hierarchical instance-level chest disease screening and classification module; Among them, the strongly enhanced chest disease screening and classification module performs multiple strong transformations on the data and introduces the nearest neighbor idea in the self-supervised training process. By selecting the nearest neighbor samples in the support set as additional positive samples, it ensures that the strongly enhanced samples still maintain a certain semantic consistency; at the same time, it introduces the distribution difference minimization loss to reduce the inconsistency of feature distribution under different enhanced views and improve the stability of the model; the hierarchical instance-level chest disease screening and classification module performs comparative learning at the hierarchical level and instance level, and combines a diversified small batch strategy and a virtual negative sample generation module to ensure that each class can be fully learned in the model training iteration while dynamically generating virtual samples that are similar but not exactly the same as the real negative samples, providing a more stable and effective training signal for comparative training.

2. The chest disease screening and classification system based on self-supervised learning according to claim 1, characterized in that: The strong enhancement chest disease screening and classification module includes a strong data enhancement module, a strong enhancement contrast learning network, a nearest neighbor contrast loss module, and a distribution difference minimization loss module; the strong data enhancement module includes a weak enhancement unit and a strong enhancement unit, which are used to generate weak enhancement samples and strong enhancement samples respectively, so as to generate more complex semantic information of the image.

3. The chest disease screening and classification system based on self-supervised learning according to claim 2, characterized in that: The weak enhancement unit includes the following three types of data enhancement operations: (1) Geometric enhancement methods such as rotation, translation, and shearing, which make the model more deformable by perturbing the spatial structure of the image, thereby improving the ability to identify lesions at different angles, positions, or scales; (2) Non-geometric enhancement methods such as automatic contrast, histogram equalization, brightness adjustment, and sharpening, which transform the image in pixel or color space to simulate different imaging conditions and effectively deal with image quality differences or imaging equipment differences; (3) Color-related enhancement operations such as contrast, brightness, and color saturation adjustment can also simulate a variety of filming conditions to a certain extent, which helps to alleviate the domain shift problem caused by different equipment, imaging parameters, and hospital environments; In order to achieve the purpose of strong enhancement, the amplitude of all enhancement operations is set to be larger than that of the traditional weak enhancement strategy, aiming to maximize the distortion of the image while ensuring that the image is basically recognizable, so that the model can learn more robust representations during training; When performing strong enhancement on the image, an enhancement is randomly selected from the data enhancement pool and applied to the image with a probability of 0.5; this process is repeated five times to achieve the effect of strong enhancement on the image.

4. The chest disease screening and classification system based on self-supervised learning according to claim 2, characterized in that: The strong enhancement contrast learning network described above takes the generated strong enhancement samples and weak enhancement sample sets as input, then extracts their feature representation through ResNet-50 to map the input image into a high-dimensional feature space; and constructs an automatically updated support set, uses the nearest neighbor algorithm to select positive and negative samples in the support set, and finally optimizes the training process by introducing the distribution difference minimization loss, performs self-supervised contrast classification, and forms the final classification model.

5. The chest disease screening and classification system based on self-supervised learning according to claim 4, characterized in that: The support set is used to retain the embedding of the dataset subset in memory. The support set is implemented as a first-in-first-out queue to ensure the diversity of samples in the support set, so that the latest samples can be continuously added to the support set, while the older samples are gradually replaced to maintain its dynamic update characteristics; the support set is initialized to a dimension of A random matrix, where is the size of the queue, which determines the number of samples stored in the support set. is the size of the embedding; the size of the support set is kept large enough to approximate the full dataset distribution in the embedding space; the support set is dynamically updated at the end of each training epoch: at the end of the training epoch, embeddings and concatenate them to the end of the queue to update the support set, where is the size of the mini-batch; this mechanism ensures that the support set always contains the latest sample distribution information and avoids the representation degradation problem caused by long sample retention time; the support set introduces new samples and removes old samples in each training round, which can ensure that the model always uses the latest data for comparative learning and improve convergence stability.

6. The chest disease screening and classification system based on self-supervised learning according to claim 5, characterized in that: For positive sample pairs, the support set of the nearest neighbor search is used to retrieve positive samples, and these samples are then paired with strongly enhanced samples from the same image. For each sample, the model searches the support set for its nearest neighbor samples as additional positive samples, forming positive pairs with the sample's strongly enhanced sample to enhance the model's semantic consistency when processing strongly enhanced views. Specifically, the support set differs from traditional memory banks in that it not only stores negative sample features but is also specifically used to retrieve positive samples. After each training sample is enhanced, the model further ensures the semantic consistency of the enhanced sample by retrieving the most similar sample from the support set. Directly using strongly enhanced samples for comparison may cause drift in the representation space, making it difficult for the model to converge stably. The samples matched by the nearest neighbors provide a mechanism similar to an "anchor point", which provides a smoother training process and helps the model gradually adapt to stronger enhancements during training. For negative samples, negative samples are obtained from small batches and form negative sample pairs with weakly enhanced samples of the original samples, so that the model can still learn global discriminative information.

7. The chest disease screening and classification system based on self-supervised learning according to claim 2, characterized in that: In contrastive learning, we optimize the loss design based on InfoNCE to adapt to the complexity of medical images. We improve the positive sample selection method of traditional contrastive learning by introducing the nearest neighbor idea. It searches for the nearest neighbor samples in the support set as additional positive samples. The improved loss is as follows: ;in and Features extracted from different enhanced views of the same image, is the negative sample in the mini-batch, is the temperature parameter, the nearest neighbor operator It is defined by the following formula: ;in is the embedding vector of the current sample, It is a collection of features that supports centralized storage. Represents candidate features; similar to InfoNCE, each embedding vector is L2 normalized before calculating the loss, and L2 normalized before the nearest neighbor calculation; the final loss function is obtained by calculating the average loss of the mini-batch data: ; The distribution divergence minimization loss function is defined as follows: ;in, is the feature extracted from the weakly enhanced view, is the feature representation of the nearest neighbor sample, and Denote the probability distribution of weakly enhanced samples and nearest neighbor samples, respectively. The optimization goal of this loss is to minimize the distribution difference between the two distributions, so that the distribution of nearest neighbor samples and original samples in the feature space is more consistent. This can effectively prevent the feature drift caused by strongly enhanced samples, ensure that the enhanced features still maintain the semantic information of the original samples during training, and stabilize the effect of nearest neighbor search, making the positive samples matched in the support set more reliable and avoiding mismatching due to feature offset after strong enhancement. Finally, the loss function of the model combines the above two contrast losses and is defined as follows: ;in, Responsible for learning the nearest neighbor samples and enhancing the similarity of views to improve the utilization of semantic information, Responsible for aligning the similarity distribution of the enhanced view and the nearest neighbor samples, preventing feature drift caused by strong enhancement, and improving the stability of the model; is a hyperparameter that controls the contribution of the distribution difference minimization loss to the total loss.

8. The chest disease screening and classification system based on self-supervised learning according to claim 1, characterized in that: The hierarchical instance-level chest disease screening and classification module includes a hierarchical instance-level contrastive learning framework, a diversified mini-batch mechanism, and an adaptive virtual negative sample generation module. The hierarchical instance-level contrastive learning framework: This contrastive learning framework enhances the model's feature representation capabilities by simultaneously performing instance-level and category-level contrastive learning (HILC). Emphasize the similarities and differences between samples at the instance level, so that the model can accurately learn individual features; At the category level, by comparing the feature distributions of the majority class and the minority class in a wider category space, the model is ensured to capture more representative category features, so that the network can better learn multiple subcategories of each class; this hierarchical comparative learning method enables the model to not only accurately identify subtle differences in individual samples, but also globally optimize the discrimination ability between categories; the virtual negative sample generation module can generate virtual negative samples similar to real negative samples, and can dynamically adapt to the statistical distribution within the mini-batch to ensure the diversity of negative samples, so that the model can obtain more stable and effective negative sample information without additional data collection costs; the diversified mini-batch mechanism generally optimizes the sample distribution within the mini-batch through sub-class balanced sampling and diversified sampling based on the feature space, so that the model can more fully learn the feature change pattern of the majority class; at the same time, the diversified mini-batch mechanism also provides a more stable feature basis for the generation of virtual negative samples, further improving the effectiveness of comparative learning.

9. The chest disease screening and classification system based on self-supervised learning according to claim 8, characterized in that: The diversified mini-batch mechanism described above: introduces subclass balanced sampling; for a majority class, assume that it contains multiple subclasses , when constructing a mini-batch, it ensures that all subclasses are included as much as possible, rather than just random sampling. This is achieved through dynamic weight adjustment: ;in Is a subclass The probability of being selected, is the number of samples of the subclass in the current mini-batch. If a subclass has been sampled many times, the probability of it being selected later will be reduced to ensure the sampling opportunities of other subclasses. λ is a smoothing parameter to avoid sampling failure when the subclass samples are completely insufficient. In order to ensure that the majority of the subclasses sampled in the mini-batch have sufficient distribution diversity in the feature space, diversified sampling based on the feature space is also required. First, calculate the mean of the samples in the current mini-batch. : ; where N is the number of samples in the current mini-batch, is the first The feature vector of each sample; by calculating the covariance matrix of the samples in the mini-batch You can measure the distribution of samples in the feature space within a small batch: ; In this way, the model can ensure that the samples in a small batch come from multiple different feature clusters rather than being concentrated in a local area.

10. The chest disease screening and classification system based on self-supervised learning according to claim 8, characterized in that: The adaptive virtual negative sample generation module: The generation of virtual negative samples depends on the feature distribution of the majority class samples in the current mini-batch, rather than randomly generating meaningless negative samples. Its calculation formula is as follows: ;in is the generated virtual negative sample, is standard Gaussian noise, ensuring that the generated virtual negative samples have a certain degree of randomness. and Represent the mean of the majority class samples in the small batch and the standard deviation of the majority class samples in the small batch, respectively, to ensure the rationality of the distribution of negative samples; is the adaptive perturbation factor of the virtual negative sample, which controls the generation intensity of the virtual negative sample. It can be regarded as the radius of generating virtual samples in the feature space, so that the generation of virtual negative samples can better adapt to different stages of model training. Its calculation formula is as follows: ;in is the initial perturbation strength of the virtual negative sample, It is a hyperparameter used to control the dynamic adjustment rate of generating virtual negative samples. is the mean change of the current mini-batch statistical information, which is used to measure whether the feature distribution of mini-batch sampling has changed significantly. Its calculation formula is as follows: .