Model training method, computer-aided diagnosis method, device, and storage medium

CN122929259APending Publication Date: 2026-10-16ALIBABA DAMO (BEIJING) TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610969677.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-30
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

然而,传统内镜诊断流程高度依赖医生的个人经验,存在诊断主观性强、效率低、漏诊率高等问题

Benefits of technology

[0020] The model training method, computer-aided diagnosis method, device, and storage medium provided in this application acquire a sample dataset containing examination record packages, package-level labels, and some phenotypic labels. They then perform bi-branch representation learning on image samples and train the encoder in the bi-branch by combining supervised contrast loss, phenotypic classification loss, and prediction consistency loss. Based on the trained encoder, they perform package-level prediction and optimization of the examination record packages, thereby optimizing the package classifier. This approach enhances both infection-related feature representation and multi-phenotypic semantic discrimination under weak supervision, improves the model's adaptability to endoscopic texture, lighting changes, and fine-grained phenotypic differences, and reduces the interference of redundant image information on diagnostic results. Ultimately, this improves the accuracy and stability of infection prediction, as well as the interpretability of the results in relation to clinical phenotypic evidence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122929259A_ABST
    Figure CN122929259A_ABST
Patent Text Reader

Abstract

The application provides a model training method, a computer-aided diagnosis method, equipment and a storage medium, and relates to the fields of medical image processing and artificial intelligence assisted diagnosis. The model training method comprises the following steps: based on sample data containing examination record packages, package-level labels and part of phenotype labels, after different enhancement of image samples, a student branch simultaneously completes infection discrimination and multi-phenotype learning, an exponential moving average is updated for a teacher branch, and an infection prediction probability is output to provide consistency constraint, and an encoder is optimized in combination with supervised contrast constraint, phenotype classification constraint and branch prediction consistency constraint; then, the trained encoder is used for package-level aggregation prediction of multiple images of a single examination, and a package classifier is trained to complete infection risk discrimination. The modeling capability for key phenotypes of gastric mucosa and complex image differences is effectively improved, the influence of redundant and low-quality frames is inhibited, and the accuracy, stability and interpretability of Helicobacter pylori infection prediction are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of medical image processing and artificial intelligence, and in particular to a model training method, a computer-aided diagnostic method, an apparatus, and a storage medium. Background Technology

[0002] In the field of modern medical diagnostics, especially in the detection of digestive tract diseases, endoscopy has become a key method for diagnosing infections such as Helicobacter pylori, Candida albicans, and Salmonella. However, the traditional endoscopic diagnostic process relies heavily on the physician's personal experience, resulting in problems such as strong diagnostic subjectivity, low efficiency, and a high rate of missed diagnoses.

[0003] With the widespread use of endoscopy, the amount of medical data is growing exponentially. However, the acquisition of high-quality image-level labeled data is costly and requires a great deal of manpower, resulting in a scarcity of labeled samples available for clinical use. Conventional fully supervised intelligent diagnostic models struggle to fully exploit the effective features of massive amounts of unlabeled image data, limiting their generalization ability and leading to poor prediction accuracy and robustness.

[0004] Therefore, there is an urgent need to provide a reliable model training method to improve the model's generalization ability in scenarios with a small number of labeled samples, thereby improving the accuracy of the model in predicting the probability of infection. Summary of the Invention

[0005] This application provides a model training method, a computer-aided diagnostic method, an apparatus, and a storage medium to address the aforementioned technical problems. This method is geared towards weakly supervised infection prediction tasks based on endoscopic examination record packages. It integrates image-level infection representation learning, fine-grained multi-phenotypic semantic modeling, and package-level diagnostic optimization. Multiple endoscopic images and their associated labels in the sample data are collaboratively trained to construct a model capable of simultaneously considering infection discrimination, phenotypic recognition, and overall prediction of the examination record package. This enhances the ability to utilize complex image information in weakly supervised endoscopic diagnostic tasks and improves the accuracy of phenotypic recognition.

[0006] In a first aspect, embodiments of this application provide a model training method, comprising: acquiring a sample dataset; the sample dataset includes multiple examination record packages and their package-level labels, the examination record package including multiple image samples obtained from endoscopic examinations, some of which have corresponding phenotypic labels; performing a first enhancement operation and a second enhancement operation on the image samples respectively, inputting them into a student branch and a teacher branch, obtaining the infection prediction probability and multi-phenotypic prediction probability of the image samples through the student branch, and obtaining the infection prediction probability of the image samples through the teacher branch; both the student branch and the teacher branch are composed of at least a portion of a pre-trained initial model, at least a portion of which includes an encoder; the multi-phenotypic prediction probability is used to characterize the probability of belonging to each phenotype among multiple phenotypes; based on supervised contrast loss, phenotypic classification loss, and prediction consistency loss... The parameters of the student branch are updated, and the parameters of the teacher branch are smoothly updated using the updated student branch parameters through an exponential moving average algorithm until the first training termination condition is met, resulting in the trained encoder. The supervised contrastive loss includes multi-label supervised contrastive loss, which is related to the multi-phenotype prediction probability; the prediction consistency loss is related to the infection prediction probability output by the student and teacher branches; and the phenotype classification loss is related to the multi-phenotype prediction probability and its corresponding phenotype label. Multiple image samples of the inspection record packet are input into the infection prediction model to obtain the packet-level prediction probability. The infection prediction model includes the trained encoder and packet classifier. The packet classifier is updated based on the packet-level loss until the second training termination condition is met. The packet-level loss is related to the packet-level prediction probability and the packet-level label.

[0007] In one possible embodiment, in the teacher branch, the encoder is connected to a bag classifier and an instance projector, respectively; in the student branch, the encoder is connected to a bag classifier, an instance classifier, and an instance projector, respectively; the bag classifier is used to output the infection prediction probability, the instance projector is used to convert the encoder output into an embedding vector; the instance classifier is used to output the multi-phenotype prediction probability; when calculating the multi-label supervised contrastive loss, the embedding vector pairs that satisfy the following condition are positive sample pairs: the values ​​of the binarized label vectors corresponding to the multi-phenotype prediction probabilities are all 1 at least under the same phenotype.

[0008] In one possible embodiment, the method further includes: updating the embedding queue based on the newly generated second embedding vector in each round; the second embedding vector being the embedding vector output by the instance projector of the teacher branch; obtaining a set of positive sample pairs and a set of negative sample pairs based on the binarized label vectors corresponding to the multi-phenotypic prediction probabilities of each embedding vector in the contrast embedding pool; the contrast embedding pool being the union of the first embedding vector of the current batch, the second embedding vector of the current batch, and the embedding queue; the first embedding vector being the embedding vector output by the instance projector of the student branch; and calculating the multi-label supervised contrastive loss based on each sample pair in the set of positive sample pairs and the set of negative sample pairs.

[0009] In one possible embodiment, the embedding queue is updated based on the newly generated second embedding vector in each round, including: for each second embedding vector in the embedding queue and the newly generated second embedding vector in each round, determining the scarcity benefit of the second embedding vector based on the binarized label vector corresponding to the second embedding vector and the phenotypic distribution of the embedding queue; calculating the retention score of the second embedding vector based on the scarcity benefit and the number of survival rounds; when the embedding vector in the embedding queue reaches the upper limit, if the retention score of the second embedding vector is higher than the retention score of the target embedding vector, the target embedding vector is removed and the second embedding vector is added to the embedding queue; the target embedding vector is the embedding vector with the lowest retention score in the embedding queue.

[0010] In one possible embodiment, the supervised contrast loss further includes a prototype contrast loss. The method further includes: generating an instantaneous pseudo-label for each image sample based on the similarity between the first embedding vector and each prototype in the global prototype, for each image sample's first embedding vector; the first embedding vector is the embedding vector output by the instance projector of the student branch; updating the pseudo-labels of the image samples in the pseudo-label library using a moving average algorithm based on the instantaneous pseudo-labels; determining the positive sample prototype set and negative sample prototype set of the image samples from each prototype in the global prototype based on the binarized label vectors corresponding to the updated pseudo-labels in the pseudo-label library; calculating the prototype contrast loss based on the positive sample prototype set and negative sample prototype set of each image sample; estimating the batch prototype of the current batch based on the first embedding vector and its corresponding binarized label vector of each image sample in the current batch; and updating the global prototype based on the batch prototype of the current batch.

[0011] In one possible embodiment, in the infection prediction model, the trained encoder is connected to the packet classifier via an integrator; the integrator takes the image features of each image sample in the same inspection record packet output by the encoder as input, and aggregates the input image features based on an attention mechanism guided by multi-phenotypic prediction probabilities to obtain a packet-level representation; wherein, the multi-phenotypic prediction probabilities are inferred by the trained instance classifier from each image sample; the packet classifier is used to determine the packet-level prediction probabilities based on the packet-level representation.

[0012] In one possible embodiment, the integrator includes a cross-instance interaction module, a feature modulation module, and a phenotype-guided attention module. The cross-instance interaction module performs cross-instance interaction on image features of the same inspection record package to obtain enhanced features for each instance. The feature modulation module calculates and normalizes the similarity between the embedding vectors of each instance, and determines the local density of each instance based on the normalized similarity of multiple neighboring instances. Based on the local density, the normalized similarity of each instance is adjusted to obtain modulated similarity. Based on the modulated similarity, the attention weight of each instance is determined, and the enhanced features of each instance are enhanced based on the attention weight of each instance. The features after feature mapping are weighted to obtain modulation features; the embedding vector of each instance is obtained by inference of each image sample by the trained instance projector; the phenotypic guided attention module is used to determine the attention score of each instance based on the modulation features of each instance using a gated attention mechanism; the phenotypic guided distribution of each instance is determined based on the multiphenotypic prediction probability of each image sample and the packet-level label of the inspection record packet to which it belongs; the attention score of each instance is regularized based on the phenotypic guided distribution of each instance to obtain the phenotypic attention weight; the modulation features and enhancement features of each instance are weighted and fused based on the phenotypic attention weight to obtain the packet-level representation.

[0013] In one possible embodiment, the packet-level loss includes packet-level classification loss and attention regularization loss; the method further includes: calculating attention regularization loss based on the phenotypic guidance distribution and attention score obtained in the same batch; and calculating packet-level classification loss based on the packet-level prediction probability and corresponding packet-level label obtained in the same batch.

[0014] In one possible embodiment, before inputting the student branch and teacher branch to obtain the infection prediction probability and multiphenotype prediction probability of the image samples after performing the first enhancement operation and the second enhancement operation on the image samples respectively, the method further includes: pre-training the encoder, instance classifier and instance projector in the initial model based on the labeled image samples until the first pre-training termination condition is met, to obtain the pre-trained encoder, instance classifier and instance projector; and pre-training the bag classifier in the initial model connected to the pre-trained encoder based on the sample dataset until the second pre-training termination condition is met, to obtain the pre-trained bag classifier, so as to form the teacher branch and the student branch through the pre-trained encoder, bag classifier, instance classifier and instance projector.

[0015] Secondly, embodiments of this application provide a computer-aided diagnostic method based on medical images, comprising: acquiring multiple endoscopic images obtained from an endoscopic examination; inputting the multiple endoscopic images into a trained infection prediction model to obtain an infection probability; wherein the infection prediction model is trained based on the method provided in the first aspect of this application.

[0016] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, causing the processor to perform the method provided above.

[0017] Fourthly, embodiments of this application provide a computer-aided diagnostic system based on medical images, including an image terminal and an image analysis terminal; the image terminal is used to store or cache endoscopic images obtained from endoscopic examinations and initiate an auxiliary diagnostic request to the image analysis terminal, the auxiliary diagnostic request carrying multiple endoscopic images obtained from the endoscopic examination; the image analysis terminal is used to parse the multiple endoscopic images from the auxiliary diagnostic request, input the multiple endoscopic images into a trained infection prediction model to obtain the infection probability, and feed the infection probability back to the image terminal; wherein, the infection prediction model is trained based on the method provided in the first aspect of this application.

[0018] Fifthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided above.

[0019] Sixthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method provided above.

