Contrast learning-based X-ray image domain adaptive pulmonary nodule detection method

The method addresses low-quality pseudo-labels and inadequate feature alignment in X-ray image domain adaptation by using contrastive learning and adversarial techniques, enhancing lung nodule detection across varied medical environments.

CN119228743APending Publication Date: 2024-12-31ANHUI UNIV
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411232082.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Existing X-ray image domain adaptation lung nodule detection methods face challenges such as low-quality pseudo-labels generated by mean teacher self-training and inadequate fine-grained feature alignment between source and target domains, leading to poor performance when applying models across different medical centers.

Method used

A method utilizing contrastive learning with a hierarchical contrastive learning strategy and an adversarial learning module to enhance nodule representation and capture domain-invariant features, incorporating region-level and pixel-level contrast losses and an adversarial gradient reversal layer for improved domain adaptation.

Benefits of technology

The method generates high-quality pseudo-labels and achieves better domain adaptation by aligning finer features, resulting in improved lung nodule detection accuracy across different medical centers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228743A_ABST
    Figure CN119228743A_ABST
Patent Text Reader

Abstract

The invention discloses a contrast learning-based X-ray image domain adaptive pulmonary nodule detection method, which comprises the following steps of: training a model by using a source domain image, copying the model to obtain a teacher model and a student model, and sending the source domain image into the student model through strong data enhancement; the target domain image is sent to the student model and the teacher model through strong data enhancement and weak data enhancement. For a source domain image, supervision loss is calculated through a label, and for a target domain image, non-supervision loss is calculated through a pseudo label. The hierarchical contrast learning module calculates region-level and pixel-level contrast losses respectively, and the adversarial learning module obtains adversarial classification losses through region-level features from a source domain and a target domain. And finally, combining loss functions to carry out model optimization, updating student model parameters, and updating teacher model parameters through an exponential moving average strategy. According to the method, a unique hierarchical contrast learning strategy is adopted, so that the problem of low-quality false labels is solved, and the accuracy of the X-ray image domain adapting to pulmonary nodule detection is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer vision, medical image processing and deep learning technology, and in particular to an X-ray image domain adaptation lung nodule detection method based on contrast learning. Background Art

[0002] Lung nodules are one of the early symptoms of lung cancer. Early detection of lung nodules is crucial to improving patient survival. Chest X-rays are widely used by radiologists due to their high cost-effectiveness and low radiation risk. However, with the increase in workload, it is becoming more difficult for doctors to effectively identify lesions in chest X-rays. Therefore, there is an urgent need for an automated lung nodule detection tool to help doctors make quick and accurate diagnoses. In recent years, many researchers have used target detection models for lung nodule detection.

[0003] Existing pulmonary nodule detectors mainly focus on data from the same medical center. Usually, the training samples and application samples in these models come from the same medical center and have similar distributions. However, in many cases, the training and application data may come from different centers, resulting in the domain shift problem. When a model is trained on source domain data and applied on target domain data, the performance may be poor.

[0004] Researchers have addressed the challenge of domain shift by self-training the mean teacher. However, such methods often face the challenge of generating low-quality pseudo labels. Since the knowledge of the teacher model comes from training on the source domain data, the pseudo labels generated by the teacher model always contain noise. Some researchers have also solved this problem by aligning the features of the source and target domain images, but these methods only focus on image-level features and ignore the more fine-grained feature domain alignment.

[0005] In general, existing X-ray image domain adaptation lung nodule detection methods have the following shortcomings: (1) Mean teacher self-training based methods often face the problem of generating low-quality pseudo labels. Since the knowledge of the teacher model comes from training on the source domain data, the pseudo labels generated by the teacher always contain noise. When these noisy pseudo labels are used as supervision signals for the student model on the target domain images, they will have an adverse effect on the performance. (2) Methods that align the image features of the source and target domains only focus on image-level features and ignore more fine-grained feature alignment. Summary of the invention

