Medical image classification method and equipment based on improved triple loss

By improving the triplet loss function and combining ResNet and SVM classifiers, the problems of feature reliability and training stability in medical image classification are solved, more efficient cancer diagnosis is achieved, and image classification accuracy and feature discriminability are improved.

CN120613086AActive Publication Date: 2025-09-09TIANJIN UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511001574.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-09-09
Estimated Expiration
2045-07-21

AI Technical Summary

Technical Problem

Existing medical image classification methods have the problem of improving classification accuracy in cancer diagnosis but difficult to evaluate feature reliability. In addition, the traditional triplet loss model is unstable in training and converges slowly, making it difficult to design a reasonable margin.

Method used

A medical image classification model based on improved triplet loss is constructed. By introducing the gradient direction angle loss and negative sample distance parameters, the triplet loss function is optimized to improve the convergence and stability of the training process. The ResNet and SVM classifiers are then combined for feature extraction and classification.

Benefits of technology

It improves the training efficiency and accuracy of medical image classification, can better learn image features, reduce the workload of doctors, improve diagnostic accuracy and efficiency, and has important clinical application value.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120613086A_ABST
    Figure CN120613086A_ABST
Patent Text Reader

Abstract

The invention discloses a medical image classification method and equipment based on improved triple loss, and the method comprises the steps: constructing a medical image classification model based on a neural network and a triple loss function, introducing the angle loss of a gradient direction into the triple loss function, enabling the loss function to reduce the deviation of the gradient direction when the gradient direction is calculated, and enabling the calculation precision of the gradient direction to be improved. Convergence of the training process is accelerated. According to the method, the training efficiency can be improved, by introducing the negative group distance, the angle loss and the adaptive Margin calculation strategy, the improved triple loss function converges faster in the training process, and the model training efficiency and stability are improved. According to the invention, the classification accuracy can be improved, and different types of medical images can be identified more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of medical image analysis and processing, and in particular to a medical image classification method and device based on improved triplet loss. Background Art

[0002] Currently, medical images are crucial in disease diagnosis, but their classification faces many challenges due to the diversity and heterogeneity of their morphology, types, and features. Traditional classification methods based on convolutional neural networks, while improving classification accuracy, often focus on convergence to categories, neglecting the analysis and reliability assessment of image features. In the field of cancer research, the significant increase in cancer prevalence has made cervical cancer screening a key research direction. Currently, medical image diagnosis relies primarily on pathologists manually examining tissue samples using microscopes, a process that is extremely time-consuming and labor-intensive, and highly reliant on the physician's expertise and experience.

[0003] In medical cell classification, cancer cell image detection has always been a challenge. Due to the heterogeneity of cells in images, convolutional neural networks lack specificity when extracting features. Even with continued improvements in classification accuracy, the reliability of these features remains difficult to effectively assess.

[0004] The primary goal of feature analysis is to learn a function or model that maps image features to a low-dimensional Euclidean space, which aligns with the concept of metric learning. In this context, metric learning offers significant advantages over conventional neural network classification methods, as it can learn general concepts of distance metrics and perform efficient nearest neighbor inference in the learned metric space. Traditional metric learning models based on triplet loss suffer from training instability, slow convergence, and difficulty designing reasonable margins. Summary of the Invention

[0005] The present invention provides a medical image classification method and device based on improved triplet loss to solve the technical problems existing in the known technology.

[0006] The technical solution adopted by the present invention to solve the technical problems existing in the known technology is:

[0007] A medical image classification method based on improved triplet loss constructs a medical image classification model based on a neural network and a triplet loss function. Medical images with category labels are collected. According to the category labels, three different categories of medical images in the collected medical images are compiled into a training set. The medical image classification model is trained. The angle loss of the gradient direction is introduced into the triplet loss function, so that the loss function reduces the gradient direction deviation when calculating the gradient direction, thereby accelerating the convergence of the training process.

[0008] Furthermore, each medical image triplet includes an anchor image, a positive sample image, and a negative sample image;

[0009] First, two images are extracted from the training set, one as the anchor image of the triplet and the other as the positive sample image of the triplet. Then, an image is randomly extracted from the training set as the negative sample image of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets.

[0010] The triplet basic loss function is defined as follows:

[0011]

[0012] By introducing the angle loss of the gradient direction into the triplet basic loss function, we get the following improved triplet loss function:

[0013]

[0014] Where:

[0015] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0016] Represents the triplet sequence number;

[0017] Indicates the Anchor images in triplets;

[0018] Indicates the Positive sample images in triplets;

[0019] Indicates the Negative sample images in triplets;

[0020] express ;

[0021] is the threshold, which is used to control the difference between positive samples and negative samples;

[0022] Indicates the The feature vector of the anchor image in the triplet;

[0023] Indicates the The feature vector of the positive sample image in the triplet;

[0024] Indicates the The feature vector of the negative sample image in the triplet;

[0025] Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet;

[0026] Indicates the triplet basis loss;

[0027] Indicates the The loss after the triplet introduces the angle loss of the gradient direction;

[0028] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0029] Furthermore, a distance parameter between negative samples is introduced into the triplet loss function to reduce the distance between samples of the same category and increase the distance between samples of different categories.

[0030] Furthermore, each medical image triplet includes an anchor image, a positive sample image and a pair of negative sample images;

[0031] First, two images are extracted from the training set, one of which is used as the anchor image of the triplet and the other as the positive sample image of the triplet. Then, two images are randomly extracted from the training set as the negative sample images of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets.

[0032] A pair of negative sample images are called negative sample image n1 and negative sample image n2 respectively;

[0033] The loss function that introduces the distance parameter between negative samples is defined as follows:

[0034]

[0035] Where:

[0036] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0037] Represents the sequence number of the triplet with a pair of negative samples;

[0038] Indicates the Anchor images in triplets;

[0039] Indicates the Positive sample images in triplets;

[0040] Indicates the Negative sample image n1 in the triplet;

[0041] Indicates the Negative sample image n2 in the triplet;

[0042] is the threshold, which is used to control the difference between positive samples and negative samples;

[0043] Indicates the The feature vector of the anchor image in the triplet;

[0044] Indicates the The feature vector of the positive sample image in the triplet;

[0045] Indicates the The feature vector of the negative sample image n1 in the triplet;

[0046] Indicates the The feature vector of the negative sample image n2 in the triplet;

[0047] The distance parameter between negative samples is introduced. The loss of triples;

[0048] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0049] Furthermore, the angle loss of the gradient direction and the distance parameter between negative samples are introduced into the triple loss function. The triple loss function is defined as follows:

[0050]

[0051] Where:

[0052] express ;

[0053] express ;

[0054] Represents the weight of the first component of the loss function; Value range: 0 ~ 1;

[0055] Represents the weight of the second component of the loss function; Value range: 0 ~ 1;

[0056] Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet;

[0057] The first step of introducing the angle loss of the gradient direction and the distance parameter between negative samples The loss of a triplet.

[0058] Furthermore, an adaptive margin adjustment parameter is added to the triplet loss function, as shown in the following formula:

[0059]

[0060]

[0061] Where:

[0062] represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images p and q;

[0063] p and q represent the category numbers; p=1, 2, 3; q=1, 2, 3;

[0064] Indicates the center of the sample image of type p; p = 1, 2, 3;

[0065] Indicates the center of the sample image of class q; q=1, 2, 3;

[0066] Indicates the center distance between the two types of sample images p and q;

[0067] Indicates the set coefficient, Value range: 0 ~ 1;

[0068] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 2;

[0069] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 3;

[0070] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 2 and 3;

[0071] Indicates The loss after adding adaptive margin adjustment is based on .

[0072] Furthermore, the medical image classification model includes a metric learning model and a classification model connected in sequence, wherein the metric learning model includes a residual network, a fully connected layer, and a normalization layer connected in sequence, and the classification model includes an SVM classifier. The backbone network weights of the residual network are updated based on the triplet loss function, and the metric learning model is optimized by minimizing the triplet loss.

[0073] Furthermore, the method comprises the following steps:

[0074] Step 1: Build a metric learning model based on the ResNet convolutional neural network;

[0075] Step 2: Use the triplet loss function to train the metric learning model and update the network weights of the metric learning model;

[0076] Step 3: Input the features output by the metric learning model into the SVM classifier and train the SVM classifier using the real labels of the image;

