Chest X-ray image pneumonia classification device

By combining the multi-scale spatial weighted residual attention mechanism and the efficient scale attention module with supervised contrastive learning, the accuracy and generalization ability of pneumonia classification in chest X-ray images are improved, the problems of difficulty in lesion feature extraction and noise interference in the existing technology are solved, and efficient pneumonia classification is achieved.

CN120635596AActive Publication Date: 2025-09-12TIANJIN THINKING CHAIN ARTIFICIAL INTELLIGENCE CO LTD

Patent Information

Application Number
CN202511106089.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-08
Publication Date
2025-09-12
Estimated Expiration
2045-08-08

AI Technical Summary

Technical Problem

The existing technology for pneumonia classification in chest X-ray images has the problem that single-scale feature extraction is difficult to capture the spatial information of complex lesions, the high-dimensional feature space is easily affected by noise, the generalization ability is insufficient, the number of labeled samples is limited, the training cost is high, and the model has poor adaptability to new samples.

Method used

The multi-scale spatial weighted residual attention mechanism (SWRA) and the efficient scale attention module (ESAM) are adopted, combined with supervised contrastive learning, through multi-scale parallel convolution and channel attention, embedded in the ConvNeXt network, and a joint loss function is designed to optimize feature extraction and classification.

Benefits of technology

The model's ability to extract complex lesion features has been improved, its robustness in high-dimensional feature space has been enhanced, its dependence on labeled samples has been reduced, and the accuracy and generalization performance of pneumonia classification have been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120635596A_ABST
    Figure CN120635596A_ABST
Patent Text Reader

Abstract

The invention relates to a chest X-ray image pneumonia classification device, and the device comprises a data obtaining module which is used for obtaining chest X-ray images, carrying out the classification marking, and constructing an image data set; the data enhancement module is used for preprocessing the chest X-ray image, adapting to a model input format and performing data enhancement; the feature extraction module is used for designing a multi-scale space weighted residual attention mechanism, extracting multi-scale space features and embedding the multi-scale space features into a ConvNeXt network; the feature enhancement module is used for constructing a high-efficiency scale attention module and embedding a ConvNeXt network to enhance feature extraction; the average pooling module is used for generating feature representation through global average pooling and optimizing by adopting comparative learning; the loss optimization module is used for designing a joint loss function and performing optimization in combination with classification loss and comparison loss; and the model training module is used for training and optimizing a network model, evaluating classification performance and outputting a result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing and deep learning technology, and in particular to a device for classifying pneumonia in chest X-ray images. Background Art

[0002] Deep learning, a branch of machine learning, uses multi-layered neural networks to simulate the human brain's information processing mechanisms, automatically extracting features and learning patterns from complex data. Its core lies in building deep neural networks that represent and classify high-dimensional data through layer-by-layer feature extraction and abstraction. In recent years, deep learning models such as Convolutional Neural Networks (CNN), Residual Networks (ResNet), and Vision Transformers (ViT) have demonstrated significant advantages in image processing, particularly in chest X-ray image analysis, where they are widely used for pneumonia detection and classification.

[0003] Chest X-ray images have become an important tool for screening pneumonia. Traditional technologies rely on manual interpretation by radiologists, which is highly subjective and inefficient. To improve screening efficiency and accuracy, researchers have developed automated classification technologies based on deep learning, including CNN-based feature extraction and attention-based feature enhancement. These technologies automatically identify viral pneumonia, other lung infections, and normal conditions by extracting and classifying features from chest X-ray images. However, existing technologies face the following challenges: single-scale feature extraction is difficult to capture the spatial information of complex lesions, resulting in limited classification performance; in high-dimensional feature spaces, the model is susceptible to noise interference and lacks generalization ability; the number of labeled samples is limited, the training cost is high, and the model has poor adaptability to new samples.