[0006] Purpose of the invention: The purpose of the present invention is to address the deficiencies in the prior art and to provide a method for detecting lung nodules in an X-ray image domain that is adapted to the environment based on contrastive learning. The method optimizes nodule representation and enhances the distinction between nodules and backgrounds through a hierarchical contrastive learning strategy. At the same time, a nodule-level adversarial learning module is introduced to capture domain-invariant features through adversarial learning between different domains, thereby enabling the model to generate high-quality pseudo-labels and achieve X-ray image domain-adaptive lung nodule detection. The present invention solves the problem of low quality of pseudo-labels in the existing mean teacher self-training method and the problem of finer-grained feature alignment between the source domain and the target domain.

[0007] Technical solution: The present invention provides an X-ray image domain adaptive pulmonary nodule detection method based on contrast learning, comprising the following steps:

[0008] Step S1: Use the source domain image to train the target detection model (e.g., Faster R-CNN model), and copy the trained detection model to obtain a teacher model and a student model;

[0009] Step S2, the source domain image is sent to the student model after strong data enhancement; the target domain image is subjected to strong data enhancement and weak data enhancement respectively, and then sent to the student model and the teacher model in turn; strong data enhancement includes random resizing, Gaussian blur, color jitter, etc., and weak data enhancement is horizontal flipping;

[0010] The processing process of the student model and the teacher model is as follows: first, the enhanced image data is input into the feature extraction module of the corresponding model, and the feature map representing the image content is extracted by the feature extraction module. Then, the region generation network of the corresponding model determines the coordinates of the candidate region box for the feature map, and multiple regions of interest are mapped from the global feature map according to the region box coordinates. For each region of interest, feature extraction is performed again, and finally classification is performed to determine whether it contains lung nodules.

[0011] Step S3: For source domain images, calculate supervision loss by label For target domain images, the unsupervised loss is calculated using pseudo labels. Monitoring loss and unsupervised loss Both are obtained by adding the classification loss and the regression loss. In the present invention, the pseudo-labels are generated by the teacher model, and the pseudo-labeling method is used to generate virtual labels on the images in the target domain to train the student model. The target domain images have no labels, so the predictions generated by the teacher model are required as labels. In order to filter out noisy pseudo-labels, a confidence threshold is set on the predicted bounding box of the teacher model to remove false positives. In addition, duplicate predictions are excluded through non-maximum suppression, and the pseudo-labels are used to guide the student model. The training of the student model includes four losses: supervised loss from the source domain images, unsupervised loss from the target domain images, hierarchical contrast loss, and adversarial classification loss.

[0012] Step S4: Calculate the region-level contrast loss separately through the hierarchical contrast learning module And pixel-level contrast loss Then we get the hierarchical contrast loss To optimize nodule representation and enhance the distinction between nodules and background; the adversarial classification loss is obtained through the regional-level features from the source domain and the target domain through the adversarial learning module, and the domain-invariant features are captured through adversarial learning between different domains, thereby achieving X-ray image domain adaptation for lung nodule detection;

[0013] Step S5, merge the loss functions of step S3 and step S4 to optimize the detection model, update the student model parameters, update the teacher model parameters by exponential sliding average, and the teacher model is incrementally updated by using the weights of the student model.

[0014] Furthermore, the hierarchical contrast learning module in step S4 calculates the hierarchical contrast loss The specific method is:

[0015] Step A: Calculate region-level contrast loss

[0016] The regional features generated from the student model are divided into two categories based on the intersection-over-union ratio of the region coordinates and the pseudo-label: positive (nodules) and negative (background). Through contrastive learning, the foreground representation is brought closer to the foreground representation, and the background representation is brought closer to the background representation, while the foreground representation and the background representation are pulled further apart. This process ensures that the representation of the nodules is clearer and significantly improves the detector's ability to distinguish between the foreground and the background. The region generation network generates n region boxes, which are pooled through the region of interest to obtain the feature set S i , set S i The features in are classified into two categories through pseudo labels: the positive class set and negative class collection