[0020] The model training method, computer-aided diagnosis method, device, and storage medium provided in this application acquire a sample dataset containing examination record packages, package-level labels, and some phenotypic labels. They then perform bi-branch representation learning on image samples and train the encoder in the bi-branch by combining supervised contrast loss, phenotypic classification loss, and prediction consistency loss. Based on the trained encoder, they perform package-level prediction and optimization of the examination record packages, thereby optimizing the package classifier. This approach enhances both infection-related feature representation and multi-phenotypic semantic discrimination under weak supervision, improves the model's adaptability to endoscopic texture, lighting changes, and fine-grained phenotypic differences, and reduces the interference of redundant image information on diagnostic results. Ultimately, this improves the accuracy and stability of infection prediction, as well as the interpretability of the results in relation to clinical phenotypic evidence. Attached Figure Description

[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0022] Figure 1 Flowchart of the model training method provided in this application Figure 1 ;

[0023] Figure 2 A schematic diagram of the teacher and student branches provided for this application;

[0024] Figure 3 A schematic diagram of the architecture of the infection prediction model provided in this application;

[0025] Figure 4 For this application Figure 3 The diagram shows the architecture of the integrator.

[0026] Figure 5 A schematic diagram of the structure of the model training device provided in this application;

[0027] Figure 6 A schematic diagram of the structure of the electronic device provided in this application.

[0028] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0030] It should be noted that, in the case of user information involved in the embodiments of this application, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant laws, regulations and standards, and provide corresponding operation entry points for users to choose to authorize or refuse.

[0031] Endoscopic-assisted diagnosis of Helicobacter pylori infection falls under the interdisciplinary technical field of medical image processing, computer-aided diagnosis, and intelligent medical analysis, and is mainly applied in hospital digestive endoscopy centers, physical examination centers, and remote image reading platforms.

[0032] In actual clinical practice, after a patient completes a gastroscopy, the endoscope continuously outputs images or videos of the gastric body, antrum, angle, and cardia. This data is transmitted to the examination workstation, image storage system, and subsequent analysis module. Doctors typically need to combine the gastric mucosal surface texture, color changes, vascular arrangement, and local inflammatory manifestations to make a comprehensive assessment of the Helicobacter pylori infection status.

[0033] To improve efficiency, existing systems often form a weakly supervised analysis architecture among endoscopic equipment, image acquisition terminals, server-side models, and diagnostic display interfaces. This architecture uses a single examination record as the basic analysis unit, inputs multiple images acquired during the examination into the model, and outputs the infection risk or classification result corresponding to the examination, thereby achieving package-level risk prediction.

[0034] In existing technologies, common approaches for weakly supervised endoscopic diagnostic tasks typically rely on multi-instance learning and deep learning models. These models treat multiple images collected during a single endoscopic examination as a single examination record package, using the infection label of this package as a supervisory signal for training. In practice, the model usually first extracts features from each image, then integrates these features into a package-level representation using average pooling, max pooling, attention aggregation, or other instance aggregation methods, ultimately outputting a prediction of negative or positive Helicobacter pylori infection.

[0035] Because endoscopic examinations naturally involve a large number of non-critical images, such as esophageal images before and after entering the stomach, repeated frames formed by multiple scans of the same area, blurred frames caused by lens movement, and low-quality frames affected by liquids, reflections, or instrument obstructions, these images, when used in training alongside key lesion frames, can easily interfere with the packet-level representation. This can cause the model to learn statistical patterns that deviate from the pathological essence during training, and may result in unstable outputs during inference due to excessive redundancy. Furthermore, existing solutions heavily rely on general visual pre-trained models to encode endoscopic images. These models are typically better at recognizing edges, shapes, and textures in natural scenes, but have limited adaptability to the subtle textures, color variations, and local vascular and inflammatory features specific to the gastric mucosa, easily leading to insufficient feature representation.

[0036] Furthermore, the diagnosis of Helicobacter pylori-related diseases cannot be accomplished solely through coarse-grained positive and negative results. Clinically, attention is often paid to fine-grained phenotypes such as diffuse redness, mucosal atrophy, and regularly arranged collecting veins. However, existing methods have weak learning capabilities for these phenotypes, especially when some phenotype samples are scarce, making it difficult to establish stable discrimination boundaries and resulting in insufficient recognition of low-frequency but crucial imaging features. Moreover, the output of existing models often presents as single-classification probabilities, rarely establishing clear correlations between the image layer, phenotype layer, and examination record layer simultaneously. This makes it difficult for physicians to directly understand the basis of the judgment from the model results, thus affecting clinical acceptance. Therefore, while existing solutions can achieve a certain degree of bag-level classification under weak supervision, they still have significant shortcomings in redundancy interference suppression, fine-grained phenotype modeling, intra-domain feature adaptation, and interpretability of diagnostic results, failing to meet the comprehensive requirements of accuracy, stability, and reliability in real-world clinical scenarios.

[0037] In view of this, how to balance infection discrimination at the image sample level, fine-grained phenotypic learning, and packet-level prediction at the examination record level in weakly supervised endoscopic diagnosis, and improve model training quality under limited phenotypic annotation conditions, has become an urgent technical problem to be solved. To address this problem, this application provides a model training method applicable to intelligent diagnosis of Helicobacter pylori infection during endoscopic examination. During model training, after performing different enhancement operations on image samples, the data is input into student and teacher branches respectively to obtain the infection prediction probability, multi-phenotype prediction probability, and the infection prediction probability corresponding to the teacher branch. Subsequently, the student branch parameters are updated based on supervised contrast loss, phenotypic classification loss, and prediction consistency loss, and the teacher branch parameters are smoothly updated using the updated student branch parameters through an exponential moving average algorithm to complete encoder training. Based on this, multiple image samples from the examination record are then input into the infection prediction model containing the trained encoder and packet classifier to obtain packet-level prediction probabilities, and the packet classifier is updated based on the packet-level loss until training is complete. This technical approach improves the model's ability to adapt to complex differences in endoscopic images and enhances its learning effect on key phenotypic information by combining infection prediction and multiphenotypic prediction at the image sample level and completing overall discrimination at the examination record package level. This improves the accuracy and stability of the auxiliary diagnosis of Helicobacter pylori infection.

[0038] Figure 1 Flowchart of the model training method provided in this application Figure 1 ,like Figure 1 As shown, the model training method includes:

[0039] S101: Obtain the sample dataset; the sample dataset includes multiple examination record packages and their package-level labels. The examination record package includes multiple image samples obtained from endoscopic examinations, and some image samples have corresponding phenotypic labels.

[0040] In this embodiment, the sample dataset serves as the input foundation for model training, providing examination record packages, package-level labels, and phenotypic labels for some image samples to support subsequent instance-level and package-level training processes. Examination record packages, as the basic package-level sample units for training and prediction, aggregate multiple image samples from a single endoscopic examination to facilitate subsequent package-level prediction and package-level loss optimization. Package-level labels are used to supervise infection outcome learning at the examination record package level; they correspond to the overall infection status of each examination record package and can be manually labeled or based on breath tests, pathological examinations, rapid urease tests, or clinical diagnostic results. Image samples are instance-level input objects for the model, typically consisting of static images acquired during gastroscopy or frame images extracted from video. Phenotypic labels characterize the fine-grained phenotypes of the image samples, such as diffuse redness, mucosal atrophy, regularly arranged collecting veins, nodular changes, fold swelling, or localized inflammatory phenotypes, to support subsequent multi-phenotype prediction probability learning and the establishment of contrastive constraints.

[0041] In specific implementation, the executing entity of this application embodiment can be a hospital endoscopy workstation, a medical image analysis server, a training server on a remote image reading platform, or a dedicated computing device with image processing capabilities.

[0042] The sample dataset can be constructed by summarizing historical endoscopic examination records, or it can be automatically segmented into image samples from the video stream output by the endoscopy host after the examination is completed. Combined with the examination number, patient number and pathology results in the hospital information system, an examination record package and corresponding package-level tags are generated.

[0043] For multiple image samples in the same examination record package, they can be saved in chronological order, or deduplication, sharpness filtering, and location filtering can be performed during the preprocessing stage to reduce the interference of esophageal transition images, excessively blurred images, strongly reflective images, and images obscured by instruments on training.

[0044] Phenotypic labels for some image samples can be manually annotated by qualified endoscopists on an annotation platform, or automatically mapped from existing structured reports and then manually reviewed and confirmed.

[0045] To ensure stable training, the sample dataset is typically partitioned before entering the training process. For example, it can be divided into training, validation, and test sets according to the dimensions of the inspection record package. This is to prevent different image samples from the same inspection record from being assigned to different data subsets at the same time, which could lead to information leakage.

[0046] At the data organization level, each examination record package contains at least one package-level label, multiple image samples, and phenotypic labels for some of the image samples. The number of image samples can vary depending on the actual examination length. To address differences in image size, color space, and acquisition device, embodiments of this application can perform preprocessing such as uniform resolution scaling, pixel normalization, color standardization, and file format conversion before writing the data to the training cache. This ensures that images acquired by different endoscopic devices have a comparable representation basis when input into the model.

[0047] For some image samples with phenotypic labels, multi-label annotation vectors can be created to represent that a single image simultaneously possesses annotation information for multiple phenotypic types. This annotation vector can be a binary vector containing multiple elements with values ​​of 0 or 1, representing the label under the corresponding phenotypic type.

[0048] The inspection record package obtained from a single inspection can be represented as: ,in, Represents a single image sample. To check the total number of image samples in the record package. Package-level tags. A value of 0 indicates negative (no infection), while a value of 1 indicates positive (infection). For some instances, i.e., some image samples, the phenotypic label can be represented as a binary vector, namely, a phenotypic binary vector, based on the sample images. For example, its phenotypic binary vector It can be represented as:

[0049]

[0050] in, The number of clinically defined phenotypes. Represents image samples In the The phenotypic label under each phenotypic is either 0 or 1.

[0051] Based on the above analysis, it is evident that by organizing a single examination into an examination record package and overlaying phenotypic labels from some image samples on top of the package-level labels, both coarse-grained infection supervision information (package-level labels) and fine-grained phenotypic supervision information (phenotypic labels) can be provided simultaneously. This provides more comprehensive data support for the subsequent encoder to learn gastric mucosa-related characterizations. This data construction method can alleviate the problem of difficulty in explicitly modeling fine-grained pathological characterizations when relying solely on package-level labels and reduce the interference of a large number of redundant frames on the overall learning direction.

[0052] S102: After performing the first enhancement operation and the second enhancement operation on the image samples respectively, input the student branch and the teacher branch. Obtain the infection prediction probability and multiphenotype prediction probability of the image samples through the student branch, and obtain the infection prediction probability of the image samples through the teacher branch.

[0053] Both the student and teacher branches consist of at least a portion of the pre-trained initial model, including at least a portion of the encoder; the multi-phenotype prediction probability is used to characterize the probability of belonging to each phenotype among multiple phenotypes. These multiple phenotypes are specifically clinically defined. Phenotypic types. The phenotypic labels corresponding to the image samples in the sample dataset include... Labels under each phenotype.

[0054] In this embodiment, the first enhancement operation is used to generate the input view of the student branch, and the second enhancement operation is used to generate the input view of the teacher branch. Both are performed on the same original image sample but with different enhancement parameters, different enhancement order, or different enhancement intensity, so as to construct a dual-view input with semantic consistency but different pixel distribution.

[0055] The student branch carries the trainable main learning path, and its output includes the infection prediction probability and multiphenotype prediction probability of the image sample. The teacher branch provides stable auxiliary predictions, and its output includes at least the infection prediction probability of the image sample to form a consistency constraint with the infection prediction probability of the student branch. The pre-trained initial model provides shared basic representation capabilities, such as an encoder, for both branches. The encoder's role is to extract feature representations from the endoscopic images, and the extraction results can be used by subsequent infection prediction heads and phenotype prediction heads. The infection prediction probability is used to characterize the prediction result of the current image sample in the infection determination dimension, and the multiphenotype prediction probability is used to characterize the probability distribution of the current image sample belonging to each of the multiple phenotypes, thereby achieving parallel learning of fine-grained gastric mucosal phenotypes.

