Leucoderma image classification method and system
Through the image classification model of the parallel ResNet and Swin Transformer branches, combined with the class activation mapping CAM module, the problem of insufficient interpretability in vitiligo diagnosis is solved, the accurate classification and visual diagnosis of vitiligo images are achieved, and the transparency and transparency of diagnosis are improved. Trust.
Patent Information
- Application Number
- CN202410740470.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-08
- Publication Date
- 2024-09-10
AI Technical Summary
Traditional deep learning methods have insufficient interpretability in vitiligo diagnosis, resulting in a lack of transparency and trust in the diagnostic process, hindering their widespread application in clinical practice.
The image classification model using the parallel ResNet branch and Swin Transformer branch, combined with the class activation mapping CAM module, provides visual diagnosis results by capturing the intermediate layer feature output map and generating the category activation map, and improves the transparency and trust of the diagnosis process.
It achieves accurate classification and interpretable diagnosis of vitiligo images, provides visual representation of disease-related areas, and improves diagnostic accuracy and trust.
Smart Images

Figure CN118628809A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer deep learning medical image recognition, and in particular to a vitiligo image classification method and system. Background Art
[0002] Vitiligo is a common skin disease characterized by a loss of melanin, resulting in white patches on the skin. The disease is widespread and affects tens of thousands of people worldwide. Vitiligo has a complex etiology that includes genetic, autoimmune and environmental factors, making it an important subject of study in the medical and dermatological fields.
[0003] However, despite the high prevalence and progressive nature of vitiligo, its diagnosis remains challenging, especially in some areas with limited medical resources. Doctors usually need to rely on visual observation and experience to make a diagnosis, which may lead to misdiagnosis and delayed treatment. Therefore, it becomes crucial to develop an accurate and interpretable vitiligo diagnostic tool that can help doctors improve accuracy and speed.
[0004] Deep learning technology has achieved remarkable success in the field of medical image processing, including skin disease diagnosis. Deep learning models can automatically extract and analyze features in medical images, thereby supporting fast and accurate disease diagnosis. There have been some research works on deep learning in skin disease diagnosis, however, for skin diseases such as vitiligo, traditional deep learning methods are insufficient in interpretability, and it faces a major challenge known as the "black box" problem. Although the mathematical theory is relatively simple, the output mechanism is difficult to understand. In the field of medical image processing, the interpretability of classification results using deep learning methods is a major challenge. Therefore, it prevents doctors and researchers from understanding the logic and mechanism of implementing these methods. This lack of interpretability weakens the reliability of deep learning methods, thereby limiting their application in clinical practice. Summary of the invention
[0005] The purpose of the present invention is to provide a vitiligo image classification method and system for identifying vitiligo and providing highly interpretable diagnostic information, thereby improving the transparency and trust of the diagnostic process.
[0006] A first aspect of an embodiment of the present invention provides a vitiligo image classification method, comprising the following steps: Acquiring image data, the image data comprising: a dermoscopic image and a clinical image; Input the image data into a pre-trained image classification model to obtain a classification result and a class activation map output by the image classification model, wherein the class activation map is obtained by a class activation map CAM module in the image classification model, and the class activation map is used to identify the image area most relevant to each class in the classification result; A visual image classification result is generated according to the classification result and the category activation map.
[0007] Furthermore, the method further comprises: When the image classification model extracts features from the image data through the intermediate layer, the feature output graph of the intermediate layer is captured through a pre-registered Hook function; The generating a visual image classification result according to the classification result and the category activation map includes: A visual image classification result is generated according to the feature output map, the classification result and the category activation map.
[0008] Furthermore, the image data is preprocessed image data, wherein: For the dermoscopic image, the preprocessing includes: one or more of noise removal, standardization and data enhancement processing; For clinical images, the preprocessing includes: performing HSV color space conversion on the clinical images and / or generating a Wood's lamp image using a Pix2pix image translation model.
[0009] Furthermore, the image classification model includes a parallel ResNet branch and a Swin Transformer branch, the class activation mapping CAM module is located in the ResNet branch, the ResNet branch is used to visualize the image; the Swin Transformer branch is used to process the global information in the image; accordingly, the training of the image classification model includes: Acquire image samples, wherein the image samples include dermoscopic image samples and clinical image samples of vitiligo; Initializing the image classification model, including initializing the Swin Transformer branch weights, adjusting the learning rate, batch size, and optimizer selection of the Swin Transformer branch; Inputting the image sample into the initialized image classification model to obtain a prediction result output by the image classification model; According to the prediction result and the actual classification result of the pattern sample, and according to the loss value between the prediction result and the actual classification result, the model parameters of the image classification model are adjusted until a model convergence condition is met.
[0010] Furthermore, during the model training process, the number of category labels of the image samples is adjusted, specifically: Get initial values, including expected values , target gain, number of Epochs and number of cycles Times for each training; The image classification model is trained for Epochs cycles, and after the Epochs cycles of training are completed, an evaluation index of the image classification model is determined, wherein the evaluation index includes: precision P and recall rate r; If the evaluation index does not reach the expected value , the labels of the image categories are amplified, and the image classification model is trained again for Epochs cycles based on the image samples after the category labels are amplified; If the evaluation index reaches the expected value Or if the image category gains are all less than the target gain, the model training ends.
[0011] Furthermore, the step of amplifying the label of the image category includes: The labels of image categories are amplified k-fold, and the value of k is: , Where cmax represents the number of samples of the category with the largest number of samples among all categories. clabel represents the number of samples of a specific category label, p represents the precision, r represents the recall rate, i represents the number of cycles, and each round of training includes the Epochs cycles.
[0012] Furthermore, the ResNet branch is used to visualize the image specifically as follows: The ResNet branch includes: a convolutional layer, a pooling layer, a residual block and a class activation mapping CAM module; The convolution layer is used to extract features from the input image samples to obtain a feature map; The pooling layer is used to reduce the spatial dimension of the feature map to 1x1; The class activation map CAM module is used to receive the output feature map of the residual block as input, perform global average pooling on the feature map of a vector of a fixed length to obtain feature map values, and weight and sum the feature map values to obtain a class activation map.
[0013] Furthermore, the Swin Transformer branch is used to process the global information in the image as follows: The Swin Transformer branch includes a Patch Partion layer, a linear embedding layer, and three Transformer encoding layers; The Patch Partion layer is used to divide the input image samples into blocks; The linear embedding layer includes a Linear Embedding block and a Swin Transformer Block block, which are used to perform a linear transformation on the number of channels to map the channels of the image samples to C; Each Transformer coding layer includes a Patch Merging block and a SwinTransformer Block block, wherein the Patch Merging block is used to double the number of channels of the image sample and to reduce the height and width to 1 / 2 of the original; The Swin Transformer Block includes a W-MSA module and a SW-MSA module. The W-MSA module is used to divide the image sample into multiple windows of the same size and non-overlapping, and each window is processed as a separate attention head; the SW-MSA module is used to design a mask matrix for each window, wherein the mask matrix is assigned a value of -100 for the part that should not be calculated for attention.
[0014] A second aspect of an embodiment of the present invention provides a vitiligo image classification system, which adopts the above-mentioned vitiligo image classification method, and specifically includes: A data acquisition module, used to acquire image data, wherein the image data includes: a dermoscopic image and a clinical image; Preprocessing module: used to preprocess the image data, wherein: For the dermoscopic image, the preprocessing includes: one or more of noise removal, standardization and data enhancement processing; For clinical images, the preprocessing includes: performing HSV color space conversion on the clinical images and / or generating a wood lamp image using a Pix2pix image translation model; Classification model training module: used to train the image classification model, including: Acquire image samples, wherein the image samples include dermoscopic image samples and clinical image samples of vitiligo; Initializing the image classification model, including initializing the Swin Transformer branch weights, adjusting the learning rate, batch size, and optimizer selection of the Swin Transformer branch; Inputting the image sample into the initialized image classification model to obtain a prediction result output by the image classification model; According to the prediction result and the actual classification result of the pattern sample, and according to the loss value between the prediction result and the actual classification result, the model parameters of the image classification model are adjusted until a model convergence condition is met; A classification model operation module is used to input the image data into a pre-trained image classification model to obtain a classification result and a class activation map output by the image classification model. The class activation map is obtained by a class activation map CAM module in the image classification model. The class activation map is used to identify the image area most relevant to each class in the classification result. Image visualization module: used to generate a visualized image classification result based on the classification result and the category activation map.
[0015] The present invention has at least the following beneficial effects: The output results of the present invention can not only provide disease labels, but also provide a visual diagnosis report showing possible areas associated with the disease. The results produced by the class activation mapping CAM module effectively emphasize the specific areas of each category within the diagnosis point, thereby facilitating decision-making in the process of skin disease diagnosis.
[0016] The vitiligo image classification system provided by the present invention can classify vitiligo skin diseases and non-vitiligo skin diseases using dermoscopic images, and can output interpretable information about the classification results, such as diagnostic results with visual representations of potential disease-related areas, thereby improving the diagnostic accuracy of vitiligo.
[0017] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flow chart of a vitiligo image classification method and system provided by an embodiment of the present invention; Figure 2 It is a structural diagram of a ResNet branch of a vitiligo image classification method and system provided by an embodiment of the present invention; Figure 3 It is a structural diagram of a Swin Transformer branch of a vitiligo image classification method and system provided by an embodiment of the present invention; Figure 4 is a feature output graph in the ResNet branch provided by an embodiment of the present invention; Figure 5 It is a feature output graph from the Swin Transformer branch provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0020] In the description of the present invention, it is necessary to understand that the terms "upper", "lower", "front", "back", "left", "right", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0021] Example 1: Combination Figure 1-Figure 5 To illustrate this embodiment, This embodiment is a vitiligo image classification method, comprising the following steps: Acquire image data, the image data including: dermoscopic images and clinical images; The image data is input into the pre-trained image classification model to obtain the classification results and class activation maps output by the image classification model. The class activation maps are obtained through the class activation map CAM module in the image classification model. The class activation maps are used to identify the image areas most relevant to each class in the classification results. Generate visual image classification results based on classification results and category activation maps.
[0022] Furthermore, the method also includes: When the image classification model extracts features from image data through the intermediate layer, it captures the feature output graph of the intermediate layer through the pre-registered Hook function; Generate visual image classification results based on classification results and category activation maps, including: Generate visual image classification results based on feature output maps, classification results, and category activation maps.
[0023] Register a Hook function in the model. The Hook function is a custom callback function that can capture the output of a specific layer during forward propagation. When the input image is forward propagated through the network, the registered Hook function is triggered to capture the output feature map of the convolutional layer in the ResNet branch. The captured output feature map can be used for visual interpretation and analysis, as well as the interpretability of the image classification model. Figure 4-Figure 5 As shown, Figure 4 The numbers 64, 128, 256, 512, 1024, and 2048 following ResNet represent the dimensions of the output feature maps of different convolutional layers. Figure 5In swin_base: "base" is the size or version of the Swin Transformer branch; patch4 means that the Swin Transformer branch divides the image into small patches of size 4x4; window12 means that the Swin Transformer branch uses the window self-attention mechanism, 12 means that each self-attention window contains a 12x12 patch, and 7 means that each self-attention window contains a 7x7 patch; 384 means that the image resolution is 384x384 pixels; in22k: means that the Swin Transformer branch is pre-trained on a dataset containing approximately 22,000 categories. The feature output maps are displayed separately in different layouts, and each grid represents a feature output map. Each convolutional layer extracts features at different levels and abstractions, allowing the output feature map to comprehensively represent different visual information of the input image from multiple intermediate layers, so that the decision process and performance of the image classification model can be better understood.
[0024] Furthermore, the image data is preprocessed image data, wherein: For dermoscopic images, preprocessing includes: one or more of noise removal, normalization and data enhancement processing; For clinical images, preprocessing includes: performing HSV color space conversion on clinical images and / or generating wood lamp images using Pix2pix image translation model.
[0025] Diverse vitiligo image data were collected, including dermoscopic images and clinical images. The image data were image samples of different lesion degrees and locations. The image data was preprocessed. For dermoscopic images, since they provide a more detailed and magnified view, allowing doctors to observe skin lesions more accurately, and the dermoscopic images have a high degree of smoothness, the quality of the image data can be improved by removing noise, standardization, and data enhancement. Data enhancement specifically includes the following methods: rotating the image at a random angle between -180° and 180°; adjusting the image brightness to brightness=0.5; adjusting the image contrast to contrast=[0.7,1.3]; and adjusting the image saturation to saturation=[0.8,1.2]. In addition, in order to maintain the size of the original image, any blank space generated from the data enhancement process is filled with black pixels. For clinical images, the image quality may vary due to factors such as equipment, light, and angle. Low-quality images may cause the model to learn inaccurate or misleading features. Therefore, HSV color space conversion and / or Pix2pix image translation model are used to convert the original images of vitiligo patients into clinical wood lamp images.
[0026] The specific use of HSV color space conversion is to convert the ordinary image into HSV hue, so as to achieve the effect under the wood light and improve the image quality. Use the following formula for conversion: , in, Represents hue. and It is a parameter used to adjust the hue, which is used to change the original hue. The value of . Used to increase hue, and Used to reduce hue. is saturation, is the brightness. The three indicators of the generated wood lamp image and the original wood lamp image are calculated to evaluate the reliability of the method. The results are shown in Table 1: Table 1 HSV color space conversion evaluation indicators
[0027] Pix2pix is an image translation model based on the conditional generative adversarial network (CGAN), which is an extension of the generative adversarial network. It achieves conditional image generation by introducing conditional information in the generator and discriminator. The generator adopts the U-Net network structure, which integrates the underlying fine-grained features and high-level abstraction; the discriminator adopts the patchGAN network structure to extract high-frequency information such as texture at the patch scale. Based on the newly collected vitiligo dataset, using paired original images and wood's lamp images, the Pix2pix network can be used to transfer the style of clinical images and generate new wood's lamp images.
[0028] The indicators of the generated images and the original images are also calculated, and the results are shown in Table 2.
[0029] Table 2 Evaluation indicators of pix2pix generated images
[0030] From the image information generated by two different methods, it can be seen that the images generated by the Pix2pix image translation model are superior to digital image processing methods in most indicators in the area of skin lesions, and can show lesions that are invisible to the naked eye; however, when the image itself has background noise and interference from other non-lesion areas, the generated image effect is unstable and prone to generate large noise. HSV color space conversion cannot enhance the lesion area that is invisible to the naked eye, but it can flexibly adapt to various noisy backgrounds and shooting at various scales, with high conversion efficiency and more stable image quality.
[0031] Furthermore, the image classification model includes a parallel ResNet branch and a Swin Transformer branch, the class activation mapping CAM module is located in the ResNet branch, the ResNet branch is used to visualize the image; the Swin Transformer branch is used to process the global information in the image; accordingly, the training of the image classification model includes: Acquire image samples, including dermoscopic image samples and clinical image samples of vitiligo; Initialize the image classification model, including initializing the weights of the Swin Transformer branches, adjusting the learning rate, batch size, and optimizer selection of the Swin Transformer branches; Input the image sample into the initialized image classification model to obtain the prediction result output by the image classification model; According to the predicted results and the actual classification results of the image samples, and according to the loss value between the predicted results and the actual classification results, the model parameters of the image classification model are adjusted until the model convergence conditions are met.
[0032] The class activation mapping CAM module is integrated in the ResNet branch, and the CAM calculation is performed on the last layer of convolutional feature maps of the ResNet branch. The class activation mapping CAM module can obtain examples of visual explanations, and the visual explanations obtained by the class activation mapping CAM module provide valuable insights for guiding the diagnosis decision of vitiligo.
[0033] After the model is built, the Swin Transformer model is adjusted according to the data and task requirements. The Swin Transformer model has three different variants. The Swin Transformer Large and Swin Transformer Base architecture models are selected in the present invention. The model weights are initialized and the hyperparameters of the model are adjusted. The hyperparameters include learning rate, batch size, and optimizer selection. The selection of these hyperparameters will affect the training speed and performance. The cross entropy loss function is selected and fine-tuned on the data. During the fine-tuning period, the model will gradually adapt to the data according to the specific requirements of the task, and the training process is monitored until the model meets the convergence conditions.
[0034] The performance of the image classification models was evaluated by accuracy, AUC, sensitivity, and specificity, and the results were analyzed. The performance of the five proposed image classification models was evaluated on a real dermoscopic image set, and the detailed data is shown in Table 3.
[0035] From the data in Table 3, it can be seen that the indicators of the Swin Transformer Large model are better than those of the Swin Transformer Base model, with a classification accuracy of 93.82%, a sensitivity of 94.02%, a specificity of 93.5%, and an AUC of 94%. Among the network models of the ResNet series, ResNet34 performed best with a classification accuracy of 89.26%. After evaluating the performance of the five models, it was found that the Swin Transformer Large model had the highest accuracy of 93.82%. Therefore, among these five models, the Swin Transformer Large model is the preferred model of the present invention.
[0036] Table 3 Performance of the five models on the test set
[0037] Furthermore, during the model training process, the number of category labels of the image samples is also adjusted, specifically: Get the initial value, which includes the expected value , target gain, number of Epochs and number of cycles Times for each training; Train the image classification model for Epochs cycles, and determine the evaluation index of the image classification model after the Epochs cycles of training are completed; If the evaluation index does not meet the expected value , the labels of the image categories are amplified, and the image classification model is trained again for Epochs cycles based on the image samples after the category labels are amplified; If the evaluation index reaches the expected value Or if the image category gains are all less than the target gain, the model training ends. Further, the labels of the image categories are amplified, including: The labels of image categories are amplified k-fold, and the value of k is: , Among them, c max Indicates the number of samples of the category with the largest number of samples among all image categories. label is the number of samples of a specific image category label, p is the precision, r is the recall rate, i is the number of cycles, and each round of training includes the Epochs cycles.
[0038] Use dynamic data augmentation algorithm to adjust the number of category labels of image samples and determine the expected value of evaluation index The evaluation indicators include precision P and recall rate r, the number of Epochs and the number of cycles Times for each training. The formula for the value of k is as follows: , When the minimum value of precision P or recall r is less than the expected value When the image category label is amplified by k times, according to the commonly used data enhancement method, the k value is stipulated not to exceed 20 times. Specifically, if the evaluation index does not reach the expected value , the labels of the image categories are amplified, and the image classification model is trained again for Epochs cycles based on the image samples after the category labels are amplified; if the evaluation index reaches the expected value Or if the image category gains are all less than the target gain, the model training ends.
[0039] Furthermore, the ResNet branch is used to visualize the image as follows: The ResNet branch includes: convolutional layer, pooling layer, residual block and class activation map CAM module; The convolution layer is used to extract features from the input image samples to obtain feature maps; The pooling layer is used to reduce the spatial dimension of the feature map to 1x1; The class activation map CAM module is used to receive the output feature map of the residual block as input, perform global average pooling on the feature map of a fixed-length vector to obtain feature map values, and weight and sum the feature map values to obtain a class activation map.
[0040] The class activation map CAM module is integrated in the ResNet branch, and the CAM calculation is performed on the last layer of convolutional feature maps of the ResNet branch. Before the class activation map CAM module, a global average pooling layer (Global AveragePooling, GAP) is added, which reduces the spatial dimension of the feature map to 1x1. In this way, each feature channel will get a response value corresponding to the category. The class activation map CAM module receives the output feature map of the last residual block as input, and performs global average pooling on the feature map of a fixed-length vector to obtain the feature map value, and finally weights and sums the feature map values to obtain the category activation map.
[0041] In the calculation, it is assumed Indicates channel The spatial position coordinates of the last residual block Activation on, for channel , the result of the performed global average pooling is expressed as , and . Therefore, given the category , classifier The result is: , In the formula For and category The corresponding channels in the final dense layer The model weights of the class activation map CAM module are in the category is defined as: , The input image is classified into the target class In the case of class activation mapping, the CAM module identifies each pixel position on the spatial grid of the feature map The class activation map CAM module is upsampled to match the size of the original input image and can identify the regions most relevant to the target category.
[0042] The generated class activation map will be used for visualization. By adding the class activation map CAM module, the present invention can provide highly interpretable diagnostic results and can intuitively highlight specific image areas related to vitiligo diagnosis, which in turn helps doctors better understand the diagnosis of the model and improve the trust and transparency of the diagnostic process.
[0043] Furthermore, the Swin Transformer branch is used to process the global information in the image as follows: The Swin Transformer branch includes a Patch Partion layer, a linear embedding layer, and three Transformer encoding layers; The Patch Partion layer is used to divide the input image samples into blocks; The linear embedding layer includes 1 Linear Embedding block and 1 Swin Transformer Block, which are used to linearly transform the number of channels and map the channels of the image samples to C; Each Transformer encoding layer includes 1 Patch Merging block and 1 Swin TransformerBlock block. The Patch Merging block is used to double the number of channels of the image sample and reduce the height and width to 1 / 2 of the original; The Swin Transformer Block includes the W-MSA module and the SW-MSA module. The W-MSA module is used to divide the image samples into multiple non-overlapping windows of the same size, and each window is treated as a separate attention head; the SW-MSA module is used to design a mask matrix for each window, where the mask matrix is assigned a value of -100 for the part that should not be calculated for attention.
[0044] By introducing the hierarchical window attention mechanism, the application of the Swin Transformer model is extended to the image field, so that the global information within the image can be processed. In the Swin Transformer, the processing of the input image is carried out according to the following steps: First, the input image sample enters the Patch Partion layer. The input image size is H*W*3. The PatchPartion layer divides the image into blocks. For each patch, the size is set to 4x4. Then all patches are superimposed on the third dimension color channel, so that the image dimension becomes [H / 4, W / 4, 4x4x3] = [H / 4, W / 4, 48]; Then, the number of channels is linearly transformed through the Linear Embedding layer, so that the image dimension changes from [H / 4, W / 4,48] to [H / 4, W / 4, C]; Then the image sample enters the Swin Transformer Block. The Swin Transformer Block is the core part of the Swin Transformer. The input and output image dimensions of the Swin Transformer Block will not change. The x2 in the figure indicates that the Swin Transformer Block has two structures. Figure 3 In (2), the two structures only differ in W-MSA and SW-MSA. These two structures are used in pairs, that is, the structure with W-MSA on the left is passed first and then the structure with SW-MSA on the right.
[0045] The W-MSA module divides the image samples into windows and uses a multi-head attention module in each window. In W-MSA, the input features are divided into multiple windows of equal size and non-overlapping, and each window is processed as a separate attention head. In this way, the number of windows directly corresponds to the number of attention heads. For each window, W-MSA uses self-attention to calculate the dependencies between different positions in the window, thereby determining the attention weights of different positions in the window and using these attention weights to weight the aggregate value in the window.
[0046] SW-MSA is mainly to allow information to be transmitted between windows. This window conversion method introduces necessary connections between windows, thereby improving the overall performance of the network. In order to solve the problem of mismatched attention calculations caused by interactive movement between windows, a mask matrix is added. A mask matrix is designed for each window. For the part that should not be calculated, the mask matrix is assigned a value of -100, so that after the subsequent Softmax calculation, it will eventually become 0, thereby playing a filtering role.
[0047] Finally, the Patch Merging block is used to double the number of channels of the image sample, and the height and width are reduced to 1 / 2 of the original. The Patch Merging block extracts four small matrices from a matrix at intervals, and then the four small matrices are concat on the third channel. After LayerNorm, they are mapped into 2 channels through a linear layer.
[0048] Example 2
[0049] The embodiment of the present invention further provides a vitiligo image classification system using the vitiligo image classification method described in Embodiment 1, specifically comprising: A data acquisition module, used to acquire image data, the image data including: dermoscopic images and clinical images; Preprocessing module: used to preprocess image data, including: For dermoscopic images, preprocessing includes: one or more of noise removal, normalization and data enhancement processing; For clinical images, preprocessing includes: performing HSV color space conversion on clinical images and / or generating wood lamp images using Pix2pix image translation model; Classification model training module: used to train the image classification model, including: Acquire image samples, including dermoscopic image samples and clinical image samples of vitiligo; Initialize the image classification model, including initializing the weights of the Swin Transformer branches, adjusting the learning rate, batch size, and optimizer selection of the Swin Transformer branches; Input the image sample into the initialized image classification model to obtain the prediction result output by the image classification model; According to the predicted results and the actual classification results of the image samples, and according to the loss value between the predicted results and the actual classification results, the model parameters of the image classification model are adjusted until the model convergence condition is met; Classification model running module: used to input image data into the pre-trained image classification model to obtain the classification results and category activation maps output by the image classification model. The category activation map is obtained through the class activation map CAM module in the image classification model. The category activation map is used to identify the image area most relevant to each category in the classification result; Image visualization module: used to generate visual image classification results based on classification results and category activation maps.
[0050] It should also be noted that the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "includes one..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements. The words "first", "second" and the like are used to indicate names, but do not indicate any specific order. The above schematically describes the invention and its implementation methods, which is not restrictive. The invention can be implemented in other specific forms without departing from the spirit or basic features of the invention. What is shown in the accompanying drawings is only one of the implementation methods of the invention, and the actual structure is not limited thereto. Any figure mark in the claims should not limit the claims involved. Therefore, if a person of ordinary skill in the art is inspired by it, and does not deviate from the purpose of the invention, and designs a structural mode and an embodiment similar to the technical solution without creativity, they should all belong to the scope of protection of this patent.
Claims
1. A vitiligo image classification method, It is characterized in that The following steps are involved: Acquiring image data, the image data comprising: a dermoscopic image and a clinical image; Input the image data into a pre-trained image classification model to obtain a classification result and a class activation map output by the image classification model, wherein the class activation map is obtained by a class activation map CAM module in the image classification model, and the class activation map is used to identify the image area most relevant to each class in the classification result; A visual image classification result is generated according to the classification result and the category activation map.
2. The method according to claim 1, It is characterized in that The method further comprises: When the image classification model extracts features from the image data through the intermediate layer, the feature output graph of the intermediate layer is captured through a pre-registered Hook function; The generating a visual image classification result according to the classification result and the category activation map includes: A visual image classification result is generated according to the feature output map, the classification result and the category activation map.
3. The method according to claim 1, It is characterized in that The image data is preprocessed image data, wherein: For the dermoscopic image, the preprocessing includes: one or more of noise removal, standardization and data enhancement processing; For clinical images, the preprocessing includes: performing HSV color space conversion on the clinical images and / or generating a Wood's lamp image using a Pix2pix image translation model.
4. The method according to claim 1, It is characterized in that The image classification model includes a parallel ResNet branch and a Swin Transformer branch, the class activation mapping CAM module is located in the ResNet branch, the ResNet branch is used to visualize the image; the Swin Transformer branch is used to process the global information in the image; accordingly, the training of the image classification model includes: Acquire image samples, wherein the image samples include dermoscopic image samples and clinical image samples of vitiligo; Initializing the image classification model, including initializing the Swin Transformer branch weights, adjusting the learning rate, batch size, and optimizer selection of the Swin Transformer branch; Inputting the image sample into the initialized image classification model to obtain a prediction result output by the image classification model; According to the prediction result and the actual classification result of the pattern sample, and according to the loss value between the prediction result and the actual classification result, the model parameters of the image classification model are adjusted until a model convergence condition is met.
5. The method according to claim 4, It is characterized in that During the model training process, the number of category labels of the image samples is also adjusted, specifically: Get initial values, including expected values , target gain, number of Epochs and number of cycles Times for each training; The image classification model is trained for Epochs cycles, and after the Epochs cycles of training are completed, an evaluation index of the image classification model is determined, wherein the evaluation index includes: precision P and recall rate r; If the evaluation index does not reach the expected value , the labels of the image categories are amplified, and the image classification model is trained again for Epochs cycles based on the image samples after the category labels are amplified; If the evaluation index reaches the expected value Or if the image category gains are all less than the target gain, the model training ends.
6. The method according to claim 5, It is characterized in that The step of amplifying the label of the image category includes: The labels of image categories are amplified k-fold, and the value of k is: , Wherein, cmax represents the number of samples of the category with the largest number of samples among all image categories. clabel represents the number of samples of a specific image category label, p represents the precision, r represents the recall rate, i represents the number of cycles, and each round of training includes the Epochs cycles.
7. The method according to claim 4, It is characterized in that The ResNet branch is used to visualize the image specifically as follows: The ResNet branch includes: a convolutional layer, a pooling layer, a residual block and a class activation mapping CAM module; The convolution layer is used to extract features from the input image samples to obtain a feature map; The pooling layer is used to reduce the spatial dimension of the feature map to 1x1; The class activation map CAM module is used to receive the output feature map of the residual block as input, perform global average pooling on the feature map of a vector of a fixed length to obtain feature map values, and weight and sum the feature map values to obtain a class activation map.
8. A vitiligo image classification method according to claim 4, It is characterized in that The SwinTransformer branch is used to process the global information in the image: The Swin Transformer branch includes a Patch Partion layer, a linear embedding layer, and three Transformer encoding layers; The Patch Partion layer is used to divide the input image samples into blocks; The linear embedding layer includes a Linear Embedding block and a Swin Transformer Block block, which are used to perform a linear transformation on the number of channels to map the channels of the image samples to C; Each Transformer coding layer includes a Patch Merging block and a Swin TransformerBlock block, and the Patch Merging block is used to double the number of channels of the image sample and reduce the height and width to 1 / 2 of the original; The Swin Transformer Block includes a W-MSA module and a SW-MSA module. The W-MSA module is used to divide the image sample into multiple windows of the same size and non-overlapping, and each window is processed as a separate attention head; the SW-MSA module is used to design a mask matrix for each window, wherein the mask matrix is assigned a value of -100 for the part that should not be calculated for attention.
9. A vitiligo image classification system, It is characterized in that A vitiligo image classification method according to any one of claims 1 to 8 is used, specifically comprising: A data acquisition module, used to acquire image data, wherein the image data includes: a dermoscopic image and a clinical image; Preprocessing module: used to preprocess the image data, wherein: For the dermoscopic image, the preprocessing includes: one or more of noise removal, standardization and data enhancement processing; For clinical images, the preprocessing includes: performing HSV color space conversion on the clinical images and / or generating a wood lamp image using a Pix2pix image translation model; Classification model training module: used to train the image classification model, including: Acquire image samples, wherein the image samples include dermoscopic image samples and clinical image samples of vitiligo; Initializing the image classification model, including initializing the Swin Transformer branch weights, adjusting the learning rate, batch size, and optimizer selection of the Swin Transformer branch; Inputting the image sample into the initialized image classification model to obtain a prediction result output by the image classification model; According to the prediction result and the actual classification result of the pattern sample, and according to the loss value between the prediction result and the actual classification result, the model parameters of the image classification model are adjusted until a model convergence condition is met; A classification model operation module is used to input the image data into a pre-trained image classification model to obtain a classification result and a class activation map output by the image classification model. The class activation map is obtained by a class activation map CAM module in the image classification model. The class activation map is used to identify the image area most relevant to each class in the classification result. Image visualization module: used to generate a visualized image classification result based on the classification result and the category activation map.
Citation Information
Patent Citations
Brain tumor image classification method based on rejection ResNet-Transformer-deep fusion
CN117351287A
Cited By
Leucoderma image processing system based on multi-modal fusion network
CN121788540A