[0017] The region-level contrast loss is defined as follows:

[0018]

[0019] Where D represents the function of pulling away the positive and negative regions; Represents a function that brings similar regions closer together; and Represents the set of positive regions and the set of negative regions; j and k are the number of positive regions and negative regions; here, the division of positive and negative regions is based on the pseudo-labels generated by the teacher model; the region generation network in the student model generates n regions of interest, which are divided according to the IOU threshold with the pseudo-label. If the threshold is greater than 0.75, it is a positive region, otherwise, it is a negative region;

[0020] Step B: Calculate pixel-level contrast loss

[0021] The region-level contrast learning strategy focuses on features such as the size and shape of nodules, but ignores more subtle features. To solve this problem, pixel-level contrast learning is introduced to pay more attention to details such as color and texture, so as to more finely distinguish nodule representation and background representation; to ensure that the pixels come from salient areas, based on the sum of the channel values ​​of each pixel, the first p positive pixel features are sampled and the first q negative pixels Through pixel-level contrast loss, positive pixels are brought closer to each other, negative pixels are brought closer to each other, and positive pixels are pushed away from negative pixels. The calculation formula is as follows:

[0022]

[0023] Where D represents the function of pulling away positive pixels and negative pixels; Represents a function that brings similar pixels closer together; and Represents the positive class pixel set and the negative class pixel set;

[0024] In order to effectively distinguish positive and negative samples, the function D is defined as follows:

[0025]

[0026] Among them, A and B represent the feature vector sets from two types of samples; a and b represent the elements in the sets A and B; |A| and |B| represent the number of elements in the sets A and B; sim(a,b) represents the cosine similarity of the two feature vectors a and b;

[0027] Due to the differences in structural morphology of different types of lung nodules, lung nodules may have completely different feature representations. In addition, the feature representations of background areas are also different. Therefore, indiscriminately aggregating similar samples together in feature representation is not conducive to model training. To solve this problem, feature vector similarity sorting is used to adjust the weight of similarity loss, and the loss function that brings similar samples closer is used. The definition is as follows:

[0028]

[0029] Where A represents the positive sample set or the negative sample set; μ represents the smoothing hyperparameter; rank represents the cosine similarity level; |A| represents the number of elements in set A; sim(a1,a2) represents the cosine similarity of the two feature vectors a1 and a2;

[0030] Step C: Calculate layer-wise contrast loss

[0031] The hierarchical contrast loss consists of the region-level contrast loss and the pixel-level contrast loss as shown below:

[0032]

[0033] Among them, λ represents the balance hyperparameter; represents the region-level contrast loss; Represents pixel-level contrast loss.

[0034] Furthermore, the adversarial classification loss in step S4 The calculation method is as follows:

[0035] The nodule-level features obtained from the source and target domains are input into the gradient reversal layer and the domain classifier.

[0036] The domain classifier is used to discriminate feature maps during the domain adaptation process; the domain classifier extracts features through multi-layer convolution operations and uses leaky rectified linear units (LeakyReLU) as activation functions to ensure the effectiveness and stability of feature extraction. The discriminator finally outputs a single-channel discrimination result for distinguishing feature representations of the source domain and the target domain, and assists the adaptive learning of the mean teacher model;

[0037] The gradient reversal layer is used to reverse the gradient direction during model training, thereby guiding the model to learn domain-independent features during feature extraction. The gradient reversal layer does not change the input data during forward propagation, but effectively prevents the model from overfitting the source domain data by reversing the gradient direction during back propagation, thereby improving the performance of the model in the target domain.

[0038] Adversarial Classification Loss The calculation formula is as follows:

[0039]

[0040] Among them, P represents the probability that the region-level feature belongs to the source domain; 1-P represents the probability that it belongs to the target domain; T represents the domain label, for the source domain image, T = 0, for the target domain image, T = 1;