[0077] Step 4, establishing a medical image classification model using the medical image classification model trained in step 2 and the SVM classifier trained in step 3;

[0078] Step 5: Use the medical image classification model established in step 4 to perform classification and analysis.

[0079] The present invention also provides a device for a medical image classification method based on improved triplet loss, comprising a memory and a processor, wherein the memory is used to store a computer program; the processor is used to execute the computer program and implement the steps of the medical image classification method based on improved triplet loss as described above when executing the computer program.

[0080] The advantages and positive effects of the present invention are:

[0081] The present invention can improve training efficiency. By introducing negative group distance, angle loss and adaptive margin calculation strategy, the improved triplet loss function converges faster during the training process, thereby improving the efficiency and stability of model training.

[0082] The present invention can better learn the features of medical images, make the extracted features more discriminative, thereby improving classification performance and contributing to a deeper understanding of the intrinsic characteristics and differences of medical images.

[0083] The present invention can improve classification accuracy, identify different types of medical images more accurately, and provide a more reliable basis for disease diagnosis.

[0084] This invention has important clinical application value and is expected to be applied in actual clinical practice to assist doctors in medical image recognition and analysis, improve the accuracy and efficiency of diagnosis, reduce the workload of doctors, and promote the development of medical image diagnosis technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0085] Figure 1 It is a schematic diagram of the structure of a metric learning model of the present invention.

[0086] Figure 2 It is a schematic diagram of medical image triples.

[0087] Figure 3 It is a schematic diagram of the original triplet loss.

[0088] Figure 4 It is a schematic diagram of triplet loss based on negative sample distance.

[0089] Figure 5 It is a schematic diagram of the original triplet loss gradient update direction.

[0090] Figure 6 It is a schematic diagram of the improved triplet loss gradient update direction.

[0091] Figure 7 It is a schematic diagram of the distance between different samples.

[0092] Figure 8 It is a schematic diagram of the structure of a medical image classification model.

[0093] In the picture:

[0094] A refers to Category A samples;

[0095] B refers to Class B samples;

[0096] C refers to Category C samples;

[0097] set up are any two image feature vectors in the feature space; Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them;

[0098] is the threshold, which is used to control the difference between positive samples and negative samples;

[0099] Represents the triplet sequence number;

[0100] Indicates the Anchor images in triplets;

[0101] Indicates the Positive sample images in triplets;

[0102] Indicates the Negative sample images in triplets;

[0103] Indicates the The updated position of each anchor point;

[0104] Indicates the The updated position of positive samples;

[0105] Indicates the The updated position of negative samples;

[0106] Indicates the Negative sample image n1 in the triplet;

[0107] Indicates the Negative sample image n2 in the triplet;

[0108] Indicates the The feature vector of the anchor image in the triplet;

[0109] Indicates the The feature vector of the positive sample image in the triplet;

[0110] Indicates the The feature vector of the negative sample image in the triplet;

[0111] Indicates the The feature vector of the negative sample image n1 in the triplet;

[0112] Indicates the The feature vector of the negative sample image n2 in the triplet;

[0113] 、 、 Corresponding representation 、 and About loss function The derivative of

[0114] a12 represents the distance from the positive sample to one of the negative samples in the triplet;

[0115] a13 represents the distance from the positive sample to another negative sample in the triplet;

[0116] a23 represents the distance between two negative samples. DETAILED DESCRIPTION

[0117] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention and are not used to limit the present invention.

[0118] In the description of the present invention, the terms "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", etc., indicating directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and do not require that the present invention must be constructed and operated in a specific direction. Therefore, they should not be understood as limitations on the present invention. The terms "connected" and "connection" used in the present invention should be understood in a broad sense. For example, it can be a fixed connection or a detachable connection; it can be a direct connection or an indirect connection through an intermediate component; it can also be an electrical connection or signal transmission. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to the specific circumstances.

[0119] The Chinese meanings of the following English words, abbreviations and phrases in this application are as follows:

[0120] SVM: Support vector machine is a generalized linear classifier that performs binary classification on data using supervised learning. Its decision boundary is the maximum margin hyperplane solved for the learning samples.