[0056] In one possible embodiment, the pre-trained initial model can be implemented using a convolutional neural network, a visual Transformer network, or a hybrid network combining both, and the encoder can be ResNet (Residual Network), EfficientNet, Swing Transformer, or other structures suitable for medical image representation learning.

[0057] The student branch can connect to an infection classification head and a phenotypic classification head after the encoder. The infection classification head outputs infection prediction probabilities in binary or multi-class classification, while the phenotypic classification head outputs multi-label multi-phenotypic prediction probabilities. The teacher branch can retain the encoder and infection classification head structures corresponding to the student branch to produce smooth prediction results within the same task space.

[0058] The first or second enhancement operation performed before the image sample is input may include one or a combination of processes such as random cropping, scaling, brightness adjustment, contrast adjustment, color cast perturbation, Gaussian blur, slight rotation, random erasure, and specular suppression simulation or local occlusion simulation designed for the characteristics of endoscopic images.

[0059] Given the importance of color and texture in endoscopic images for infection assessment, the enhancement parameters used during enhancement operations are usually controlled within a range that does not damage the recognizability of key mucosal structures. For example, the color perturbation amplitude is kept within a preset threshold, and the rotation angle is limited to a small angle range, thereby avoiding the enhanced image from deviating from the true medical semantics.

[0060] Specifically, for each input image sample, the original pixel matrix is ​​first read, and a first enhancement parameter set and a second enhancement parameter set are generated based on a random number seed. Then, the first enhancement parameter set is used to perform a first enhancement operation on the image sample to obtain the student branch view; the second enhancement parameter set is used to perform a second enhancement operation on the image sample to obtain the teacher branch view. After the student branch view is input, the encoder extracts the feature vector, which is then fed into the infection classification head and the multiphenotype classification head, respectively, outputting the infection prediction probability and the multiphenotype prediction probability. After the teacher branch view is input, it is processed by its encoder and the infection classification head, outputting the teacher-side infection prediction probability.

[0061] By employing different enhancement operations, on the one hand, the model's robustness to device differences, noise, and sampling fluctuations is improved by utilizing consistent semantics under different views. On the other hand, by synchronously learning infection and phenotypic tasks through student branches, the encoder is no longer limited to coarse-grained package-level label-driven processing, but can further capture fine-grained representations related to Helicobacter pylori infection, such as gastric mucosal color levels, micro-textures, and local vascular arrangements, thereby enhancing the domain feature adaptation capability.

[0062] S103: Update the parameters of the student branch based on supervised contrast loss, phenotypic classification loss and prediction consistency loss, and use the updated student branch parameters to smoothly update the parameters of the teacher branch using the exponential moving average algorithm until the first training termination condition is met, thus obtaining the trained encoder.

[0063] Among them, the supervised contrast loss includes multi-label supervised contrast loss, which is related to the multi-phenotype prediction probability; the prediction consistency loss is related to the infection prediction probability output by the student branch and the teacher branch; and the phenotype classification loss is related to the multi-phenotype prediction probability and its corresponding phenotype label.

[0064] Supervised contrastive loss is used to jointly constrain the distribution relationship of image samples in the feature space, bringing image samples with the same or related phenotypic features closer together in the embedding space and keeping image samples with significant phenotypic differences further apart, thereby improving the encoder's ability to distinguish fine-grained phenotypes of the gastric mucosa. This supervised contrastive loss includes multi-label supervised contrastive loss, which is related to the multi-phenotype prediction probability. This is because endoscopic images may simultaneously present multiple phenotypes, and using a multi-label approach can better reflect the complex phenotypes of real clinical images.

[0065] Phenotypic classification loss is used to constrain the consistency between the multi-phenotypic prediction probabilities output by the student branches and the labeled phenotypic tags. It can be implemented using binary cross-entropy loss, weighted cross-entropy loss, or focal loss to alleviate phenotypic class imbalance.

[0066] The prediction consistency loss is used to constrain the infection prediction probabilities output by the student branch and the teacher branch to remain close. It can be implemented using mean squared error, KL (Kullback-Leibler) divergence, or cross-entropy distance.

[0067] The Exponential Moving Average (EMA) algorithm is used to smoothly update the parameters of the teacher branch, allowing the teacher branch to follow the changes in the student branch at a slower pace, thus reducing the instability caused by drastic parameter oscillations during training. Specifically, the EMA algorithm is used to slowly and iteratively update the network parameters of the teacher branch in an exponentially smooth manner, without backpropagation or direct gradient optimization.

[0068] The first training termination condition is used to determine whether instance-level joint training is complete. It can be set to reach a preset number of training rounds or a preset training duration, convergence of the validation set loss, no further improvement in the validation set performance within a certain number of consecutive rounds, or a combination of these conditions.

[0069] In practical implementation, the student branch outputs the infection prediction probability, multi-phenotype prediction probability, and intermediate feature embedding for a training batch. For image samples with phenotypic labels, the phenotypic labels can be pre-organized into binary vectors. Then, based on these binary vectors, it can be determined whether different samples share at least one phenotypic category, or the sample similarity can be calculated based on the number of shared phenotypic types. In this way, the multi-label supervised contrastive loss can not only define positive and negative sample pairs, but also assign different weights according to the degree of phenotypic overlap, making the relationship modeling of composite phenotypic samples in the feature space more consistent with medical semantics.

[0070] In one exemplary implementation, for sample images and Their respective phenotypic binary vectors and Then, according to and The overlap of elements with a value of 1 or the Jaccard (Jaccard Similarity Coefficient) similarity coefficient determines the degree of positive correlation between the two samples, and this correlation is used as a weight term in the supervised contrastive loss. This approach avoids simply treating partially similar phenotypic samples as completely positive or completely negative samples, thereby improving the continuity and accuracy of the embedding space construction.

[0071] In the joint loss optimization phase, the total loss can be expressed as the weighted sum of the individual losses. The expression for the total loss can be:

[0072]

[0073] in, Indicates the comparative loss under supervision. This represents the phenotypic classification loss. This represents the loss of prediction consistency. , and This represents the weight coefficient of the corresponding loss term. Each weight coefficient can be adjusted using the validation set to achieve a relative balance between fine-grained phenotypic learning, consistency constraints, and main task learning.

[0074] Student branch parameters are updated via backpropagation and gradient descent algorithms. The optimizer can employ SGD (Stochastic Gradient Descent), Adam (Adaptive Moment Estimation), or AdamW (Adam with Decoupled Weight Decay). After the student branch is updated, the teacher branch parameters are updated according to the exponential moving average formula, i.e. ,in This indicates the current parameter of the teacher branch. This indicates the updated student branch parameters. This represents the momentum coefficient. The momentum coefficient is usually set to a value close to 1 to make teacher branch updates smoother. Its role is to provide a relatively stable soft objective for student branches and reduce the impact of single-batch perturbations on consistent learning.

[0075] As the training rounds progress, the encoder gradually forms a domain feature representation that is more suitable for gastroscopy images under the combined effect of contrast constraints, phenotypic supervision, and infection consistency constraints. In particular, it can enhance the perception of low-frequency key phenotypes and weakly significant pathological signs.

[0076] Based on the above analysis, this step is a key step in solving the problem of insufficient adaptation of general visual features to the fine representation of gastric mucosa and insufficient utilization of fine-grained information under weak bag-level supervision in the existing technology. By combining instance-level multi-task learning with teacher-student consistency mechanism, the training quality of encoder can be improved under limited phenotypic annotation conditions, and the trained encoder can be used as a stable feature extraction basis for subsequent bag-level learning.

[0077] S104: Input multiple image samples from the inspection record into the infection prediction model to obtain the packet-level prediction probability; the infection prediction model includes a trained encoder and a packet classifier.

[0078] In this embodiment, the trained encoder, building upon the training results of the first stage, extracts image features from multiple image samples within the same examination record package. The infection prediction model consists of the trained encoder and a package classifier. The package classifier receives features from multiple instances within the same examination record package and outputs the package-level prediction probability for the corresponding package. The package-level prediction probability represents the prediction result of the entire examination record package at the Helicobacter pylori infection level, rather than being limited to the judgment at the single image level. Since clinical judgment is usually based on a single examination, package-level prediction better aligns with the workflow of doctors reviewing images and issuing reports.

[0079] In practice, for a specific inspection record package, all image samples in the package can be read in a preset order, or the number of image samples can be standardized. For example, when the number of images is too large, a fixed number of image samples can be sampled according to the time interval, image quality score, or part coverage strategy. When the number of images is small, the batch shape can be maintained by repeated sampling or placeholder filling.

[0080] Each image sample is processed by the trained encoder to obtain an instance feature vector. Multiple instance feature vectors from the same examination record packet are then input into the packet classifier. The packet classifier can be implemented using average pooling aggregation, max pooling aggregation, attention aggregation, multi-head attention aggregation, or a Transformer-based sequence aggregation structure. If attention aggregation is used, the packet classifier can assign higher weights to image samples with greater infection discrimination value and lower weights to duplicate frames, blurred frames, and low-quality frames, thus making the packet-level representation more focused on key gastric mucosal regions. Finally, the packet classifier outputs a packet-level prediction probability based on the aggregated packet-level representation. This probability can be the infection positive probability or a probability distribution of negative and positive results.

[0081] In one exemplary implementation, a single examination record package contains N image samples, and the trained encoder obtains a feature set. The package classifier first calculates the attention weight for each feature, aggregates these attention weights to form a package-level representation, and then obtains the package-level prediction probability through a fully connected layer and an activation function. These attention weights reflect the degree of contribution of different image samples to the final package-level judgment; therefore, in addition to being used for training, they can also provide some interpretive clues for subsequent clinical display, such as identifying keyframes with high contributions.

[0082] Based on the above analysis, it can be seen that applying the post-trained encoder obtained in the first stage to the packet-level prediction model can transfer the fine-grained phenotypic learning results to the check record level decision, so that the packet-level classification no longer relies solely on coarse instance averaging, but completes aggregation in a more discriminative feature space. This helps to reduce the interference of redundant images on the overall results and improve the prediction stability at the check record level.

[0083] S105: Update the packet classifier based on packet-level loss until the second training termination condition is met; the packet-level loss is related to the packet-level prediction probability and the packet-level label.

[0084] In this embodiment, the packet-level loss is used to supervise the packet classifier's learning of the overall infection label of the recorded packets, so that the packet-level prediction probability gradually approaches the true packet-level label. The packet-level loss can be constructed based on the deviation between the packet-level prediction probability and the packet-level label, for example, using binary cross-entropy loss, multi-class cross-entropy loss, weighted cross-entropy loss, or focus loss. For training sets with imbalanced class distribution, class weights can be introduced into the packet-level loss to alleviate the bias caused by the difference in the number of positive and negative packets. The second training termination condition is used to determine whether the packet classifier training is complete, and can be set to conditions such as reaching a preset number of training rounds, convergence of the validation set packet-level loss, and the validation set accuracy or AUC (Area Under the ROC Curve) no longer improving within a certain number of consecutive rounds.

[0085] After the infection prediction model outputs the packet-level predicted probability, the packet-level loss is calculated based on the packet-level label corresponding to the current inspection record packet, and the packet classifier parameters are updated only through backpropagation.

[0086] In one alternative implementation, the trained encoder is kept frozen in the second stage, and only the bag classifier is trained to make full use of the stable feature representations obtained in the first stage and avoid the gradient backlash caused by coarse bag-level labels interfering with the encoder's fine-grained representation capabilities.

[0087] In another alternative implementation, a small learning rate can be fine-tuned in the second stage for a few layers in the later part of the encoder to further adapt to the packet-level task, but the core training still revolves around the packet classifier. In each training round, batches are formed from multiple inspection record packets, and the predicted probability and its corresponding loss for each packet are calculated. Then, the losses are averaged or weighted and summarized to complete a parameter update. To prevent overfitting, early stopping strategies, weight decay, batch normalization statistical freezing, or validation set model selection mechanisms can be used.

[0088] After training convergence, a complete infection prediction model is obtained that can output infection risk results based on inspection records.