[0041] During back-propagation, the gradients of the gradient reversal layer are multiplied by a negative scalar, prompting the encoder to generate region-level features that are difficult to distinguish between the source and target domains.

[0042] Furthermore, the weight update formula of the teacher model in step S5 is as follows:

[0043] θ t ←βθ t +(1-β)θ s

[0044] Among them, θ t represents the weight of the teacher model; θ s represents the weight of the student model; β represents the balance parameter.

[0045] Further, after completing the model update in step S5, continue to perform the detection model testing process in step S6.

[0046] During the test, the model parameters that have been trained in the fixed training phase are selected, and the student model with the best performance in the training process is selected as the test model, and the target domain test set is used as the test data;

[0047] First, input the test data into the feature extraction module of the model;

[0048] The test data is then processed through the feature extraction module to obtain a feature map that can represent the image content. The region generation network determines the coordinates of the candidate region box for the feature map, and maps multiple regions of interest from the global feature map according to the region box coordinates. Each region of interest is further feature extracted and then classified to determine whether it contains a lung nodule and assign a prediction score to it, which represents the confidence level of the lung nodule.

[0049] Finally, AP and AP are calculated by the coordinates and prediction scores of the final detection box and the target domain test set label. 50 、AP 75 、AP S 、AP M and AP L index.

[0050] Beneficial effects: (1) For the task of detecting lung nodules in domain-adapted X-ray images, the present invention solves the problem of low-quality pseudo-labels by adopting a unique hierarchical contrastive learning strategy. Unlike methods that only focus on the data differences between the source domain and the target domain, the present invention captures additional valuable information, including the association between nodules and the background, during the training process. Model training is supervised by the similarity of nodule representation and the similarity of background representation, as well as the difference between nodules and background. The hierarchical contrastive learning strategy is carried out in two dimensions: regional level and pixel level. Regional level contrastive learning focuses on the size and shape features of targets in nodule and background regions, while pixel level contrastive learning targets the texture and grayscale features in these regions. The combination of the two can obtain more discriminative nodule and background representations.

[0051] (2) Different from the traditional method of aligning the image features of the source domain and the target domain only at the image level, the present invention adopts a more fine-grained feature alignment. The adversarial learning module includes an adversarial gradient reversal layer and a domain classifier, which performs adversarial learning on nodule-level features, aiming to align the finer details of the source domain data and the target domain data, solve the domain adaptation challenge at the nodule level, and thus improve the performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 It is a schematic diagram of the overall process of the present invention;

[0053] Figure 2 It is a schematic diagram of the network structure of the present invention. DETAILED DESCRIPTION

[0054] The technical solution of the present invention is described in detail below, but the protection scope of the present invention is not limited to the embodiments.

[0055] like Figure 1 As shown, the X-ray image domain adaptation pulmonary nodule detection method based on contrast learning of the present invention comprises the following steps:

[0056] Step S1: Use the source domain image to train the target detection model, and copy the trained detection model to obtain a teacher model and a student model;

[0057] Step S2: After strong data enhancement, the source domain image is sent to the student model; the target domain image is subjected to strong data enhancement and weak data enhancement respectively, and then sent to the student model and the teacher model in turn;

[0058] The processing process of the student model and the teacher model is as follows: first, the enhanced image data is input into the feature extraction module of the corresponding model, and the feature map representing the image content is extracted by the feature extraction module. Then, the region generation network of the corresponding model determines the coordinates of the candidate region box for the feature map, and multiple regions of interest are mapped from the global feature map according to the region box coordinates. Each region of interest is subjected to feature extraction, and finally classified to determine whether it contains lung nodules. Among them, the student model outputs a detection box containing a predicted score, and the teacher model generates a detection box containing a pseudo-label. The pseudo-label is used to guide the student model to calculate the unsupervised loss and contrast loss.