[0004] Contrastive Learning, as an unsupervised or semi-supervised learning strategy, can effectively improve the generalization performance of the model by constructing positive and negative sample pairs and optimizing the sample representation in the feature space. In the field of image processing, supervised contrastive learning uses annotation information to enhance the feature similarity of samples of the same type and reduce the similarity of samples of different types, thereby improving classification accuracy. However, existing contrastive learning strategies are mostly based on global features, do not fully utilize multi-scale spatial information, and do not sufficiently enhance features in the channel dimension, resulting in limited performance of the model in complex pneumonia lesion problems. In addition, although attention mechanisms (such as channel attention and spatial attention) are widely used for feature enhancement, a single attention module is difficult to simultaneously take into account the interaction of multi-scale spatial features and channel features, which limits the model's ability to accurately locate and classify lesion areas. Summary of the Invention

[0005] This application provides a chest X-ray image pneumonia classification device, comprising: The data acquisition module is used to acquire chest X-ray images, classify and annotate them, and construct an image dataset; a data enhancement module, configured to preprocess the chest X-ray image, adapt the model input format, and perform data enhancement; Feature extraction module, used to design a multi-scale spatial weighted residual attention mechanism to extract multi-scale spatial features and embed them into the ConvNeXt network; Feature enhancement module, used to build an efficient scale-attention module and embed it into the ConvNeXt network to enhance feature extraction; Average pooling module, which generates feature representations through global average pooling and adopts contrastive learning optimization; Loss optimization module, used to design a joint loss function that combines classification loss and contrast loss for optimization; Model training module, used to train and optimize network models, evaluate classification performance and output results; The feature extraction module is specifically used to: The original features of the input chest X-ray image , through global average pooling and global maximum pooling, generate spatial descriptors and , reflecting the overall intensity and salient features of the image respectively; Will F avg and F max Splice along the channel axis to generate splicing features , through convolution operations with kernel sizes of 3×3, 5×5, and 7×7, a multi-scale attention map is generated 、 、 And perform nonlinear transformation on each attention map through Sigmoid activation function; Define the learnable weight vector , normalized by the Softmax function, satisfying , calculate the fusion attention map , the formula is: in, 、 、 For learnable weights, they are optimized through gradient updates during training; The fused attention map A fused With the original features XPerform element-by-element multiplication to generate weighted features and connected with the original features through residual connection Add to generate spatial enhancement features , the formula is: Enhance the spatial features Y It is connected after stage 1, stage 2, and stage 3 of the ConvNeXt network to improve the model's ability to extract multi-scale lesion features.

[0006] Furthermore, the data acquisition module is specifically used to: Obtain chest X-ray images including viral pneumonia, lung opacities, and normal states; Identify each image and assign a classification label, including viral pneumonia, lung opacity, and normal state; Organize images and corresponding labels into a dataset, split it into training and validation sets, and store them in a specified directory for model loading.

[0007] Furthermore, the data enhancement module is specifically used to: Resize chest X-ray images to the model input resolution, preserving the image aspect ratio; Normalize the image pixel values ​​using a predefined mean and standard deviation; Data augmentation operations are applied to the training set, including random affine transformation, color jittering, and Gaussian blur, while only pixel value normalization is performed on the validation set.

[0008] Furthermore, the feature enhancement module is specifically used to: For input features Perform channel attention operation and generate channel descriptors through global average pooling , generate channel weight vectors through two layers of fully connected layers and Sigmoid activation function ; The channel weight vector W c With input features Y Perform channel-by-channel multiplication to generate channel-weighted features ; Channel-weighted features Y c Perform spatial attention operation and generate spatial attention map through 3×3 convolution and Sigmoid activation function ,and Y c Perform element-by-element multiplication to generate spatial enhancement features ; Enhance the spatial features Y s It is connected to the second two-dimensional convolution kernel of the ConvNeXt Block in stage 3 and stage 4 of the ConvNeXt network to form an enhanced ConvNeXt Block.

[0009] Furthermore, the average pooling module is specifically used to: Perform global average pooling on the stage 4 output feature map of the ConvNeXt network to generate a global feature representation. The formula is: Where B is the batch size and D is the feature dimension; Through the projection head module, a multi-layer perceptron is used to F pooled Mapping to 128-dimensional contrast space to generate projection features ; right F proj Perform L2 normalization to generate normalized features , calculate the cosine similarity matrix S , the formula is: in, It is the temperature parameter, the default value is 0.07, which is used to adjust the smoothness of the similarity distribution; Generate positive sample masks based on labels M ,in M ij =1 indicates sample i and j Tags y i = y j ,otherwise M ij =0; Using the supervised contrast loss function, the formula is: in, S ij Represents a sample i and j The cosine similarity of M ij represents the positive sample mask, is the temperature parameter.