[0121] ResNet: Residual network is a deep convolutional neural network architecture proposed by He Kaiming and others in 2015. Its core innovation is to solve the gradient vanishing problem in deep neural network training through residual blocks and skip connections, significantly improving the accuracy of image recognition tasks.

[0122] Anchor: anchor point.

[0123] Positive: positive sample.

[0124] Negative: negative sample.

[0125] See Figures 1 to 8 A medical image classification method based on improved triplet loss is proposed. A medical image classification model based on neural network and triplet loss function is constructed. Medical images with category labels are collected. According to the category labels, three different categories of medical images in the collected medical images are edited into a training set. The medical image classification model is trained. The angle loss of the gradient direction is introduced into the triplet loss function, so that the loss function reduces the gradient direction deviation when calculating the gradient direction, thereby accelerating the convergence of the training process.

[0126] Triplet loss is a loss function used to train neural networks. It is mainly used for metric learning tasks, especially in face recognition, image retrieval and other fields.

[0127] Preferably, each medical image triplet includes an anchor image, a positive sample image and a negative sample image;

[0128] First, two images can be extracted from the training set, one as the anchor image of the triplet, and the other as the positive sample image of the triplet. Then, an image is randomly extracted from the training set as the negative sample image of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets.

[0129] It can be set by The medical image triplet composed of the extracted images is The triplet basic loss function can be defined as follows:

[0130]

[0131] By introducing the angle loss of the gradient direction into the triplet basic loss function, the following improved triplet loss function can be obtained:

[0132]

[0133] Where:

[0134] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0135] Represents the triplet sequence number;

[0136] Indicates the Anchor images in triplets;

[0137] Indicates the Positive sample images in triplets;

[0138] Indicates the Negative sample images in triplets;

[0139] express ;

[0140] is the threshold, which is used to control the difference between positive samples and negative samples;

[0141] Indicates the The feature vector of the anchor image in the triplet;

[0142] Indicates the The feature vector of the positive sample image in the triplet;

[0143] Indicates the The feature vector of the negative sample image in the triplet;

[0144] Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet;

[0145] Indicates the triplet basis loss;

[0146] Indicates the The loss after the triplet introduces the angle loss of the gradient direction;

[0147] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0148] Preferably, a distance parameter between negative samples can be introduced into the triplet loss function to reduce the distance between samples of the same category and increase the distance between samples of different categories.

[0149] Preferably, each medical image triplet may include an anchor image, a positive sample image and a pair of negative sample images;

[0150] First, two images can be extracted from the training set, one as the anchor image of the triplet, and the other as the positive sample image of the triplet. Then, two images are randomly extracted from the training set as the negative sample images of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets.

[0151] A pair of negative sample images can be called negative sample image n1 and negative sample image n2 respectively;

[0152] It can be set by The medical image triplet composed of the extracted images is The loss function of the distance parameter between negative samples can be defined as follows:

[0153]

[0154] Where:

[0155] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0156] Represents the sequence number of the triplet with a pair of negative samples;

[0157] Indicates the Anchor images in triplets;

[0158] Indicates the Positive sample images in triplets;

[0159] Indicates the Negative sample image n1 in the triplet;

[0160] Indicates the Negative sample image n2 in the triplet;

[0161] is the threshold, which is used to control the difference between positive samples and negative samples;

[0162] Indicates the The feature vector of the anchor image in the triplet;

[0163] Indicates the The feature vector of the positive sample image in the triplet;

[0164] Indicates the The feature vector of the negative sample image n1 in the triplet;

[0165] Indicates the The feature vector of the negative sample image n2 in the triplet;

[0166] The distance parameter between negative samples is introduced. The loss of triples;

[0167] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0168] Preferably, the angle loss of the gradient direction and the distance parameter between negative samples can be introduced into the triplet loss function at the same time. The triplet loss function can be defined as follows:

[0169]

[0170] Where:

[0171] express ;

[0172] express ;

[0173] Represents the weight of the first component of the loss function; Value range: 0 ~ 1;

[0174] Represents the weight of the second component of the loss function; Value range: 0 ~ 1;

[0175] Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet;

[0176] The first step of introducing the angle loss of the gradient direction and the distance parameter between negative samples The loss of a triplet.