[0089] Based on the above analysis, it can be seen that the second stage, by driving the packet classifier learning through packet-level loss, can effectively elevate the instance-level discrimination ability formed in the first stage to the examination record-level decision-making level, thereby adapting to the actual needs of providing infection judgments based on a single examination in hospital endoscopic-assisted diagnosis. Compared with existing simple multi-instance aggregation schemes, the embodiments of this application first explicitly model infection-related phenotypes at the image sample level, and then perform classification training at the packet level. Therefore, the packet classifier does not receive ordinary general visual features, but rather endoscopy-specific representations optimized by phenotypic supervision, contrast constraints, and consistency mechanisms. This enables more accurate differentiation between key pathological frames and redundant interference frames, thereby improving the accuracy, stability, and clinical interpretability of packet-level prediction.

[0090] The model training method provided in this application integrates instance-level infection prediction, multi-phenotype prediction, supervised contrastive learning, and teacher-student consistency learning into the first-stage training process to complete encoder training. The trained encoder is then introduced into the second-stage packet-level prediction training. This improves the learning ability for fine-grained gastric mucosal phenotypes under limited phenotype annotation conditions, enhances adaptability to different devices, different field-of-view switching, and complex noise interference, and outputs more stable Helicobacter pylori infection prediction results at the examination record level. Furthermore, this technical approach considers the information association at three granularities: image sample layer, phenotype layer, and examination record layer, enabling the auxiliary diagnostic model to have higher accuracy, consistency, and practical usability in real clinical scenarios.

[0091] Figure 2 The architectural diagram of the teacher branch and student branch provided for this application is as follows: Figure 2As shown, in the teacher branch, the encoder is connected to a bag classifier and an instance projector; in the student branch, the encoder is connected to a bag classifier, an instance classifier, and an instance projector. The bag classifier is used to output the infection prediction probability, and the instance projector is used to convert the encoder output into an embedding vector. The instance classifier is used to output the multi-phenotype prediction probability. When calculating the multi-label supervised contrastive loss, the embedding vector pairs that meet the following conditions are considered positive sample pairs: the values ​​of the binary label vectors corresponding to the multi-phenotype prediction probabilities are all 1 at least under the same phenotype.

[0092] The packet classifier is connected to the encoder output and maps the encoded features output by the encoder to Helicobacter pylori infection probability values. These probability values ​​are normalized using a sigmoid function to obtain the infection prediction probability, which is then output. In the first training phase, the packet classifier can predict the infection prediction probability for only a single image. The instance classifier is connected to the encoder output in the student branch and is used to distinguish between multiple gastric mucosal phenotypes corresponding to a single image, outputting the probability distribution of each phenotype. The instance projector is connected to the encoder output and can consist of a fully connected layer, a normalization layer, and an activation layer in sequence. It is used to compress high-dimensional encoded features into low-dimensional embedding vectors suitable for contrastive learning, preserving the semantic distance relationship between samples. In practical applications, the instance projector can also use other network layer combinations; this embodiment does not limit this.

[0093] In constructing the multi-label supervised contrastive loss, the multi-phenotypic predicted probabilities output by the instance classifier are first thresholded to obtain a binary label vector corresponding to each image sample. Then, the embedding vectors are paired and their binary label vectors are compared. If two samples have a value of 1 in at least the same phenotypic (i.e., at least one element with a value of 1 is in the same position), the pair of embedding vectors is determined as a positive sample pair, so that they can be trained to be closer to each other in the feature space. If this condition is not met, the pair of embedding vectors is regarded as a negative sample pair and participates in the loss constraint.

[0094] The packet classifier and instance projector in the teacher branch are used to provide stable infection discrimination features and contrastive learning representations. The packet classifier, instance classifier and instance projector in the student branch work together to achieve packet-level infection prediction, multi-phenotype discrimination and contrastive embedding generation, so that the model can learn infection information at the record level and phenotypic information at the image sample level at the same time.

[0095] After the instance projector parameters of the student branch are updated, the instance projector of the teacher branch can be updated using the updated instance projector parameters of the student branch through the exponential moving average (EMA) algorithm.

[0096] Through the aforementioned connection relationships and sample pair construction methods, the model can aggregate image samples with shared phenotypes in the embedding space, making the feature representation more consistent with the semantic structure of endoscopic phenotypes, while enhancing the stability of the discriminative features upon which infection classification depends. Therefore, in the auxiliary diagnosis of Helicobacter pylori infection, it can reduce the interference of redundant frames and low-quality images on feature learning, improve multi-phenotype recognition capabilities, and enhance the accuracy and consistency of packet-level infection prediction.

[0097] In one possible implementation, the method further includes: updating the embedding queue based on the newly generated second embedding vector in each round; the second embedding vector is the embedding vector output by the instance projector of the teacher branch; obtaining a set of positive sample pairs and a set of negative sample pairs based on the binarized label vectors corresponding to the multi-phenotypic prediction probabilities of each embedding vector in the contrast embedding pool; the contrast embedding pool is the union of the first embedding vector of the current batch, the second embedding vector of the current batch, and the embedding queue; the first embedding vector is the embedding vector output by the instance projector of the student branch; and calculating the multi-label supervised contrastive loss based on each sample pair in the set of positive sample pairs and the set of negative sample pairs.

[0098] The embedding queue stores the second embedding vectors generated in previous rounds and, together with the embeddings of the current batch, forms the contrast space to expand the range of samples that can participate in contrastive learning. The second embedding vector is the feature representation of the teacher branch after mapping by the instance projector; its dimension can be consistent with the first embedding vector to facilitate subsequent similarity calculations. The contrastive embedding pool is the union of the first embedding vector of the current batch, the second embedding vector of the current batch, and the embedding queue, facilitating the selection of positive and negative sample pairs within a unified feature space. The set of positive sample pairs represents embedding vector pairs where the value is 1 on at least one phenotypic label, and the set of negative sample pairs represents embedding vector pairs where the value is not 1 on any of the phenotypic labels. A value of 1 indicates a positive result for the corresponding phenotype, meaning the presence of a lesion of that phenotype.

[0099] In practical implementation, the instance projector of the teacher branch can be composed of a fully connected layer or a multilayer perceptron. Its output second embedding vector is normalized and then written into an embedding queue. The embedding queue can be set to a fixed-length first-in-first-out structure to control the size of historical samples and maintain training stability. Whenever a new second embedding vector is generated, it is appended to the tail of the embedding queue. When the embedding queue is full, the earliest entered vector is removed or the historical vector with the lowest value is retained, so that the queue continuously reflects the recent feature distribution.

[0100] After the instance projector of the student branch outputs the first embedding vector, it participates in the construction of the contrastive embedding pool together with the second embedding vector of the corresponding batch in the same batch dimension, so as to enhance the phenotypic representation constraints between the student branch and the teacher branch.

[0101] Based on the multi-phenotypic prediction probabilities corresponding to each embedding vector in the contrastive embedding pool, the probability vectors are first binarized according to a preset threshold to obtain binarized label vectors with elements of "1" or "0" under each phenotypic label. Then, the binarized label vectors of each embedding vector are compared pairwise. When two embedding vectors meet the following condition: both have a value of "1" in at least one phenotypic dimension (i.e., phenotypic label), they are determined to be a positive sample pair; when this condition is not met, they are determined to be a negative sample pair. Subsequently, a multi-label supervised contrastive loss is calculated based on the positive sample pair set and the negative sample pair set, so that embedding vectors related to the same phenotypic type are closer to each other in the feature space, and embedding vectors related to different phenotypic types are further apart.

[0102] In multi-label supervised contrastive loss, the weights of the loss terms for the corresponding embedding vector pairs can be determined based on the Jaccard similarity of the binarized label vectors.

[0103] Jaccard similarity can be expressed as:

[0104]

[0105] in, Represents the binary label vector and Jaccard similarity between them The binary label vector is the embedded vector of the student branch; min and max are the minimum and maximum value functions, respectively; and These represent the binary label vectors respectively. and In phenotypic labels The value on it is either 0 or 1.

[0106] Embedded vector The corresponding loss term in multi-label supervised contrastive learning loss It can be represented as:

[0107]

[0108] In the formula, To be classified under one item; and These represent the embedding vectors respectively. The set of positive sample pairs and the set of negative sample pairs; and These represent the samples (embedding vectors) in the positive sample pair set and the negative sample pair set, respectively. is the temperature coefficient (hyperparameter); exp() is the natural exponential function, and log() is the natural logarithm function.

[0109] By introducing an embedding queue and a contrastive embedding pool, the training process can simultaneously utilize phenotypic information from both the current batch and historical batches, mitigating the sample distribution fluctuation problem caused by small-batch training. Multi-label supervised contrastive loss establishes finer positive and negative constraints using binarized label vectors, which helps improve the ability of student branches to characterize fine-grained features of multiple phenotypes and enhances representation consistency under teacher-guided branch guidance. This, in turn, improves the discriminative ability, training stability, and phenotypic identification performance of the Helicobacter pylori infection auxiliary diagnostic model.

[0110] In one possible implementation, the embedding queue is updated based on the newly generated second embedding vector in each round, including: for each second embedding vector in the embedding queue and each newly generated second embedding vector in each round, determining the scarcity benefit of the second embedding vector based on the binarized label vector corresponding to the second embedding vector and the phenotypic distribution of the embedding queue; calculating the retention score of the second embedding vector based on the scarcity benefit and the number of survival rounds; when the embedding vectors in the embedding queue reach the upper limit, if the retention score of the second embedding vector is higher than the retention score of the target embedding vector, the target embedding vector is removed and the second embedding vector is added to the embedding queue; the target embedding vector is the embedding vector with the lowest retention score in the embedding queue.

[0111] Among them, phenotypic distribution is used to count the cumulative frequency or coverage density of each phenotypic in the embedding queue, so as to reflect the information retention status of different phenotypic in the current queue. Scarcity benefit is used to measure the supplementary value of the phenotypic carried by the second embedding vector to the current embedding queue. Survival rounds are used to record the number of rounds that the embedding vector has been continuously retained since entering the embedding queue. Retention score is used to comprehensively characterize whether the embedding vector should continue to be retained.

[0112] In practical implementation, the binarized label vector of the second embedding vector can first be matched with the phenotypic distribution of the embedding queue. If it contains low-frequency or insufficiently covered phenotypic types in the queue, it is given a higher scarcity benefit; if its phenotypic type has been largely covered in the queue, its scarcity benefit is reduced accordingly. Subsequently, the scarcity benefit and the number of survival rounds are input into the scoring function to generate a retention score. The number of survival rounds can be used to suppress redundant vectors that repeatedly enter the embedding queue in the short term, and can also be used to prevent vectors that have not been replaced for a long time from continuously occupying capacity.

[0113] Retention scores are positively correlated with scarcity gains and inversely correlated with the number of rounds in survival. Freshness advantage can be determined based on the number of rounds in survival, and retention scores can be derived from both scarcity gains and freshness advantage; for example, the retention score can be determined as the sum of scarcity gains and freshness advantage. Freshness advantage can be a function that decays with the number of rounds in survival or the duration of survival.

[0114] For example, retaining ratings It can be represented as:

[0115]

[0116] in, For the phenotypic distribution of the embedded queue, The target is a phenotypic uniform distribution; Indicates the positive operation; Used to represent scarcity benefits; Indicating an advantage in freshness, The survival time of an embedded vector can be represented by the product of the number of survival rounds and a fixed duration; It is a function of decay over time, meaning that the advantage of freshness gradually diminishes as the survival time increases.

[0117] When the embedding queue reaches its limit, the embedding vector with the lowest retention score is selected from the existing embedding vectors in the embedding queue as the target embedding vector. Its retention score is then compared with the retention score of the second embedding vector. If the retention score of the second embedding vector is higher, a replacement is performed, and the target embedding vector in the embedding queue is updated to the second embedding vector.

[0118] For example, the embedded queue can be stored in server memory or cache, and the upper limit can be preset according to the batch size, video memory capacity or queue length.