[0010] Furthermore, the loss optimization module is specifically used to: Calculate cross entropy classification loss , classification probability and true label based on model output; Calculating contrastive loss , using a supervised contrastive loss function; Design the joint loss function, the formula is: in, Represents a dynamic weighting coefficient, which gradually increases the weight of the contrast loss as the number of training rounds increases.

[0011] Furthermore, the model training module is specifically used to: The network model was iteratively trained using the training set, using the AdamW optimizer, with a learning rate of 0.0001, a weight decay of 0.01, and a batch size of 64. A cosine annealing learning rate scheduler was used for learning rate decay, and gradient clipping was used to prevent gradient explosion. The maximum gradient norm was limited to 1.0. Apply channel attention weights to the input feature map to generate a weighted feature map; Calculate classification accuracy, recall, precision, F1 score, and Kappa coefficient on the validation set to evaluate model performance; Select the best model parameters based on the validation set performance and save the model weights and performance metrics to the specified file.

[0012] The above technical solution of this application has the following advantages: 1. To address the difficulty of capturing complex spatial information of pneumonia lesions using single-scale feature extraction, we propose a multi-scale spatial weighted residual attention (SWRA) mechanism. This mechanism, embedded in a ConvNeXt network through multi-scale parallel convolution operations and residual connections, extracts diverse lesion features, improving the classification accuracy of viral pneumonia, lung opacity, and normal conditions. Ablation experiments and multiple comparative tests demonstrate that the proposed multi-scale spatial weighted residual attention (SWRA) enhances the model's ability to extract features from complex lesion patterns.

[0013] 2. To address the problem of insufficient generalization due to high-dimensional feature spaces being susceptible to noise, we propose the Efficient Scale Attention Module (ESAM). This module combines channel attention and multi-scale spatial attention to enhance the robustness of feature extraction. This module is embedded in a ConvNeXt network to form an enhanced feature representation. Ablation experiments and multiple comparative tests demonstrate that the ESAM improves the model's generalization performance in complex image environments.

[0014] 3. To address the problem of blurred classification boundaries caused by the similar appearance of multiple pneumonia lesions in pneumonia X-ray image recognition, an optimization scheme based on supervised contrastive learning is proposed. This approach generates feature representations through global average pooling, and combines the cosine similarity matrix and a joint loss function to optimize feature discrimination, reducing reliance on labeled samples and achieving efficient classification performance. Ablation experiments and multiple comparative tests demonstrate that this optimization scheme based on supervised contrastive learning improves the model's performance for pneumonia X-ray image classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the specific implementation methods or the description of the prior art. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0016] Figure 1 A structural diagram of the device for classifying pneumonia in chest X-ray images provided in this application; Figure 2 The architecture diagram of the multi-scale spatially weighted residual attention mechanism (SWRA) provided for this application; Figure 3 Architecture diagram of the Efficient Scale Attention Module (ESAM) provided for this application. DETAILED DESCRIPTION

[0017] In the following description, specific details such as specific system structures and technologies are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, and circuits are omitted to avoid obscuring the description of the present application with unnecessary detail.

[0018] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.

[0019] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0020] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of the present application include a particular feature, structure, or characteristic described in conjunction with that embodiment. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized. "Multiple" means "two or more."

[0021] In response to the problems in the background technology, this application proposes a pneumonia classification device for chest X-ray images based on a multi-scale spatial attention mechanism and contrastive learning. By designing a multi-scale spatial weighted residual attention mechanism (SWRA) and an efficient scale attention module (ESAM), combined with supervised contrastive learning, the feature extraction and classification process are optimized. This can effectively improve the performance of the model in the classification tasks of viral pneumonia, lung opacity and normal state, while reducing dependence on a large number of labeled samples and adapting to the dynamic changes of complex lesion characteristics.