[0177] Preferably, an adaptive margin adjustment parameter can be added to the triplet loss function, as shown in the following formula:

[0178]

[0179]

[0180] Where:

[0181] represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images p and q;

[0182] p and q represent the category numbers; p=1, 2, 3; q=1, 2, 3;

[0183] Indicates the center of the sample image of type p; p = 1, 2, 3;

[0184] Indicates the center of the sample image of class q; q=1, 2, 3;

[0185] Indicates the center distance between the two types of sample images p and q;

[0186] Indicates the set coefficient, Value range: 0 ~ 1;

[0187] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 2;

[0188] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 3;

[0189] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 2 and 3;

[0190] Indicates The loss after adding adaptive margin adjustment is based on .

[0191] Preferably, the medical image classification model may include a metric learning model and a classification model connected in sequence, wherein the metric learning model includes a residual network, a fully connected layer, and a normalization layer connected in sequence, and the classification model includes an SVM classifier. The backbone network weights of the residual network are updated based on the triplet loss function, and the metric learning model is optimized by minimizing the triplet loss.

[0192] Preferably, the method may include the following steps:

[0193] Step 1: Build a metric learning model based on the ResNet convolutional neural network;

[0194] Step 2: Use the triplet loss function to train the metric learning model and update the network weights of the metric learning model;

[0195] Step 3: Input the features output by the metric learning model into the SVM classifier and train the SVM classifier using the real labels of the image;

[0196] Step 4, establishing a medical image classification model using the medical image classification model trained in step 2 and the SVM classifier trained in step 3;

[0197] Step 5: Use the medical image classification model established in step 4 to perform classification and analysis.

[0198] The present invention also provides a device for a medical image classification method based on improved triplet loss, comprising a memory and a processor, wherein the memory is used to store a computer program; the processor is used to execute the computer program and implement the steps of the medical image classification method based on improved triplet loss as described above when executing the computer program.

[0199] The following further describes the workflow and working principle of the present invention according to a preferred embodiment of the present invention:

[0200] like Figure 2 As shown, the definition of triples is composed of anchor images , Positive image and negative images The original triplet loss function is:

[0201]

[0202]

[0203] Where:

[0204] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0205] Represents the triplet sequence number;

[0206] Indicates the number of triples;

[0207] Indicates the triplet anchor image;

[0208] Indicates the triplet of positive sample images;

[0209] Indicates the triplet of negative sample images;

[0210] Indicates the The feature vector of the triplet anchor image;

[0211] Indicates the The feature vector of the triplet positive sample image;

[0212] Indicates the The feature vector of the triplet negative sample image;

[0213] Indicates the triplet basic loss;

[0214] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0215] represents the triplet basic loss.

[0216] The basic principle of the triplet basic loss function is to ensure that the distance between the anchor point and the positive sample is added is smaller than the distance between the anchor point and the negative sample, assuming that the image The corresponding eigenvector is ,but Should be greater than .

[0217] Take separately 、 and About loss function The derivative of is:

[0218]

[0219]

[0220]

[0221] The gradient update diagram is as follows Figure 5 As shown, but the actual gradient direction and Inconsistent. and Although s strives to gather and , but their gradient directions also deviate.

[0222] This project proposes a triplet loss with angular loss, which is defined as:

[0223]

[0224] in, and The center is , express Then we have:

[0225]

[0226] Where:

[0227] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0228] Represents the triplet sequence number;

[0229] Indicates the Anchor images in triplets;

[0230] Indicates the Positive sample images in triplets;

[0231] Indicates the Negative sample images in triplets;

[0232] express ;

[0233] is the threshold, which is used to control the difference between positive samples and negative samples;

[0234] Indicates the The feature vector of the anchor image in the triplet;

[0235] Indicates the The feature vector of the positive sample image in the triplet;

[0236] Indicates the The feature vector of the negative sample image in the triplet;

[0237] Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet;

[0238] Indicates the triplet basis loss;

[0239] Indicates the The loss after the triplet introduces the angle loss of the gradient direction;

[0240] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0241] Take separately 、 and About loss function The derivative of , then:

[0242]