[0059] Step S3: For source domain images, supervised loss is calculated by label, and for target domain images, unsupervised loss is calculated by pseudo label. Both supervised loss and unsupervised loss are obtained by adding classification loss and regression loss. Classification loss is to classify the detection box, determine whether there is a nodule in the box, predict the classification score, and calculate the cross entropy loss according to the label. Regression loss is to calculate the IOU loss according to the coordinates of the label and the coordinates of the predicted box. The classification loss and regression loss here are both conventional losses of the target detection network.

[0060] Step S4: Calculate the region-level contrast loss separately through the hierarchical contrast learning module And pixel-level contrast loss Then we get the hierarchical contrast loss To optimize nodule representation and enhance the distinction between nodules and background; the adversarial classification loss is obtained through the regional-level features from the source domain and the target domain through the adversarial learning module, and the domain-invariant features are captured through adversarial learning between different domains, thereby achieving X-ray image domain adaptation for lung nodule detection;

[0061] Step S5, merge the loss functions of step S3 and step S4 to optimize the detection model, update the student model parameters, update the teacher model parameters by exponential sliding average, and the teacher model is incrementally updated by using the weights of the student model.

[0062] In the present invention, pseudo labels are generated due to the domain offset between the source domain and the target domain. Instead of using only pseudo labels for supervision, the difference between nodules and background is used to train the student model, thereby prompting the teacher model to generate high-quality pseudo labels (the teacher model is not updated using the loss function during the interactive training process, and the weight of the student model is also used for weighted update). At the same time, the adversarial module can also prompt the encoder to generate features that are difficult to distinguish between the source domain and the target domain, further improving the quality of pseudo labels.

[0063] In step S4 of this embodiment, the hierarchical contrastive learning module calculates the hierarchical contrast loss The specific method is:

[0064] Step A: Calculate region-level contrast loss

[0065] The regional features generated from the student model are divided into two categories based on the intersection-over-union ratio of the region coordinates and the pseudo-label: positive (nodules) and negative (background). Through contrastive learning, the foreground representation is brought closer to the foreground representation, and the background representation is brought closer to the background representation, while the foreground representation and the background representation are pulled further apart. The region generation network generates n regions of interest, and the features of these regions of interest are represented as a set S i , set S i The features in are classified into two categories through pseudo labels: the positive class set and negative class collection

[0066] The region-level contrast loss is defined as follows:

[0067]

[0068] Where D represents the function of pulling away the positive and negative regions; Represents a function that brings similar regions closer together; and represents the set of positive regions and the set of negative regions; j and k are the number of positive regions and negative regions;

[0069] Step B: Calculate pixel-level contrast loss

[0070] Based on the sum of the channel values ​​of each pixel, the first p positive pixel features are sampled and the first q negative pixels Through pixel-level contrast loss, positive pixels are brought closer to each other, negative pixels are brought closer to each other, and positive pixels are pushed away from negative pixels. The calculation formula is as follows:

[0071]

[0072] Where D represents the function of pulling away positive pixels and negative pixels; Represents a function that brings similar pixels closer together; and Represents the positive class pixel set and the negative class pixel set;

[0073] In order to effectively distinguish positive and negative samples, the function D is defined as follows:

[0074]

[0075] Among them, A and B represent the feature vector sets from two types of samples; a and b represent the elements in the sets A and B; |A| and |B| represent the number of elements in the sets A and B; sim(a,b) represents the cosine similarity of the two feature vectors a and b;

[0076] The similarity loss weight is adjusted by sorting the feature vector similarity, and the loss function is used to bring similar samples closer together. The definition is as follows:

[0077]

[0078] Where A represents the positive sample set or the negative sample set; μ represents the smoothing hyperparameter; rank represents the cosine similarity level; |A| represents the number of elements in set A; sim(a1,a2) represents the cosine similarity of the two feature vectors a1 and a2;

[0079] Step C: Calculate layer-wise contrast loss

[0080] The hierarchical contrast loss consists of the region-level contrast loss and the pixel-level contrast loss as shown below:

[0081]

[0082] Among them, λ represents the balance hyperparameter; represents the region-level contrast loss; Represents pixel-level contrast loss.