[0119] This update mechanism continuously filters embedding vectors that are more valuable for scarce phenotypes and, combined with the survival round count, suppresses the long-term accumulation of repetitive information, ensuring that the queue always maintains a good breadth of phenotype coverage. Therefore, subsequent multi-label supervised contrastive loss can obtain a more balanced distribution of contrastive samples when constructing positive and negative sample relationships, thereby improving the ability of the embedding representation to express fine-grained phenotypes related to Helicobacter pylori.

[0120] With this specific implementation method, the embedding queue no longer mechanically retains samples based solely on time order, but is dynamically maintained based on scarcity benefits and retention scores. This reduces the interference of redundant embeddings on training, enhances the retention probability of low-frequency phenotypic samples, improves the quality of effective samples for contrastive learning, and further enhances the stability of model training and the accuracy of infection-assisted diagnosis.

[0121] In one possible implementation, the supervised contrastive loss also includes a prototype contrastive loss. The method further includes: generating instantaneous pseudo-labels for each image sample based on the similarity between the first embedding vector and each prototype in the global prototype, using the first embedding vector; the first embedding vector is the embedding vector output by the instance projector of the student branch; updating the pseudo-labels of the image samples in the pseudo-label library using a moving average algorithm based on the instantaneous pseudo-labels; determining the positive sample prototype set and negative sample prototype set of the image samples from each prototype in the global prototype based on the binarized label vectors corresponding to the updated pseudo-labels in the pseudo-label library; calculating the prototype contrastive loss based on the positive sample prototype set and negative sample prototype set of each image sample; estimating the batch prototype of the current batch based on the first embedding vector and its corresponding binarized label vector of each image sample in the current batch; and updating the global prototype based on the batch prototype of the current batch.

[0122] The global prototype is a set of prototypes maintained across batches. Each prototype corresponds to a phenotype or combination of phenotypes and is used to provide a stable category reference.

[0123] Prototypes can be divided into two types: abnormal prototypes and normal prototypes. Abnormal prototypes are feature templates for lesions with corresponding subphenotypes, representing the typical feature distribution of lesions with that subphenotype. Normal prototypes are feature templates for healthy gastroscopy images without any subphenotypes, representing the feature distribution of normal gastric mucosa.

[0124] The instantaneous pseudo-label represents the matching strength between an image sample and each prototype, with a value range of [0,1]. This allows for the use of continuous values ​​from 0 to 1 to describe the degree of membership of an image sample to different prototypes. The pseudo-label library is used to store historical pseudo-labels and perform smooth updates to suppress the influence of single-batch noise on prototype selection. The positive sample prototype set and the negative sample prototype set are used to construct attraction and repulsion terms, respectively, thus forming the contrast targets for prototype constraints.

[0125] During initialization, the pseudo-label library can uniformly assign a value of 0.5 to the pseudo-label of each image sample. The same image sample can be repeatedly used in training across batches.

[0126] The binarized label vector corresponding to the first embedding vector can be obtained from the aforementioned pseudo-label library, or from the binarized output of an instance classifier, or from manually labeled ground-truth. For example, if the image sample corresponding to the first embedding vector has a manually labeled phenotypic label, then the manually labeled phenotypic label is directly selected as the binarized label vector corresponding to the first embedding vector; if there is no labeled phenotypic label, then the binarized label vector can be obtained by binarizing the multi-phenotypic prediction probability of the image sample using an instance classifier.

[0127] For the image samples input in the current batch, the student branch first obtains the first embedding vector, then calculates its similarity with each prototype in the global prototype, such as cosine similarity or dot product similarity, and normalizes the similarity as the immediate pseudo-label. Subsequently, using a moving average method, the immediate pseudo-label is fused with the historical pseudo-labels of the corresponding image samples in the pseudo-label library to obtain the updated pseudo-labels of the image sample under each prototype. By comparing the pseudo-labels with corresponding thresholds, the updated pseudo-labels of the image sample under each prototype are thresholded into a binary label vector. If the value of this binary label vector at a certain prototype is 1, then the prototype is determined to be a positive sample prototype; if it is 0, then the prototype is determined to be a negative sample prototype, thus obtaining the positive sample prototype set and the negative sample prototype set for the image sample. Based on the proximity constraint between the image sample's embedding vector and the positive sample prototype and the distance constraint between it and the negative sample prototype, the prototype contrast loss is calculated and participates in optimization together with the multi-label supervised contrast loss.

[0128] After obtaining the binarized label vector, based on the first embedding vector of each image sample in the current batch and its corresponding binarized label vector, the embedding vectors of the image samples in the same batch are aggregated to estimate the batch prototype of the current batch. Aggregation can be performed using weighted average or class average methods. Then, based on the batch prototype of the current batch, the global prototype is updated with momentum, for example, by using the EMA algorithm, so that the global prototype retains historical statistical information and can continuously adapt to new feature distributions during the training process.

[0129] In this way, the prototype contrastive loss can use stable prototypes to constrain sample representations, enabling student branches to obtain clearer inter-class separation capabilities and more consistent intra-class aggregation capabilities under limited labeling conditions.

[0130] With this implementation, sample embedding no longer relies solely on intra-batch contrast relationships but establishes a connection with global prototypes maintained across batches. This reduces disturbances caused by duplicate, blurred, and reflective frames in endoscopic images. Because the pseudo-labels are updated smoothly via moving average, the prototype selection process is more stable, and the prototype contrast loss continuously enhances the ability to identify fine-grained phenotypes, thereby improving training convergence stability and the characterization quality for Helicobacter pylori infection-assisted diagnosis.

[0131] After encoder training is complete, the encoder parameters are frozen, and the student branches no longer participate in training.

[0132] Figure 3 A schematic diagram of the architecture of the infection prediction model provided in this application is shown below. Figure 3As shown, in the infection prediction model, the trained encoder is connected to the packet classifier via an aggregator. The aggregator takes the image features of each image sample in the same inspection record packet output by the encoder as input, and aggregates the input image features based on an attention mechanism guided by multi-phenotypic prediction probabilities to obtain a packet-level representation. The packet classifier is used to determine the packet-level prediction probability based on the packet-level representation. The multi-phenotypic prediction probability is inferred by the trained instance classifier for each image sample, specifically by the trained instance classifier with frozen transfer learning.

[0133] The integrator performs packet-level aggregation of features from multiple images within the same examination record packet. Its input is the instance-level features (also known as image features or encoded features) extracted by the encoder from each image sample, and its output is a packet-level representation that encapsulates the comprehensive image information of the entire examination record. The packet classifier receives the packet-level representation and determines the infection status based on it, thus outputting the corresponding packet-level prediction probability. The multi-phenotype prediction probability reflects the likelihood of multiple phenotypes corresponding to an image sample. It can be output through the student branch during the encoder training phase (the first stage), for example, by the instance classifier, and serves as guiding information for the integrator during feature weighting.

[0134] In its implementation, the trained encoder can extract convolutional features or visual embedding features from each image sample in the same examination record package. These features can be represented as fixed-length vectors. The integrator includes an attention weight generation unit and a feature aggregation unit. The attention weight generation unit jointly models each image feature with its corresponding multi-phenotypic prediction probability, generating attention weights associated with each image sample. The feature aggregation unit then performs weighted summation or weighted fusion of the image features to form a package-level representation. This package-level representation can be input to a fully connected classification layer or a linear classification layer. After normalization, it outputs a package-level prediction probability, representing the confidence level of whether the examination record package corresponds to a negative or positive Helicobacter pylori infection.

[0135] The infection prediction model with the aforementioned structure allows the packet classifier to no longer directly discriminate based on features after simple pooling. Instead, an integrator combines multi-phenotypic prediction probabilities to assign higher weights to key images within the examination record packet, thereby highlighting mucosal phenotypic information related to infection and suppressing interference from duplicate, blurred, and occluded frames. Since the packet-level representation is composed of multiple images within the same examination record packet, the model can make fuller use of local lesion clues and overall distribution information during the examination process, improving the stability and consistency of packet-level prediction probabilities.

[0136] By adopting this specific structure, the model can enhance its ability to utilize fine-grained phenotypes while maintaining weakly supervised packet-level training. Furthermore, it can improve the contribution of key image features through attention aggregation, thereby reducing the interference of redundant images on diagnostic results. This improves the accuracy, robustness, and clinical interpretability of auxiliary diagnosis of Helicobacter pylori infection, making packet-level prediction more consistent with the comprehensive discrimination needs in real-world endoscopic examination scenarios.

[0137] Figure 4 For this application Figure 3 The architecture diagram of the integrator shown is as follows: Figure 4 As shown, the integrator includes a cross-instance interaction module, a feature modulation module, and a phenotype-guided attention module. The cross-instance interaction module performs cross-instance interaction on image features of the same inspection record package to obtain enhanced features for each instance. The feature modulation module calculates and normalizes the similarity between the embedded features of each instance, and determines the local density of each instance based on the normalized similarity of multiple neighboring instances. Based on the local density, the normalized similarity of each instance is adjusted to obtain the modulated similarity. Based on the modulated similarity, the attention weight of each instance is determined, and the enhanced features of each instance are mapped based on the attention weight of each instance to obtain the enhanced features. The obtained features are weighted to obtain modulation features; the embedding vector of each instance is obtained by inference of each image sample by the instance projector after training and frozen transfer; the phenotypic guided attention module is used to determine the attention score of each instance based on the modulation features of each instance using a gated attention mechanism; the phenotypic guided distribution of each instance is determined based on the multiphenotypic prediction probability of each image sample and the packet-level label of the inspection record packet to which it belongs; the attention score of each instance is regularized based on the phenotypic guided distribution of each instance to obtain phenotypic attention weights; the modulation features and enhancement features of each instance are weighted and fused based on the phenotypic attention weights to obtain the packet-level representation.

[0138] Here, an instance is used to represent an image sample, and one image sample is considered as one instance. Multiple instances neighboring an instance are the nearest neighbors to each other in terms of enhanced feature distance.

[0139] The cross-instance interaction module establishes contextual relationships between image samples within the same examination record package, enabling repeated frames of the same location, adjacent scan frames, and frames with similar phenotypes to share complementary information. Local density characterizes the degree of clustering of an instance in the feature space; higher density generally indicates stronger redundancy between the instance and its neighbors. Modulated similarity is used to correct the local density of normalized similarity, thereby reducing the impact of highly redundant instances. Phenotypic-guided distribution expresses the correspondence between each instance and clinical phenotype under package-level label constraints, ensuring that attention allocation considers both model prediction and medical priors. Phenotypic attention weights represent the contribution of instances constrained by phenotypes and serve as the weighting basis for subsequent package-level representation fusion.

[0140] In the specific implementation, each image sample in the inspection record package is first extracted into image features by the encoder and then sent to the integrator for aggregation. The cross-instance interaction module can adopt a feature exchange structure based on self-attention, which performs interactive calculations on the features of each instance with other instances to output enhanced features; this structure facilitates strengthening the association between lesion-related regions and adjacent instances. The feature modulation module can organize the enhanced features into a modulation feature matrix, calculate the similarity between instances based on cosine similarity or dot product similarity, and then obtain the standardized similarity relationship through a normalization function; subsequently, it estimates the local density based on the similarity relationship of multiple neighboring instances, and attenuates the similarity of high-density regions and compensates for the similarity of low-density regions accordingly, thereby generating attention weights and obtaining modulation features. The phenotypic-guided attention module can adopt a gating attention mechanism by combining a gating function and a linear mapping. It first generates an original attention score based on the modulation features, then constructs a phenotypic-guided distribution by combining multi-phenotypic prediction probabilities and packet-level labels, applies regularization constraints to the original attention score, and finally obtains the phenotypic attention weight, which is then applied to the modulation features and enhanced features respectively to complete the weighted fusion.

[0141] During operation, this integrator first supplements single-frame information through cross-instance interaction, then suppresses redundant frames and highlights locally scarce but diagnostically valuable instances through feature modulation. Subsequently, it utilizes a phenotype-guided attention mechanism to unify image-level prediction, phenotype-level priors, and packet-level label constraints into a single aggregation process, forming a packet-level representation for packet classification. This allows the model to focus more intently on key mucosal phenotypes associated with Helicobacter pylori infection in endoscopic examination records, while reducing interference from non-critical images such as reflections, blurring, and resampling.