[0243] The improved gradient update diagram is as follows Figure 6 As shown, Indicates the The updated position of each anchor point; Indicates the The updated position of positive samples; Indicates the The updated position of negative samples; and They are the same. And and Committed to gathering and ,and and Converging at one point.

[0244] The schematic diagram of triplet basis loss is as follows Figure 3 As shown, where:

[0245] The distance between samples of category A is When the loss function When pushing the B and C samples apart during training and satisfying the constraints, the loss function does not introduce the distance between B and C, and the pushing process will make B and C closer.

[0246] In order to alleviate the weak generalization ability of triple loss, it is necessary not only to reduce the distance between similar samples but also to increase the distance between different categories. The distance between negative samples is introduced into triple loss to make the samples of the same category closer and the distance between different categories larger. The triple loss function based on negative sample distance is as follows: Figure 4 shown.

[0247] Each medical image triplet includes an anchor image, a positive sample image and a pair of negative sample images;

[0248] First, two images are extracted from the training set, one of which is used as the anchor image of the triplet and the other as the positive sample image of the triplet. Then, two images are randomly extracted from the training set as the negative sample images of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets.

[0249] A pair of negative sample images are called negative sample image n1 and negative sample image n2 respectively;

[0250] Assuming the The medical image triplet composed of the extracted images is The loss function of the distance parameter between the three negative samples is defined as follows:

[0251]

[0252] Where:

[0253] Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space;

[0254] Represents the sequence number of the triplet with a pair of negative samples;

[0255] Indicates the Anchor images in triplets;

[0256] Indicates the Positive sample images in triplets;

[0257] Indicates the Negative sample image n1 in the triplet;

[0258] Indicates the Negative sample image n2 in the triplet;

[0259] is the threshold, which is used to control the difference between positive samples and negative samples;

[0260] Indicates the The feature vector of the anchor image in the triplet;

[0261] Indicates the The feature vector of the positive sample image in the triplet;

[0262] Indicates the The feature vector of the negative sample image n1 in the triplet;

[0263] Indicates the The feature vector of the negative sample image n2 in the triplet;

[0264] The distance parameter between negative samples is introduced. The loss of triples;

[0265] When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

[0266] The improved triplet loss based on negative sample distance tightens the sample distance of class A while pushing classes B and C away from class A, which is consistent with the effect of the original triplet loss. At the same time, in the process of pushing classes B and C away, the distance between B and C increases, which further improves the convergence speed of the model.

[0267] The distance parameter between negative samples is introduced according to the following formula to obtain a further improved triplet loss function:

[0268]

[0269] Where:

[0270] express ;

[0271] express ;

[0272] Represents the weight of the first component of the loss function; Value range: 0 ~ 1;

[0273] Represents the weight of the second component of the loss function; Value range: 0 ~ 1;

[0274] Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet;

[0275] The first step of introducing the angle loss of the gradient direction and the distance parameter between negative samples The loss of a triplet.

[0276] like Figure 7 As shown in , a12 represents the distance from the positive sample to one of the negative samples in the triplet; a13 represents the distance from the positive sample to the other negative sample in the triplet; a23 represents the distance between the two negative samples.

[0277] From common sense, the values ​​of a12 and a13 should be greater than that of a23 to indicate the similarity between different categories. Therefore, the threshold requires a more detailed calculation strategy.

[0278] This paper proposes an online threshold calculation strategy, which adaptively calculates the threshold based on the existing expression , and by updating the threshold Continue model training as shown below.

[0279] An adaptive margin adjustment strategy is added to the triplet loss, which refers to the similarity of the original samples and maintains the original spatial form when the loss function is introduced into different categories. The threshold is updated according to the following formula Continue model training:

[0280]

[0281]

[0282] Where:

[0283] represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images p and q;

[0284] p and q represent the category numbers; p=1, 2, 3; q=1, 2, 3;

[0285] Indicates the center of the sample image of type p; p = 1, 2, 3;

[0286] Indicates the center of the sample image of class q; q=1, 2, 3;

[0287] Indicates the center distance between the two types of sample images p and q;

[0288] Indicates the set coefficient, Value range: 0 ~ 1;

[0289] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 2;

[0290] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 3;

[0291] Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 2 and 3;

[0292] Indicates The loss after adding adaptive margin adjustment is based on .