[0083] The adversarial classification loss in step S4 above The calculation method is as follows:

[0084] The nodule-level features obtained from the source and target domains are input into the gradient reversal layer and the domain classifier.

[0085] The domain classifier is used to discriminate the feature map during the domain adaptation process. The domain classifier extracts features through multi-layer convolution operations and uses a leaky rectified linear unit (LeakyReLU) as an activation function. The discriminator finally outputs a single-channel discrimination result for distinguishing the feature representations of the source domain and the target domain.

[0086] The gradient reversal layer reverses the gradient direction during model training, thereby guiding the model to learn domain-independent features during feature extraction;

[0087] Adversarial Classification Loss as follows:

[0088]

[0089] Among them, P represents the probability that the region-level feature belongs to the source domain; 1-P represents the probability that it belongs to the target domain; T represents the domain label, for the source domain image, T = 0, for the target domain image, T = 1;

[0090] During back-propagation, the gradients of the gradient reversal layer are multiplied by a negative scalar, prompting the encoder to generate region-level features that are difficult to distinguish between the source and target domains.

[0091] The weight update formula of the teacher model in step S5 is as follows:

[0092] θ t ←βθ t +(1-β)θ s

[0093] Among them, θ t represents the weight of the teacher model; θ s represents the weight of the student model; β represents the balance parameter.

[0094] Step S6: During the test, the model parameters that have been trained in the training phase are fixed, and the student model with the best performance in the training process is selected as the test model, and the target domain test set is used as the test data;

[0095] First, the test data is input into the feature extraction module of the detection model;

[0096] The test data is then processed through the feature extraction module to obtain a feature map that can represent the image content. The region generation network determines the coordinates of the candidate region box for the feature map, and maps multiple regions of interest from the global feature map according to the region box coordinates. Each region of interest is further feature extracted and then classified to determine whether it contains a lung nodule and assign a prediction score to it, which indicates the confidence level of the lung nodule.

[0097] Finally, AP and AP are calculated by the coordinates and prediction scores of the final detection box and the target domain test set label. 50 、AP 75 、AP S 、AP M and AP L index.

[0098] Example

[0099] The detection model structure in this embodiment is as follows Figure 2As shown in the figure, Faster R-CNN is used as the basic model, which includes four parts: teacher model, student model, adversarial learning module and hierarchical contrastive learning module. In the teacher model and student model, feature extraction is first performed, and the region of interest is obtained through the region generation network and region of interest pooling. In the adversarial learning module, the classifier classifies the regions of interest from the source domain and the target domain. During the back propagation process, the gradient of the gradient reversal layer is multiplied by a negative scalar, prompting the encoder to generate nodule-level features that are difficult to distinguish from the source domain or the target domain. The hierarchical contrastive learning module uses the region-level and pixel-level contrast loss functions to distance the nodule representation and background representation in the region of interest, while bringing similar representations closer.

[0100] This embodiment conducts cross-domain experiments on the CXR dataset, B-NODULE dataset, and NODE21 dataset. Table 1 shows the experimental results using CXR as the source domain dataset and B-NODULE as the target domain dataset. Table 2 shows the experimental results using CXR as the source domain dataset and NODE21 as the target domain dataset.

[0101] Table 1

[0102] Method AP <![CDATA[AP 50 ]]> <![CDATA[AP 75 ]]> <![CDATA[AP M ]]> <![CDATA[AP L ]]> EPM 18.047 50.874 4.689 12.951 19.531 SCAN 19.960 49.380 9.438 22.389 20.561 PT 20.879 53.791 8.828 17.944 21.940 AT 14.542 43.759 4.025 7.709 16.014 CMT 20.591 52.679 9.195 12.698 22.000 The present invention 21.928 56.337 9.730 14.370 23.659

[0103] Table 2