[0142] See also Figure 4 The integrator's input includes the image features of K image samples within a single inspection record package, i.e., the image feature matrix. ( The instance classifier outputs the multiphenotypic prediction probability matrix of the inspection record package, i.e., the phenotypic prediction matrix. ( The embedding matrix is ​​composed of the embedding vectors output by the instance projector and the embedding vectors. Image feature matrix Enhanced features are obtained through initial cross-instance interaction via cross-instance interaction modules such as the Transformer layer. Enhanced features Fine-grained interaction is achieved through the Feature Modulation (CFM) module, combining the similarity between normalized embedding vectors to complete refined cross-instance fusion, and the modulated features are obtained through residual connections. Simultaneously, the embedding matrix... The local density is determined by the similarity between the elements, and after normalization, a normalized similarity matrix is ​​obtained. .

[0143] Inverse consensus scaling can be performed when calculating local density. Local density The expression is:

[0144]

[0145] in, This represents the normalized similarity between two embedding vectors; It is a binary neighborhood mask with two values, 0 and 1. When the similarity is greater than or equal to the corresponding threshold, the value is 1, and otherwise it is 0.

[0146] Based on the following formula, At that time, the modulated similarity The expression is:

[0147]

[0148] in, For example, a constant slightly greater than 0. .exist At that time, the similarity after modulation was 1.

[0149] The modulated similarity is injected into the QKV attention module to calculate the attention weights. It can be represented as:

[0150]

[0151] In the CFM module, the enhancement features are first... Perform a linear mapping to obtain the query matrix. Bond matrix Then, the characteristic affinity matrix is ​​calculated. ; Feature affinity matrix With the normalized similarity matrix Element-wise multiplication followed by normalization yields the attention weight matrix. This includes attention weights for each instance; and enhanced features. After linear mapping by value, the instance-weighted coefficient matrix is ​​used. Perform weighted aggregation, and compare the aggregated features with the enhanced features. The residuals are summed to obtain the output of the CFM module, i.e., the modulation characteristics.

[0152] In the phenotypic-guided attention module, or PAA module, a phenotypic prediction probability matrix is ​​formed by the multiphenotypic prediction probabilities of each image sample within the inspection record bag, based on the output of the instance classifier. And check the package-level tags of the record package. The phenotypic guided distribution vector was calculated. Phenotypic-guided distribution vector The Middle Phenotypic-guided distribution of individual instances The expression is:

[0153]

[0154] in, Representation of instances In multiphenotypic prediction probability, phenotype The predicted probability is as follows; and These represent the sets of positive lesion phenotypes and the sets of negative or normal tissue phenotypes, respectively.

[0155] A gated attention mechanism is used to map and calculate modulation features, obtaining the unconstrained raw attention scores for each instance. Then, based on the previously obtained phenotypic guided distribution, a KL divergence loss is constructed to apply regularization constraints to the raw attention scores. After normalization, the final attention weights for each instance, i.e., phenotypic attention weights, are obtained. Based on these phenotypic attention weights, modulation and enhancement features are weighted and aggregated to output packet-level representations. .

[0156] By adopting this specific structure, the complementary information between different instances within the record packet can be fully utilized, local density constraints can effectively reduce the interference of repeated frames on packet-level representation, and phenotypic guidance constraints can improve the focusing ability on fine-grained mucosal phenotypes, thereby improving the discriminability and stability of packet-level characterization and enhancing the accuracy and interpretability of Helicobacter pylori infection auxiliary diagnostic results.

[0157] Based on the aforementioned embodiments, the packet-level loss further includes packet-level classification loss and attention regularization loss; the method also includes: calculating attention regularization loss based on the phenotypic guidance distribution and attention score obtained in the same batch; and calculating packet-level classification loss based on the packet-level prediction probability and corresponding packet-level label obtained in the same batch.

[0158] In this application, the phenotypic guidance distribution is used to characterize the degree of conformity of each instance in the same batch to the packet-level phenotypic prior, and its value comes from the joint mapping of multi-phenotypic prediction results and packet-level labels; the attention score is used to characterize the weight strength assigned to each instance by the integrator, and the two correspond one-to-one in the same batch.

[0159] In practical implementation, the attention regularization loss can adopt the Kullback-Leibler divergence form, cross-entropy form, or other functions that measure distributional differences. Its input is the phenotypic guidance distribution and attention score obtained in the same batch, and its output is a constraint term that makes the attention score converge towards the phenotypic guidance distribution, thereby suppressing attention deviation from clinical phenotypic information. The packet-level classification loss can adopt binary cross-entropy loss or multi-class cross-entropy loss. Its input is the packet-level prediction probability and corresponding packet-level label obtained in the same batch, and its output is a supervisory signal for the packet classifier, to ensure that the model output is consistent with the actual infection status. The above two types of losses can be summed according to preset weights to form the packet-level loss, and this summation is coordinated with the update process of the packet classifier parameters.

[0160] In terms of working principle, the attention regularization loss constrains the attention allocation of instances within a packet to a range that better aligns with phenotypic priors, thereby increasing the attention given to images related to key phenotypic traits. The packet-level classification loss directly supervises the final judgment result of the checked packet. Together, they contribute to packet-level representation learning and classification. Thus, the model maintains its ability to discriminate packet-level infection states while enhancing the interpretability and stability of the attention distribution.

[0161] With this implementation, the packet-level loss no longer depends solely on the final classification result, but simultaneously introduces phenotypic guidance constraints and packet-level supervision constraints. This reduces the interference of redundant images on attention allocation, improves the accuracy of packet-level prediction, and makes the packet-level decision-making process closer to clinical phenotypic logic, thereby improving the reliability and consistency of auxiliary diagnosis of Helicobacter pylori infection.

[0162] Based on the aforementioned embodiments, further, before inputting the student branch and teacher branch to obtain the infection prediction probability and multiphenotype prediction probability of the image samples after performing the first enhancement operation and the second enhancement operation on the image samples respectively, the method further includes: pre-training the encoder, instance classifier and instance projector in the initial model based on the labeled image samples until the first pre-training termination condition is met, to obtain the pre-trained encoder, instance classifier and instance projector; pre-training the bag classifier in the initial model connected to the pre-trained encoder based on the sample dataset until the second pre-training termination condition is met, to obtain the pre-trained bag classifier, so as to form the teacher branch and the student branch through the pre-trained encoder, bag classifier, instance classifier and instance projector.

[0163] The labeled image samples are those with corresponding phenotypic labels. These labels can be assigned manually or semi-automatically within the examination record package. Their purpose is to provide a supervised phenotypic representation foundation for the encoder, instance classifier, and instance projector. The initial model is used for pre-training and subsequent branch construction, and its structure can consist of an encoder, instance classifier, instance projector, and bag classifier. The pre-trained encoder is a feature extractor learned from labeled image samples, capable of outputting features that more closely resemble the texture, color, and vascular representation of the gastric mucosa. The instance classifier outputs probabilities for multiple phenotypic representations corresponding to a single image, the instance projector maps the encoder output to embedding vectors suitable for contrastive learning, and the bag classifier outputs infection prediction results based on the overall features of the examination record package.

[0164] In practical implementation, when pre-training the encoder, instance classifier, and instance projector in the initial model based on labeled image samples, image samples can be input into the encoder to obtain image features. The instance classifier then generates multi-phenotypic prediction probabilities, and the instance projector generates embedding vectors. Classification and representation errors are calculated based on phenotypic labels, and the parameters of these components are updated. The first pre-training termination condition can be set as loss function convergence, validation set metric stability, or reaching a preset number of rounds. After completing this pre-training, the encoder, instance classifier, and instance projector can obtain initial parameters suitable for recognizing Helicobacter pylori-related phenotypic patterns.

[0165] Subsequently, when pre-training the packet classifier in the initial model connected to the pre-trained encoder based on the sample dataset, multiple image samples from the same inspection record packet can be input into the pre-trained encoder to aggregate packet-level features. These features are then input into the packet classifier to output the packet-level infection probability, and the packet classifier parameters are updated based on the packet-level labels. The second pre-training termination condition can be set as the packet-level classification loss meeting a threshold, the training epochs reaching an upper limit, or the packet-level prediction accuracy reaching a preset requirement. The pre-trained packet classifier obtained in the above manner is combined with the pre-trained encoder, and then together with the instance classifier and instance projector to form student and teacher branches. This results in the model having more stable initialization parameters and a better phenotypic and infection discrimination basis when performing augmentation input at the image sample level.

[0166] This pre-training method allows the model to first establish fine-grained phenotypic recognition capabilities on labeled image samples, and then establish packet-level infection discrimination capabilities on the sample dataset. The two processes are interconnected, reducing random initialization bias in subsequent joint training and improving the consistency between student and teacher branches. Since the encoder, instance classifier, instance projector, and packet classifier all obtain targeted parameters before formal joint training, subsequent calculations of infection prediction probabilities and multi-phenotypic prediction probabilities for enhanced image samples will be more stable, thus improving convergence speed, prediction accuracy, and clinical applicability in weakly supervised diagnostic scenarios.

[0167] This application's embodiments are applicable to intelligent diagnosis scenarios of Helicobacter pylori infection in hospital endoscopy workstations. When a patient undergoes gastroscopy due to stomach discomfort, the endoscopic equipment acquires a sequence of video frames of the gastric mucosa, including the gastric body, gastric angle, and esophageal region, and forms an examination record package for each endoscopy examination. The system first acquires a sample dataset, which contains multiple examination record packages and corresponding package-level tags for each package. Each examination record package includes multiple image samples obtained from a single endoscopy examination, some of which have phenotypic tags. These phenotypic tags can correspond to fine-grained phenotypes related to Hp infection, such as diffuse redness, mucosal atrophy, and goosebumps.

[0168] For labeled image samples, the encoder, instance classifier, and instance projector in the initial model are pre-trained until the first pre-training termination condition is met. Then, based on the entire sample dataset, the bag classifier connected to the pre-trained encoder is pre-trained until the second pre-training termination condition is met. Subsequently, student and teacher branches are constructed using the pre-trained encoder, bag classifier, instance classifier, and instance projector. The encoder in the teacher branch is connected to both the bag classifier and the instance projector, while the encoder in the student branch is connected to both the bag classifier, instance classifier, and instance projector. The teacher branch is updated using an exponential moving average method to follow the student branch, forming a two-branch training structure corresponding to the query network and the key network.

[0169] During training, a first enhancement operation and a second enhancement operation are performed on each image sample, and the enhanced images are then fed into the student branch and the teacher branch, respectively. For example, for a frame of the gastric body region and a frame of the gastric angle region, cropping, color perturbation, or scaling can be performed before inputting them into the two branches. The encoder of the student branch extracts image features, outputs the infection prediction probability via the bag classifier, the multi-phenotype prediction probability via the instance classifier, and the first embedding vector via the instance projector. The encoder of the teacher branch extracts image features, outputs the infection prediction probability via the bag classifier, and the second embedding vector via the instance projector. The multi-phenotype prediction probability characterizes the probability that an image sample belongs to each of the various phenotypes. For the multi-phenotype prediction probability output by the student branch, the phenotype classification loss is calculated in conjunction with the corresponding phenotype label; for the infection prediction probabilities output by both the student and teacher branches, the prediction consistency loss is calculated.

[0170] For multi-label supervised contrastive learning, the predicted probabilities of multiple phenotypes are converted into binary label vectors. Positive and negative sample pairs are then determined within the contrastive embedding pool. The contrastive embedding pool consists of the first embedding vector of the current batch, the second embedding vector of the current batch, and the embedding queue. When the binary label vectors corresponding to two embedding vectors both have a value of 1 under at least the same phenotype, the embedding vector pair is considered a positive sample pair; other sample pairs that do not meet this condition are considered negative sample pairs. For example, gastric body frames and gastric angle frames that both have diffusely red labels can be classified as positive sample pairs; esophageal non-diagnostic images and goosebumps images typically do not meet the common phenotype condition and can be classified as negative sample pairs. After each training round generates a new second embedding vector, the embedding queue is updated. During the update, for each embedding vector in the embedding queue and the newly generated second embedding vector, the scarcity benefit is determined based on the corresponding binarized label vector and the phenotypic distribution of the current embedding queue. Then, a retention score is calculated based on the survival rounds of each embedding vector. When the number of embedding vectors in the embedding queue reaches the upper limit, the retention score of the newly generated second embedding vector is compared with the retention score of the target embedding vector with the lowest retention score in the queue. If the retention score of the newly generated second embedding vector is higher, the target embedding vector is removed and the newly generated second embedding vector is added to the embedding queue. Subsequently, a multi-label supervised contrastive loss is calculated based on each sample pair in the positive sample pair set and the negative sample pair set, thereby retaining scarce sample representations corresponding to low-frequency phenotypes such as goosebumps in the embedding pool.