[0293] The medical image classification model includes a metric learning model and a classification model connected in sequence, wherein the metric learning model includes a residual network, a fully connected layer, and a normalization layer connected in sequence, and the classification model includes an SVM classifier. The improved triplet loss function is used to update the weights of the ResNet backbone network, and the metric learning model is optimized by minimizing the triplet loss.

[0294] like Figure 1 As shown in Figure 2, in the metric learning model, the improved triplet loss function is used to update network weights. The model is optimized by minimizing the triplet loss, which helps the network learn the characteristics of medical images. ResNet is introduced as the backbone for metric learning. The normalization layer after the fully connected layer helps stabilize the training process and accelerate convergence. This model leverages metric learning and the powerful feature representation capabilities of ResNet to achieve accurate and reliable medical image classification.

[0295] The medical image is converted into a feature vector by the trained model. The metric learning model is used as a feature extractor. The feature vector is input to the SVM, which is used to classify the image, such as Figure 8 shown.

[0296] After the above analysis, the medical image classification method based on the improved triplet loss in the present invention can be specifically carried out according to the following steps:

[0297] Step 1: Build a metric learning model based on ResNet convolutional neural network; Figure 1 shown.

[0298] Step 2: Use the triplet loss function to train the metric learning model and update the network weights of the metric learning model.

[0299] Step 3: Input the features output by the metric learning model into the SVM classifier and train the SVM classifier using the real labels of the image.

[0300] Step 4: Establish a medical image classification model based on the medical image classification model trained in step 2 and the SVM classifier trained in step 3, as shown in Figure 8 shown.

[0301] Step 5: Use the medical image classification model established in step 4 to perform classification and analysis.

[0302] Medical image classification can be achieved through the above steps, which not only improves the classification accuracy of medical images, but also standardizes the features extracted by the convolutional network, and has important clinical application value.

[0303] The above-mentioned neural networks, metric learning models, classification models, residual networks, fully connected layers, normalization layers, SVM classifiers, ResNet convolutional neural networks and other neural networks and functional modules can all adopt applicable neural networks and functional modules in the existing technology, or can adopt applicable neural networks and functional modules in the existing technology and construct them using conventional technical means.

[0304] The embodiments described above are only used to illustrate the technical ideas and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. The scope of the patent of the present invention cannot be limited by these embodiments alone. That is, any equivalent changes or modifications made to the spirit disclosed by the present invention still fall within the scope of the patent of the present invention.

Claims

1. A medical image classification method based on improved triplet loss, characterized in that: A medical image classification model based on neural networks and triplet loss function is constructed. Medical images with category labels are collected. According to the category labels, three different categories of medical images in the collected medical images are compiled into a training set. The medical image classification model is trained. The angle loss of the gradient direction is introduced into the triplet loss function, so that the loss function reduces the gradient direction deviation when calculating the gradient direction, thereby accelerating the convergence of the training process.

2. The medical image classification method based on improved triplet loss according to claim 1, characterized in that: Each medical image triplet includes an anchor image, a positive sample image, and a negative sample image; First, two images are extracted from the training set, one as the anchor image of the triplet and the other as the positive sample image of the triplet. Then, an image is randomly extracted from the training set as the negative sample image of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets. The triplet basic loss function is defined as follows: ; By introducing the angle loss of the gradient direction into the triplet basic loss function, we get the following improved triplet loss function: ; Where: Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space; Represents the triplet sequence number; Indicates the Anchor images in triplets; Indicates the Positive sample images in triplets; Indicates the Negative sample images in triplets; express ; is the threshold, which is used to control the difference between positive samples and negative samples; Indicates the Feature vectors of the anchor images in the triplet; Indicates the The feature vector of the positive sample image in the triplet; Indicates the The feature vector of the negative sample image in the triplet; Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet; Indicates the triplet basis loss; Indicates the The loss after the triplet introduces the angle loss of the gradient direction; When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

3. The medical image classification method based on improved triplet loss according to claim 1, characterized in that: The distance parameter between negative samples is also introduced into the triplet loss function to reduce the distance between samples of the same category and increase the distance between samples of different categories.