[0104] Method AP <![CDATA[AP 50 ]]> <![CDATA[AP 75 ]]> <![CDATA[AP S ]]> <![CDATA[AP M ]]> <![CDATA[AP L ]]> EPM 17.526 50.250 4.743 0.495 18.568 26.341 SCAN 16.790 50.439 5.510 3.267 18.002 16.507 PT 17.784 48.158 8.452 4.093 18.386 26.415 AT 14.542 45.484 9.915 4.770 18.310 27.077 CMT 19.508 49.865 10.237 5.643 19.921 30.814 The present invention 19.948 50.671 10.355 5.755 20.889 28.493

[0105] In this embodiment, AP, AP 50 、AP 75 、AP S 、AP M and AP L The indicators are compared with other methods. Through the data comparison in the above table, it can be clearly seen that the technical solution of the present invention is superior to other existing methods. 50 、AP 75 、AP S 、AP M and AP L They represent the mean of the average precision at different thresholds, the average precision when the threshold is 50, the average precision when the threshold is 75, the average precision of small nodules, the average precision of medium nodules, and the average precision of large nodules. Since there are no small nodules in the B-NODULE dataset, there is no AP in Table 1. S index.

Claims

1. A method for detecting pulmonary nodules in X-ray images based on contrastive learning, characterized in that: The following steps are involved: Step S1: Use the source domain image to train the target detection model, and copy the trained detection model to obtain a teacher model and a student model; Step S2: After strong data enhancement, the source domain image is sent to the student model; the target domain image is subjected to strong data enhancement and weak data enhancement respectively, and then sent to the student model and the teacher model in turn; The processing process of the student model and the teacher model is as follows: first, the enhanced image data is input into the feature extraction module of the corresponding model, and the feature map representing the image content is extracted by the feature extraction module. Then, the region generation network of the corresponding model determines the coordinates of the candidate region box for the feature map, and multiple regions of interest are mapped from the global feature map according to the region box coordinates. For each region of interest, feature extraction is performed again, and finally classification is performed to determine whether it contains lung nodules. Step S3: For source domain images, calculate supervision loss by label For target domain images, the unsupervised loss is calculated using pseudo labels. The teacher model generates pseudo labels and uses the pseudo labels to guide the student model; Step S4: Calculate the region-level contrast loss separately through the hierarchical contrast learning module And pixel-level contrast loss Then we get the hierarchical contrast loss To optimize nodule representation and enhance the distinction between nodules and background; the adversarial classification loss is obtained through the region-level features from the source domain and the target domain through the adversarial learning module Domain-invariant features are captured through adversarial learning between different domains, thereby achieving domain-adaptive lung nodule detection in X-ray images. Step S5, merge the loss functions of steps S3 and S4 to optimize the detection model, update the student model parameters, update the teacher model parameters through exponential sliding average, and the teacher model is incrementally updated by using the weights of the student model.