[0022] The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0023] like Figure 1 As shown, the embodiment of the present application provides a chest X-ray image pneumonia classification device, comprising: The data acquisition module is used to acquire chest X-ray images, classify and annotate them, and construct an image dataset; a data enhancement module, configured to preprocess the chest X-ray image, adapt the model input format, and perform data enhancement; Feature extraction module, used to design a multi-scale spatial weighted residual attention mechanism (SWRA), extract multi-scale spatial features and embed them into the ConvNeXt network; Feature enhancement module, used to build the Efficient Scale Attention Module (ESAM), embedded in the ConvNeXt network to enhance feature extraction; Average pooling module, which generates feature representations through global average pooling and adopts contrastive learning optimization; Loss optimization module, used to design a joint loss function that combines classification loss and contrast loss for optimization; Model training module, used to train and optimize network models, evaluate classification performance and output results; The feature extraction module is specifically used to: The original features of the input chest X-ray image , through global average pooling and global maximum pooling, generate spatial descriptors and , reflecting the overall intensity and salient features of the image respectively; Will F avg and F max Splice along the channel axis to generate splicing features , through convolution operations with kernel sizes of 3×3, 5×5, and 7×7, a multi-scale attention map is generated 、 、 And perform nonlinear transformation on each attention map through Sigmoid activation function; Define the learnable weight vector , normalized by the Softmax function, satisfying , calculate the fusion attention map , the formula is: in, 、 、 For learnable weights, they are optimized through gradient updates during training; The fused attention map A fused With the original features X Perform element-by-element multiplication to generate weighted features and connected with the original features through residual connection Add to generate spatial enhancement features , the formula is: Enhance the spatial features Y It is connected after stage 1, stage 2, and stage 3 of the ConvNeXt network to improve the model's ability to extract multi-scale lesion features.

[0024] In some embodiments, the data acquisition module is specifically configured to: Chest X-ray images containing viral pneumonia, lung opacity, and normal conditions were obtained from a public database; Each image is identified and assigned a classification label based on radiology reports or expert annotations, including viral pneumonia, lung opacity, and normal status; The images and corresponding labels are organized into a dataset through index files, divided into a training set (80%) and a validation set (20%), and stored in a specified directory for model loading.

[0025] In some embodiments, the data enhancement module is specifically configured to: Resize chest X-ray images to the model input resolution (299×299 pixels), maintaining the image aspect ratio; Normalize the image pixel values ​​to the range of [-1, 1] using the predefined mean (0.5, 0.5, 0.5) and standard deviation (0.5, 0.5, 0.5); Apply data augmentation operations to the training set, including: Random affine transformation, set the rotation angle to ±5 degrees, the translation ratio to ±0.02, and the scaling ratio to 0.97-1.03; Color dithering, set brightness and contrast adjustment range 0.9-1.1; Gaussian blur, set the convolution kernel size to 3, and the standard deviation to 0.1-0.2; The validation set only undergoes pixel value normalization.

[0026] In some embodiments, the feature enhancement module is specifically configured to: For input features Perform channel attention operation and generate channel descriptors through global average pooling , generate channel weight vectors through two layers of fully connected layers and Sigmoid activation function ; The channel weight vector W c With input features Y Perform channel-by-channel multiplication to generate channel-weighted features ; Channel-weighted features Y c Perform spatial attention operation and generate spatial attention map through 3×3 convolution and Sigmoid activation function ,and Y c Perform element-by-element multiplication to generate spatial enhancement features ; Enhance the spatial features Y s It is connected to the second two-dimensional convolution kernel of the ConvNeXt Block in stage 3 and stage 4 of the ConvNeXt network to form an enhanced ConvNeXt Block.

[0027] In some embodiments, the average pooling module is specifically configured to: Perform global average pooling on the stage 4 output feature map of the ConvNeXt network to generate a global feature representation. The formula is: Where B is the batch size and D is the feature dimension; Through the projection head module, a multi-layer perceptron is used to F pooled Mapping to 128-dimensional contrast space to generate projection features ; right F proj Perform L2 normalization to generate normalized features , calculate the cosine similarity matrix S , the formula is: in, It is the temperature parameter, the default value is 0.07, which is used to adjust the smoothness of the similarity distribution; Generate positive sample masks based on labels M ,in M ij =1 indicates sample i and j Tags y i = y j ,otherwise M ij =0; Using the supervised contrast loss function, the formula is: in, S ij Represents a sample i and j The cosine similarity of M ij represents the positive sample mask, is the temperature parameter.