4. The medical image classification method based on improved triplet loss according to claim 3, characterized in that: Each medical image triplet includes an anchor image, a positive sample image and a pair of negative sample images; First, two images are extracted from the training set, one of which is used as the anchor image of the triplet and the other as the positive sample image of the triplet. Then, two images are randomly extracted from the training set as the negative sample images of the triplet to form a medical image triplet. The negative sample images are repeatedly extracted to form several medical image triplets. A pair of negative sample images are called negative sample image n1 and negative sample image n2 respectively; The loss function that introduces the distance parameter between negative samples is defined as follows: ; Where: Indicates calculating two image feature vectors in the feature space 、 The distance measurement function between them; are any two image feature vectors in the feature space; Represents the sequence number of the triplet with a pair of negative samples; Indicates the Anchor images in triplets; Indicates the Positive sample images in triplets; Indicates the Negative sample image n1 in the triplet; Indicates the Negative sample image n2 in the triplet; is the threshold, which is used to control the difference between positive samples and negative samples; Indicates the Feature vectors of the anchor images in the triplet; Indicates the The feature vector of the positive sample image in the triplet; Indicates the The feature vector of the negative sample image n1 in the triplet; Indicates the The feature vector of the negative sample image n2 in the triplet; The distance parameter between negative samples is introduced. The loss of triples; When the value in [ ] is greater than zero, the loss is taken as the value; when it is less than zero, the loss is zero.

5. The medical image classification method based on improved triplet loss according to claim 4, characterized in that: The angle loss of the gradient direction and the distance parameter between negative samples are introduced into the triplet loss function. The triplet loss function is defined as follows: ; Where: express ; express ; Represents the weight of the first component of the loss function; Value range: 0 ~ 1; Represents the weight of the second component of the loss function; Value range: 0 ~ 1; Indicates the The geometric midpoint of the feature vectors of the anchor image and the positive sample image in the triplet; The first step of introducing the angle loss of the gradient direction and the distance parameter between negative samples The loss of triples.

6. The medical image classification method based on improved triplet loss according to claim 5, characterized in that: Add an adaptive margin adjustment parameter to the triplet loss function as shown below: ; ; Where: Indicated by Adaptive margin adjustment parameters for automatic adjustment of the center distance between two types of sample images; 、 Indicates the category number; =1, 2, 3; =1, 2, 3; express Class sample image center; =1, 2, 3; express Class sample image center; =1, 2, 3; express The center distance between two types of sample images; Indicates the set coefficient, Value range: 0 ~ 1; Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 2; Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 1 and 3; Represents the adaptive margin adjustment parameter automatically adjusted by the center distance of the two types of sample images 2 and 3; Indicates The loss after adding adaptive margin adjustment is based on .

7. The medical image classification method based on improved triplet loss according to claim 1, characterized in that: The medical image classification model includes a metric learning model and a classification model connected in sequence, wherein the metric learning model includes a residual network, a fully connected layer, and a normalization layer connected in sequence, and the classification model includes an SVM classifier. The backbone network weights of the residual network are updated based on the triplet loss function, and the metric learning model is optimized by minimizing the triplet loss.

8. The medical image classification method based on improved triplet loss according to claim 7, characterized in that: The method comprises the following steps: Step 1: Build a metric learning model based on the ResNet convolutional neural network; Step 2: Use the triplet loss function to train the metric learning model and update the network weights of the metric learning model; Step 3: Input the features output by the metric learning model into the SVM classifier and train the SVM classifier using the real labels of the image; Step 4, establishing a medical image classification model using the medical image classification model trained in step 2 and the SVM classifier trained in step 3; Step 5: Use the medical image classification model established in step 4 to perform classification and analysis.

9. A device for medical image classification based on an improved triplet loss method, comprising a memory and a processor, characterized in that: The memory is used to store a computer program; the processor is used to execute the computer program and implement the steps of the medical image classification method based on improved triplet loss as described in any one of claims 1 to 8 when executing the computer program.

Citation Information

Patent Citations

  • Trace ratio criterion-based triple loss function design method

    CN108399428A

  • Image classification model training method, image classification method, equipment and medium

    CN115496955A

  • Recommendation method fusing angle distance and robust scale measurement learning

    CN118364910A

  • Discriminative Cosine Embedding in Machine Learning

    US20190279091A1