2. The X-ray image domain adaptation pulmonary nodule detection method based on contrastive learning according to claim 1 is characterized in that: In step S4, the hierarchical contrastive learning module calculates the hierarchical contrast loss The specific method is: Step A: Calculate region-level contrast loss The regional features generated from the student model are divided into two categories based on the intersection-over-union ratio of the region coordinates and the pseudo-label: positive and negative. The positive category corresponds to nodules and the negative category corresponds to the background. Through contrastive learning, the foreground representation is brought closer to the foreground representation, and the background representation is brought closer to the background representation. At the same time, the foreground representation and the background representation are pulled further apart. The region generation network generates n region boxes, which are pooled through the region of interest to obtain the regional feature set S. i , set S i The features in are classified into two categories through pseudo labels: the positive class set and negative class collection j+k=n;i∈{1,…,n}; The region-level contrast loss is defined as follows: Where D represents the function of pulling away the positive and negative regions; Represents a function that brings similar regions closer together; and represents the set of positive regions and the set of negative regions; j and k are the number of positive regions and negative regions; Step B: Calculate pixel-level contrast loss Based on the sum of the channel values ​​of each pixel, the first p positive pixel features are sampled and the first q negative pixels Through pixel-level contrast loss, positive pixels are brought closer to each other, negative pixels are brought closer to each other, and positive pixels are pushed away from negative pixels. The calculation formula is as follows: Where D represents the function of pulling away positive pixels and negative pixels; Represents a function that brings similar pixels closer together; and Represents the positive class pixel set and the negative class pixel set; In order to effectively distinguish positive and negative samples, the function D is defined as follows: Among them, A and B represent the feature vector sets from two types of samples; a and b represent the elements in the sets A and B; |A| and |B| represent the number of elements in the sets A and B; sim(a,b) represents the cosine similarity of the two feature vectors a and b; The similarity loss function is used to adjust the weight of the similarity loss by sorting the feature vector similarity, and to bring similar samples closer together. The definition is as follows: Where A represents the positive sample set or the negative sample set; μ represents the smoothing hyperparameter; rank represents the cosine similarity level; |A| represents the number of elements in set A; sim(a1,a2) represents the cosine similarity of the two feature vectors a1 and a2; Step C: Calculate layer-wise contrast loss The hierarchical contrast loss consists of the region-level contrast loss and the pixel-level contrast loss as shown below: Among them, λ represents the balance hyperparameter; represents the region-level contrast loss; Represents pixel-level contrast loss.

3. The X-ray image domain adaptation pulmonary nodule detection method based on contrast learning according to claim 1, characterized in that: The adversarial classification loss in step S4 The calculation method is as follows: The nodule-level features obtained from the source and target domains are input into the gradient reversal layer and the domain classifier. The domain classifier is used to discriminate feature maps during the domain adaptation process. The domain classifier extracts features through multi-layer convolution operations and uses leaky rectified linear units as activation functions. The discriminator finally outputs a single-channel discrimination result for distinguishing feature representations of the source domain and the target domain. The gradient reversal layer reverses the gradient direction during model training, thereby guiding the model to learn domain-independent features during feature extraction; Adversarial Classification Loss as follows: Among them, P represents the probability that the region-level feature belongs to the source domain; 1-P represents the probability that it belongs to the target domain; T represents the domain label, for the source domain image, T = 0, for the target domain image, T = 1; During back-propagation, the gradients of the gradient reversal layer are multiplied by a negative scalar, prompting the encoder to generate region-level features that are difficult to distinguish between the source and target domains.

4. The X-ray image domain adaptation pulmonary nodule detection method based on contrast learning according to claim 1, characterized in that: The weight update formula of the teacher model in step S5 is as follows: i t ←bth t +(1-β)θ s Among them, θ t represents the weight of the teacher model; θ s represents the weight of the student model; β represents the balance parameter.

5. The X-ray image domain adaptation pulmonary nodule detection method based on contrastive learning according to claim 1, characterized in that: After completing the model update in step S5, continue to perform the detection model test process in step S6. During the test, the model parameters that have been trained in the fixed training phase are selected, and the student model with the best performance in the training process is selected as the test model, and the target domain test set is used as the test data; First, the test data is input into the feature extraction module of the detection model; Then, the feature map is obtained through the feature extraction module. The region generation network determines the coordinates of the candidate region box for the feature map. Multiple regions of interest are mapped from the global feature map according to the region box coordinates. Each region of interest is further extracted for features and then classified to determine whether it contains a lung nodule and assigned a prediction score, which indicates the confidence level of the lung nodule. Finally, AP and AP are calculated by the coordinates and prediction scores of the final detection box and the target domain test set label. 50 ,AP 75 ,AP S ,AP M and AP L index.

Citation Information

Cited By

  • Multi-layer feature adaptive alignment cross-domain unmanned aerial vehicle target detection method and system

    CN120014241A

  • Red blood cell test time domain adaptation detection method based on average teacher model

    CN120031810A

  • Reverse distillation image anomaly detection method and device based on feature regulation and control, and medium

    CN120339647A

  • Domain adaptive target detection method based on comparative learning and diffusion model

    CN121616839A