[0028] In some embodiments, the loss optimization module is specifically configured to: Calculate cross entropy classification loss , classification probability and true label based on model output; Calculating contrastive loss , using the supervised contrast loss function in step S5; Design the joint loss function, the formula is: in, Represents a dynamic weighting coefficient, which gradually increases the weight of the contrast loss as the number of training rounds increases.

[0029] In some embodiments, the model training module is specifically used to: The network model was iteratively trained using the training set, using the AdamW optimizer, with a learning rate of 0.0001, a weight decay of 0.01, and a batch size of 64. A cosine annealing learning rate scheduler was used for learning rate decay, and gradient clipping was used to prevent gradient explosion. The maximum gradient norm was limited to 1.0. Apply channel attention weights to the input feature map to generate a weighted feature map; Calculate classification accuracy, recall, precision, F1 score, and Kappa coefficient on the validation set to evaluate model performance; Select the best model parameters based on the validation set performance and save the model weights and performance metrics to the specified file.

[0030] Current deep learning approaches to pneumonia image classification face challenges with subtle lesion features and fuzzy class boundaries. Existing attention mechanisms often use single-dimensional convolutional kernels, making it difficult to effectively capture the characteristics of lesions of varying sizes. Contrastive learning is often used as data preprocessing and is not fully integrated into model training, limiting the ability to distinguish between classes.

[0031] This application uses the scale-weighted residual attention (SWRA) mechanism, combined with multi-scale convolution kernels, to dynamically extract complex lesion features and improve detection accuracy. SWRA and efficient channel attention (ECA) form the efficient scale attention module (ESAM), which is embedded in the deep structure of ConvNeXt to enhance feature extraction capabilities. At the same time, this application innovatively integrates the contrast loss and classification loss to improve inter-class discrimination and intra-class consistency, effectively addressing the problem of blurred class boundaries. Experiments show that the pneumonia classification device for chest X-ray images proposed in this application achieves an accuracy of 96.10% and an F1 score of 96.60%, which is superior to mainstream neural network models. This application provides important value for efficient and accurate automatic pneumonia identification and is suitable for the intelligent needs of complex clinical scenarios.

[0032] The chest X-ray image pneumonia classification device provided in the embodiment of the present application is designed by designing a multi-scale spatial weighted residual attention mechanism (SWRA, such as Figure 2 ) and the Efficient Scale Attention Module (ESAM, as Figure 3 As shown in Figure 3), combined with supervised contrastive learning, a deep learning model was constructed to achieve classification detection and analysis of viral pneumonia, lung opacity, and normal status in chest X-ray images.

[0033] The following describes the invention through specific embodiments.

[0034] Example To verify the performance superiority of the chest X-ray image pneumonia classification device based on multi-scale spatial attention mechanism and contrastive learning proposed in this application, the effectiveness of model optimization was verified in the classification tasks of viral pneumonia, lung opacity and normal state, and the classification strategy based on supervised contrastive learning can improve the generalization ability of the model for complex lesion features. The specific steps are as follows: (1) Dataset: This application uses the dataset shown in Table 1 as the basic data source for experimental verification. The dataset contains 6,012 samples of opaque lung lesions, 10,192 samples of normal lung conditions, and 1,345 samples of viral pneumonia, totaling 17,549 high-quality image data, as shown in Table 1.

[0035] Table 1 Dataset distribution (2) Comparison system The pneumonia classification model for chest X-ray images using the multi-scale spatial attention mechanism and contrastive learning proposed in this application is adopted. The experimental dataset shown in Table 1 is used, 80% of which is used as a training set and 20% as a test set. Comparative experiments are conducted with five common deep learning models: ResNet34, ResNeXt101, DenseNet121, SqueezeNet, and ConvNeXt. Since these five models have a high influence in the classification field, they are used to verify the effectiveness of this application.