[0171] Supervised contrastive loss can also include prototype contrastive loss. For the first embedding vector of each image sample in the current batch, its similarity to each prototype in the global prototype is first calculated, and an instantaneous pseudo-label with a value between 0 and 1 is generated accordingly; for example, for a frame of gastric body image, an instantaneous pseudo-label of "high diffuse redness" and "medium mucosal atrophy" can be generated. Then, a moving average algorithm is used to update the pseudo-label of the image sample in the pseudo-label library based on the instantaneous pseudo-label. The updated pseudo-label is converted into a binary label vector, and a positive sample prototype set and a negative sample prototype set are determined for each image sample from each prototype in the global prototype, and the prototype contrastive loss is calculated accordingly. At the same time, the batch prototype of the current batch is estimated based on the first embedding vector of each image sample in the current batch and its corresponding binary label vector, and then the global prototype is updated using the batch prototype. Subsequently, the multi-label supervised contrastive loss, prototype contrastive loss, phenotypic classification loss, and prediction consistency loss are used together as training objectives related to the supervised contrastive loss to update the student branch parameters. After the student branch parameters are updated, the teacher branch parameters are smoothly updated using the exponential moving average algorithm until the first training termination condition is met, thus obtaining the trained encoder.

[0172] After obtaining the trained encoder, an infection prediction model is constructed, and the trained encoder is connected to the package classifier via an integrator. For each examination record package, multiple image samples are input into the trained encoder to obtain the image features of each image sample within the same examination record package and the corresponding multi-phenotypic prediction probabilities. For an examination record package generated from a single gastroscopy examination, it may contain diagnostically relevant frames such as the gastric body and gastric angle, as well as non-diagnostic frames such as esophageal images. The integrator first performs cross-instance interaction on the image features of the same examination record package through a cross-instance interaction module to obtain the enhanced features of each instance; then, the feature modulation module calculates and normalizes the similarity between the enhanced features of each instance, and determines the local density of each instance by combining the normalized similarity of multiple neighboring instances. The normalized similarity of each instance is adjusted according to the local density to obtain the modulated similarity. Then, the attention weight of each instance is determined based on the modulated similarity, and the features of the corresponding instance in the modulated feature matrix are weighted using the attention weight of each instance to obtain the modulated features. For esophageal images that have low similarity to key pathological frames and whose local density reflects redundancy, the attention weight corresponding to their modulated similarity will be reduced.

[0173] Subsequently, the phenotypic-guided attention module employs a gated attention mechanism. It determines the attention score for each instance based on its modulation features and combines this with the multiphenotypic prediction probabilities of each image sample and the package-level label of its respective examination record package to determine the phenotypic-guided distribution for each instance. For example, when the prediction probability of "mucosal atrophy" or "diffuse redness" in the gastric body region image is high and the package-level label of its respective examination record package indicates positive *Helicobacter pylori* infection, the weight of this instance in the phenotypic-guided distribution is higher than that of the esophageal region image. Based on the phenotypic-guided distribution of each instance, a regularization constraint is applied to the attention score of each instance to obtain phenotypic attention weights. These weights are then used to weight and fuse the modulation and enhancement features of each instance to form a package-level representation. The package classifier receives the package-level representation and outputs the package-level prediction probability, which can provide a package-level diagnostic result such as "positive *Helicobacter pylori* infection" on the workstation interface, along with a heatmap annotated with key lesion areas such as the diffuse redness area in the gastric angle.

[0174] When training the infection prediction model, the packet-level classification loss is calculated based on the packet-level prediction probabilities and corresponding packet-level labels of the same batch. The attention regularization loss is calculated based on the phenotypic guidance distribution and attention scores obtained from the same batch. The packet-level classification loss and attention regularization loss are combined as the packet-level loss to update the packet classifier parameters until the second training termination condition is met. After deployment at a hospital endoscopy workstation, the system can process the gastric mucosal video frame sequences acquired during the examination, outputting the packet-level infection prediction probability, the multi-phenotypic prediction probability of each image sample, and attention heatmaps corresponding to key lesion areas for doctors to reference when examining the gastric body, gastric angle, and related areas.

[0175] This application also provides a computer-aided diagnostic method based on medical images, including: acquiring multiple endoscopic images obtained from an endoscopic examination; inputting the multiple endoscopic images into a trained infection prediction model to obtain the infection probability; wherein the infection prediction model is trained based on the model training method provided above.

[0176] By acquiring multiple endoscopic images from the same endoscopic examination, the mucosal manifestations of different locations such as the gastric body, antrum, angle, and cardia at different times can be jointly included in the analysis, eliminating the influence of random noise from a single frame on the judgment result. After inputting multiple endoscopic images into the trained infection prediction model, the model can combine the image-level infection representation, fine-grained phenotypic representation, and packet-level aggregation capabilities obtained during training, resulting in stronger robustness to duplicate frames, blurred frames, and reflective occlusion frames, thus outputting a more stable infection probability. Since the infection prediction model is based on the above training method, the model has completed the adaptation to endoscopic domain features and reinforcement learning of key phenotypic information during the training phase, enabling it to more accurately capture Helicobacter pylori-related mucosal texture, color, and vascular changes during inference, thereby improving the accuracy of auxiliary diagnosis and the reliability of clinical applications.

[0177] Figure 5 A schematic diagram of the structure of the model training device provided in this application is shown below. Figure 5 As shown, the model training apparatus provided in this embodiment includes: a training set acquisition module for acquiring a sample dataset; the sample dataset includes multiple examination record packages and their package-level labels, the examination record package includes multiple image samples obtained from endoscopic examinations, and some image samples correspond to phenotypic labels; a dual-branch processing module for performing a first enhancement operation and a second enhancement operation on the image samples respectively, and then inputting the data into a student branch and a teacher branch, obtaining the infection prediction probability and multi-phenotypic prediction probability of the image samples through the student branch, and obtaining the infection prediction probability of the image samples through the teacher branch; both the student branch and the teacher branch are composed of at least a portion of a pre-trained initial model, at least a portion of which includes an encoder; the multi-phenotypic prediction probability is used to characterize the probability of belonging to each phenotype among multiple phenotypes; and an encoder training module for training the model based on supervised contrastive loss, phenotypic classification loss, and prediction-1 The consistency loss updates the parameters of the student branch, and the teacher branch parameters are smoothly updated using the updated student branch parameters through an exponential moving average algorithm until the first training termination condition is met, resulting in the trained encoder. Supervised contrastive loss includes multi-label supervised contrastive loss, which is related to the multi-phenotype prediction probability; prediction consistency loss is related to the infection prediction probability output by the student and teacher branches; and phenotypic classification loss is related to the multi-phenotype prediction probability and its corresponding phenotypic label. A packet-level prediction module is used to input multiple image samples from the inspection record into the infection prediction model to obtain the packet-level prediction probability. The infection prediction model includes the trained encoder and packet classifier. A packet classifier training module is used to update the packet classifier based on the packet-level loss until the second training termination condition is met. The packet-level loss is related to the packet-level prediction probability and the packet-level label.

[0178] In one possible embodiment, in the teacher branch, the encoder is connected to a bag classifier and an instance projector, respectively; in the student branch, the encoder is connected to a bag classifier, an instance classifier, and an instance projector, respectively; the bag classifier is used to output the infection prediction probability, the instance projector is used to convert the encoder output into an embedding vector; the instance classifier is used to output the multi-phenotype prediction probability; when calculating the multi-label supervised contrastive loss, the embedding vector pairs that satisfy the following condition are positive sample pairs: the values ​​of the binarized label vectors corresponding to the multi-phenotype prediction probabilities are all 1 at least under the same phenotype.

[0179] In one possible embodiment, the apparatus further includes: a queue update module, used to update the embedding queue based on the newly generated second embedding vector in each round; the second embedding vector is the embedding vector output by the instance projector of the teacher branch; a positive and negative sample partitioning module, used to obtain a set of positive sample pairs and a set of negative sample pairs based on the binarized label vectors corresponding to the multi-phenotypic prediction probabilities of each embedding vector in the contrast embedding pool; the contrast embedding pool is the union of the first embedding vector of the current batch, the second embedding vector of the current batch, and the embedding queue; the first embedding vector is the embedding vector output by the instance projector of the student branch; and a first loss calculation module, used to calculate the multi-label supervised contrastive loss based on each sample pair in the set of positive sample pairs and the set of negative sample pairs.

[0180] In one possible embodiment, the queue update module is specifically configured to: for each second embedding vector in the embedding queue and each newly generated second embedding vector in each round, determine the scarcity benefit of the second embedding vector based on the binarized label vector corresponding to the second embedding vector and the phenotypic distribution of the embedding queue; calculate the retention score of the second embedding vector based on the scarcity benefit and the number of survival rounds; when the embedding vectors in the embedding queue reach the upper limit, if the retention score of the second embedding vector is higher than the retention score of the target embedding vector, remove the target embedding vector and add the second embedding vector to the embedding queue; the target embedding vector is the embedding vector with the lowest retention score in the embedding queue.

[0181] In one possible embodiment, the supervised contrast loss further includes a prototype contrast loss. The device also includes a second loss calculation module for: generating instantaneous pseudo-labels for each image sample based on the similarity between the first embedding vector and each prototype in the global prototype, for each first embedding vector; the first embedding vector is the embedding vector output by the instance projector of the student branch; updating the pseudo-labels of the image samples in the pseudo-label library based on the instantaneous pseudo-labels using a moving average algorithm; determining the positive sample prototype set and negative sample prototype set of the image samples from each prototype in the global prototype based on the binarized label vectors corresponding to the updated pseudo-labels in the pseudo-label library; calculating the prototype contrast loss based on the positive sample prototype set and negative sample prototype set of each image sample; estimating the batch prototype of the current batch based on the first embedding vector and its corresponding binarized label vector of each image sample in the current batch; and updating the global prototype based on the batch prototype of the current batch.

[0182] In one possible embodiment, in the infection prediction model, the trained encoder is connected to the packet classifier via an integrator; the integrator takes the image features of each image sample in the same inspection record packet output by the encoder as input, and aggregates the input image features based on an attention mechanism guided by multi-phenotypic prediction probabilities to obtain a packet-level representation; wherein, the multi-phenotypic prediction probabilities are inferred by the trained instance classifier from each image sample; the packet classifier is used to determine the packet-level prediction probabilities based on the packet-level representation.

[0183] In one possible embodiment, the integrator includes a cross-instance interaction module, a feature modulation module, and a phenotype-guided attention module. The cross-instance interaction module performs cross-instance interaction on image features of the same inspection record package to obtain enhanced features for each instance. The feature modulation module calculates and normalizes the similarity between the embedding vectors of each instance, and determines the local density of each instance based on the normalized similarity of multiple neighboring instances. Based on the local density, the normalized similarity of each instance is adjusted to obtain modulated similarity. Based on the modulated similarity, the attention weight of each instance is determined, and the enhanced features of each instance are enhanced based on the attention weight of each instance. The features after feature mapping are weighted to obtain modulation features; the embedding vector of each instance is obtained by inference of each image sample by the trained instance projector; the phenotypic guided attention module is used to determine the attention score of each instance based on the modulation features of each instance using a gated attention mechanism; the phenotypic guided distribution of each instance is determined based on the multiphenotypic prediction probability of each image sample and the packet-level label of the inspection record packet to which it belongs; the attention score of each instance is regularized based on the phenotypic guided distribution of each instance to obtain the phenotypic attention weight; the modulation features and enhancement features of each instance are weighted and fused based on the phenotypic attention weight to obtain the packet-level representation.