[0036] ResNet34: It uses a 34-layer residual network architecture, consisting of a 7×7 convolutional layer, four residual block groups (containing 3, 4, 6, and 3 residual units respectively), and a fully connected classification layer. It solves the gradient vanishing problem in deep networks through skip connections.

[0037] ResNeXt101: It uses a 101-layer grouped convolutional network architecture, consisting of a 7×7 convolutional layer, four residual block groups (containing 3, 4, 23, and 3 grouped convolutional units respectively) and a fully connected classification layer. Each grouped convolutional unit uses 32 parallel branches.

[0038] DenseNet121: It uses a 121-layer densely connected network architecture, consisting of a 7×7 convolutional layer, four dense blocks (containing 6, 12, 24, and 16 dense layers respectively), three transition layers, and a fully connected classification layer, achieving feature reuse through dense connections.

[0039] SqueezeNet: It uses a lightweight network architecture consisting of a 7×7 convolutional layer, eight Fire modules (each module contains a squeeze layer and an expand layer), and a fully connected classification layer, and reduces the number of parameters through 1×1 convolution.

[0040] ConvNeXt: It adopts a modern convolutional network architecture, consisting of four stages (containing 3, 3, 9, and 3 ConvNeXt blocks respectively) and a fully connected classification layer. Each ConvNeXt block contains depth convolution, LayerNorm, point convolution, and GELU activation function.

[0041] (3) Experimental results and analysis: During the experiment, each model was tested ten times, and the one with the best performance was taken as the experimental result. The specific results of each model are shown in Table 2.

[0042] Table 2 Comparison of model performance on the dataset Experimental results show that the PneumoNeXt model in this application achieves optimal performance across key performance indicators such as accuracy, recall, F1-Score, precision, and Kappa coefficient. Specifically, compared to the ConvNeXt baseline model, the accuracy increased by 2.22% and the Kappa coefficient increased by 3.45%, fully verifying the effectiveness and advancement of this application's technical solution.

[0043] The pneumonia classification device for chest X-ray images based on multi-scale spatial attention mechanism and contrastive learning proposed in this application designs a multi-scale spatial weighted residual attention mechanism (SWRA) and an efficient scale attention module (ESAM), combines the ConvNeXt network and supervised contrastive learning, and uses multi-scale parallel convolution and channel attention to extract complex lesion features. At the same time, it optimizes feature discrimination by combining classification loss and contrast loss. It not only significantly improves the classification accuracy of viral pneumonia, lung opacity and normal state, but also effectively reduces the dependence on a large number of labeled samples, and adapts to the diversity and dynamic changes of pneumonia lesions.

[0044] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other and are not used to limit the scope of protection of this application.

[0045] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A chest X-ray image pneumonia classification device, characterized in that: include: The data acquisition module is used to acquire chest X-ray images, classify and annotate them, and construct an image dataset; a data enhancement module, configured to preprocess the chest X-ray image, adapt the model input format, and perform data enhancement; Feature extraction module, used to design a multi-scale spatial weighted residual attention mechanism to extract multi-scale spatial features and embed them into the ConvNeXt network; Feature enhancement module, used to build an efficient scale-attention module and embed it into the ConvNeXt network to enhance feature extraction; Average pooling module, which generates feature representations through global average pooling and adopts contrastive learning optimization; Loss optimization module, used to design a joint loss function that combines classification loss and contrast loss for optimization; Model training module, used to train and optimize network models, evaluate classification performance and output results; The feature extraction module is specifically used to: The original features of the input chest X-ray image , through global average pooling and global maximum pooling, generate spatial descriptors and , reflecting the overall intensity and salient features of the image respectively; Will F avg and F max Splice along the channel axis to generate splicing features , through convolution operations with kernel sizes of 3×3, 5×5, and 7×7, a multi-scale attention map is generated 、 、 And perform nonlinear transformation on each attention map through Sigmoid activation function; Define the learnable weight vector , normalized by the Softmax function, satisfying , calculate the fusion attention map , the formula is: in, 、 、 For learnable weights, they are optimized through gradient updates during training; The fused attention map A fused With the original features X Perform element-by-element multiplication to generate weighted features and connected with the original features through residual connection Add to generate spatial enhancement features , the formula is: Enhance the spatial features Y It is connected after stage 1, stage 2, and stage 3 of the ConvNeXt network to improve the model's ability to extract multi-scale lesion features.

2. The chest X-ray image pneumonia classification device according to claim 1, characterized in that: The data acquisition module is specifically used to: Obtain chest X-ray images including viral pneumonia, lung opacities, and normal states; Identify each image and assign a classification label, including viral pneumonia, lung opacity, and normal state; Organize images and corresponding labels into a dataset, split it into training and validation sets, and store them in a specified directory for model loading.

3. The chest X-ray image pneumonia classification device according to claim 1, characterized in that: The data enhancement module is specifically used to: Resize chest X-ray images to the model input resolution, preserving the image aspect ratio; Normalize the image pixel values ​​using a predefined mean and standard deviation; Data augmentation operations are applied to the training set, including random affine transformation, color jittering, and Gaussian blur, while only pixel value normalization is performed on the validation set.

4. The chest X-ray image pneumonia classification device according to claim 1, characterized in that: The feature enhancement module is specifically used to: For input features Perform channel attention operation and generate channel descriptors through global average pooling , generate channel weight vectors through two layers of fully connected layers and Sigmoid activation function ; The channel weight vector W c With input features Y Perform channel-by-channel multiplication to generate channel-weighted features ; Channel-weighted features Y c Perform spatial attention operation and generate spatial attention map through 3×3 convolution and Sigmoid activation function ,and Y c Perform element-by-element multiplication to generate spatial enhancement features ; Enhance the spatial features Y s It is connected to the second two-dimensional convolution kernel of the ConvNeXt Block in stage 3 and stage 4 of the ConvNeXt network to form an enhanced ConvNeXt Block.

5. The chest X-ray image pneumonia classification device according to claim 1, characterized in that: The average pooling module is specifically used to: Perform global average pooling on the stage 4 output feature map of the ConvNeXt network to generate a global feature representation. The formula is: Where B is the batch size and D is the feature dimension; Through the projection head module, a multi-layer perceptron is used to F pooled Mapping to 128-dimensional contrast space to generate projection features ; right F proj Perform L2 normalization to generate normalized features , calculate the cosine similarity matrix S , the formula is: in, It is the temperature parameter, the default value is 0.07, which is used to adjust the smoothness of the similarity distribution; Generate positive sample masks based on labels M ,in M ij =1 indicates sample i and j Tags y i = y j ,otherwise M ij =0; Using the supervised contrast loss function, the formula is: in, S ij Represents a sample i and j The cosine similarity of M ij represents the positive sample mask, is the temperature parameter.

6. The chest X-ray image pneumonia classification device according to claim 1, characterized in that: The loss optimization module is specifically used to: Calculate cross entropy classification loss , classification probability and true label based on model output; Calculating contrastive loss , using a supervised contrastive loss function; Design the joint loss function, the formula is: in, Represents a dynamic weighting coefficient, which gradually increases the weight of the contrast loss as the number of training rounds increases.

7. The chest X-ray image pneumonia classification device according to claim 1, characterized in that: The model training module is specifically used to: The network model was iteratively trained using the training set, using the AdamW optimizer, with a learning rate of 0.0001, a weight decay of 0.01, and a batch size of 64. A cosine annealing learning rate scheduler was used for learning rate decay, and gradient clipping was used to prevent gradient explosion. The maximum gradient norm was limited to 1.

0. Apply channel attention weights to the input feature map to generate a weighted feature map; Calculate classification accuracy, recall, precision, F1 score, and Kappa coefficient on the validation set to evaluate model performance; Select the best model parameters based on the validation set performance and save the model weights and performance metrics to the specified file.

Citation Information

Patent Citations

  • Microscopic hyperspectral image segmentation method based on multi-scale attention fusion

    CN119810116A

  • Multi-scale fused dehazing method based on stacked hourglass network

    WO2024040973A1

  • Feedback generative adversarial network having channel-spatial attention mechanism for agent path finding

    WO2024168938A1

Cited By

  • Image classification method and device based on multi-scale feature fusion, equipment and medium

    CN121746783A