[0184] In one possible embodiment, the packet-level loss includes packet-level classification loss and attention regularization loss; the device also includes a third loss calculation module for: calculating attention regularization loss based on the phenotypic guidance distribution and attention score obtained in the same batch; and calculating packet-level classification loss based on the packet-level prediction probability and corresponding packet-level label obtained in the same batch.

[0185] In one possible embodiment, the device further includes a pre-training module for: pre-training the encoder, instance classifier, and instance projector in the initial model based on labeled image samples, before inputting the student branch and teacher branch to obtain the infection prediction probability and multiphenotype prediction probability of the image samples, after performing a first enhancement operation and a second enhancement operation on the image samples respectively, until a first pre-training termination condition is met, to obtain a pre-trained encoder, instance classifier, and instance projector; and pre-training the bag classifier in the initial model connected to the pre-trained encoder based on the sample dataset, until a second pre-training termination condition is met, to obtain a pre-trained bag classifier, so as to form the teacher branch and the student branch and teacher branch through the pre-trained encoder, bag classifier, and instance projector.

[0186] The model training device provided in this embodiment can execute the model training method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0187] Figure 6 A schematic diagram of the structure of the electronic device provided in this application. Figure 6 As shown, the electronic device 60 provided in this embodiment includes at least one processor 601 and a memory 602. Optionally, the electronic device 60 further includes a communication component 603. The processor 601, memory 602, and communication component 603 are connected via a bus.

[0188] In a specific implementation, at least one processor 601 executes computer execution instructions stored in memory 602, causing at least one processor 601 to perform the above-described method.

[0189] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0190] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0191] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0192] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, the bus in the accompanying drawings of the present application is not limited to only one bus or one type of bus.

[0193] The present application further provides a computer-aided diagnosis system based on medical images, comprising an image terminal and an image analysis end; the image terminal is configured to store or cache endoscopic images obtained by endoscopic examination, and initiate an auxiliary diagnosis request to the image analysis end, where the auxiliary diagnosis request carries a plurality of endoscopic images obtained by the endoscopic examination; the image analysis end is configured to parse the plurality of endoscopic images from the auxiliary diagnosis request, input the plurality of endoscopic images into a trained infection prediction model to obtain an infection probability, and feed the infection probability back to the image terminal; wherein the infection prediction model is trained by the model training method provided in any one of the above embodiments.

[0194] In this embodiment, the image terminal and the image analysis end are divided only according to functions, and no limitation is imposed on the physical hardware form, deployment position, and deployment manner of the two.

[0195] The image terminal and the image analysis end may be deployed in the same physical device, for example, an integrated endoscopic diagnosis host, or may be disposed in different devices and communicatively connected through a local area network, the Internet, a wireless network, or the like.

[0196] The image terminal is a front-end device with functions such as image storage or caching, human-computer interaction, and network request transmission, and is not limited to a single hardware form. For example, the image terminal may be a medical workstation supporting an endoscope, such as a medical desktop computer directly connected to endoscopic devices like a gastroscope and a colonoscope, with a local hard disk caching the endoscopic images obtained by the endoscopic examination. The image terminal may also be a server of a hospital imaging center, configured to store endoscopic images obtained from each endoscopic examination of different medical workstations. The image terminal may also be a mobile medical terminal, such as a medical tablet computer, a touch diagnosis and treatment all-in-one machine, which can wirelessly acquire the endoscopic images captured by the endoscopic device and initiate the auxiliary diagnosis request.

[0197] Image analysis can be achieved through backend computing devices, such as locally deployed physical servers, like those in a hospital server room or rack-mounted computing hosts, which load the trained infection prediction model locally via the hospital's local area network. Alternatively, image analysis can be achieved through cloud-based inference servers, edge computing devices, distributed computing nodes, or integrated computing modules.

[0198] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0199] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0200] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0201] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0202] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0203] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0204] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0205] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0206] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0207] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A model training method, characterized in that, include: Obtain a sample dataset; the sample dataset includes multiple examination record packages and their package-level labels, the examination record package includes multiple image samples obtained from endoscopic examinations, and some of the image samples correspond to phenotypic labels; After performing a first enhancement operation and a second enhancement operation on the image samples respectively, the student branch and the teacher branch are input. The infection prediction probability and multiphenotype prediction probability of the image samples are obtained through the student branch, and the infection prediction probability of the image samples is obtained through the teacher branch. Both the student branch and the teacher branch are composed of at least a part of a pre-trained initial model, and the at least a part includes an encoder. The multiphenotype prediction probability is used to characterize the probability of belonging to each phenotype among multiple phenotypes. The parameters of the student branch are updated based on supervised contrastive loss, phenotypic classification loss, and prediction consistency loss. The parameters of the teacher branch are then smoothly updated using the updated student branch parameters through an exponential moving average algorithm until the first training termination condition is met, resulting in the trained encoder. The supervised contrastive loss includes multi-label supervised contrastive loss, which is related to the multi-phenotypic prediction probability. The prediction consistency loss is related to the infection prediction probability output by the student branch and the teacher branch. The phenotypic classification loss is related to the multi-phenotypic prediction probability and its corresponding phenotypic label. Multiple image samples from the inspection record package are input into the infection prediction model to obtain the package-level prediction probability; The infection prediction model includes a trained encoder and a packet classifier; The packet classifier is updated based on the packet-level loss until the second training termination condition is met; the packet-level loss is related to the packet-level prediction probability and the packet-level label.

2. The method according to claim 1, characterized in that, In the teacher branch, the encoder is connected to a package classifier and an instance projector, respectively; In the student branch, the encoder is connected to a package classifier, an instance classifier, and an instance projector, respectively; The packet classifier is used to output the infection prediction probability, and the instance projector is used to convert the encoder output into an embedding vector; the instance classifier is used to output the multiphenotype prediction probability. When calculating the multi-label supervised contrastive loss, the embedding vector pairs that meet the following conditions are considered positive sample pairs: the values ​​of the binary label vectors corresponding to the multi-phenotype prediction probabilities are all 1 at least under the same phenotype.

3. The method according to claim 2, characterized in that, The method further includes: The embedding queue is updated based on the newly generated second embedding vector in each round; the second embedding vector is the embedding vector output by the instance projector of the teacher branch. Based on the binarized label vectors corresponding to the multi-phenotypic prediction probabilities of each embedding vector in the contrast embedding pool, a set of positive sample pairs and a set of negative sample pairs are obtained; the contrast embedding pool is the union of the first embedding vector of the current batch, the second embedding vector of the current batch, and the embedding queue; the first embedding vector is the embedding vector output by the instance projector of the student branch; The multi-label supervised contrastive loss is calculated based on each sample pair in the set of positive sample pairs and the set of negative sample pairs.

4. The method according to claim 3, characterized in that, Based on the newly generated second embedding vector in each round, update the embedding queue, including: For each second embedding vector in the embedding queue and the newly generated second embedding vector in each round, the scarcity benefit of the second embedding vector is determined based on the binarized label vector corresponding to the second embedding vector and the phenotypic distribution of the embedding queue. Based on the scarcity benefit and number of survival rounds of the second embedding vector, calculate the retention score of the second embedding vector; When the embedding vector in the embedding queue reaches the upper limit, if the retention score of the second embedding vector is higher than the retention score of the target embedding vector, the target embedding vector is removed and the second embedding vector is added to the embedding queue; the target embedding vector is the embedding vector with the lowest retention score in the embedding queue.

5. The method according to claim 2, characterized in that, The supervised contrast loss also includes prototype contrast loss, and the method further includes: For each of the image samples, an instantaneous pseudo-label is generated based on the similarity between the first embedding vector and each prototype in the global prototype; the first embedding vector is the embedding vector output by the instance projector of the student branch. The moving average algorithm is used to update the pseudo-labels of the image samples in the pseudo-label library based on the real-time pseudo-labels; Based on the binarized label vectors corresponding to the updated pseudo-labels in the pseudo-label library, the positive sample prototype set and negative sample prototype set of the image sample are determined from each prototype of the global prototype. Based on the positive sample prototype set and negative sample prototype set of each image sample, the prototype contrast loss is calculated; Based on the first embedding vector of each image sample in the current batch and its corresponding binarized label vector, estimate the batch prototype of the current batch; Update the global prototype based on the batch prototype of the current batch.

6. The method according to any one of claims 2-5, characterized in that, In the infection prediction model, the trained encoder is connected to the bag classifier via an integrator; The integrator takes the image features of each image sample in the same inspection record bag output by the encoder as input, and aggregates the input image features based on the attention mechanism guided by the multi-phenotypic prediction probability to obtain the bag-level representation; wherein, the multi-phenotypic prediction probability is obtained by the trained instance classifier inference from each image sample; The packet classifier is used to determine the packet-level prediction probability based on the packet-level representation.

7. The method according to claim 6, characterized in that, The integrator includes a cross-instance interaction module, a feature modulation module, and a phenotype-guided attention module; The cross-instance interaction module is used to perform cross-instance interaction on the image features of the same inspection record package to obtain the enhanced features of each instance; The feature modulation module is used to calculate and normalize the similarity between the embedding vectors of each instance, and determine the local density of each instance based on the normalized similarity of multiple neighboring instances; adjust the normalized similarity of each instance according to the local density to obtain the modulated similarity; determine the attention weight of each instance based on the modulated similarity, and weight the enhanced feature mapping features of each instance based on the attention weight of each instance to obtain the modulated features; wherein, the embedding vector of each instance is obtained by the trained instance projector from each image sample. The phenotypic-guided attention module employs a gated attention mechanism to determine the attention score of each instance based on its modulation features; determines the phenotypic-guided distribution of each instance based on the multiphenotypic prediction probability of each image sample and the packet-level label of its respective inspection record packet; applies regularization constraints to the attention scores of each instance based on the phenotypic-guided distribution to obtain phenotypic attention weights; and performs weighted fusion of the modulation features and enhancement features of each instance based on the phenotypic attention weights to obtain the packet-level representation.

8. The method according to claim 7, characterized in that, The packet-level loss includes packet-level classification loss and attention regularization loss; the method further includes: Based on the phenotypic guidance distribution and attention score obtained in the same batch, calculate the attention regularization loss; The package-level classification loss is calculated based on the package-level predicted probabilities and corresponding package-level labels obtained from the same batch.

9. The method according to any one of claims 2-5, characterized in that, After performing the first enhancement operation and the second enhancement operation on the image samples respectively, and before inputting the student branch and the teacher branch to obtain the infection prediction probability and multiphenotype prediction probability of the image samples, the method further includes: Based on labeled image samples, the encoder, instance classifier and instance projector in the initial model are pre-trained until the first pre-training termination condition is met, and the pre-trained encoder, instance classifier and instance projector are obtained. Based on the sample dataset, the bag classifier in the initial model connected to the pre-trained encoder is pre-trained until the second pre-training termination condition is met, resulting in a pre-trained bag classifier. This pre-trained bag classifier is then used to form the teacher branch and the student branch through the pre-trained encoder, bag classifier, instance classifier, and instance projector.

10. A computer-aided diagnostic method based on medical images, characterized in that, include: Acquire multiple endoscopic images obtained from endoscopic examinations; The multiple endoscopic images are input into the trained infection prediction model to obtain the infection probability; wherein the infection prediction model is trained based on the method provided in any one of claims 1-9.

11. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-10.

12. A computer-aided diagnostic system based on medical images, characterized in that, Includes image terminals and image analysis terminals; The imaging terminal is used to store or cache endoscopic images obtained from endoscopic examinations and to send auxiliary diagnostic requests to the image analysis terminal. The auxiliary diagnostic requests carry multiple endoscopic images obtained from endoscopic examinations. The image analysis terminal is used to parse the multiple endoscopic images from the auxiliary diagnosis request, input the multiple endoscopic images into the trained infection prediction model to obtain the infection probability, and feed the infection probability back to the image terminal; wherein, the infection prediction model is trained based on the method provided in any one of claims 1-9.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-10.

14. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-10.