Pneumonia classification lightweight method based on few-sample enhancement

By using deep convolution generation adversarial networks in the pneumonia classification model to enhance the small sample data, combining attention mechanisms and residual neural networks, and using a lightweight model pruning strategy based on geometric medians, the problems of category imbalance and high computational complexity are solved, high-quality medical image sample generation and model lightweighting are achieved, and the applicability and performance of the model are improved.

CN119888344APending Publication Date: 2025-04-25NANJING MEDICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411966874.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The existing pneumonia classification model has category imbalance problem when processing medical images, which leads to the model tending to identify categories with a large number of samples, increasing the misclassification rate of a few categories. At the same time, the model parameter quantity and calculation complexity are too high, limiting its application in resource-constrained environments.

Method used

A small sample data enhancement strategy based on deep convolution generation adversarial network is adopted, and high-quality medical image samples are generated by introducing spectrum normalization technology and hinge adversarial loss function. Combining the attention mechanism and residual neural network, the problem of gradient disappearance in the deep network is alleviated and the model's attention to key areas is enhanced. Use a lightweight model pruning strategy based on geometric medians to remove redundant filters to reduce the number of parameters and calculation complexity of the model.

Benefits of technology

It significantly improves the quality of the generator's chest X-ray samples, balances the proportion of positive and negative samples in the data set, improves the accuracy and robustness of pneumonia classification, and while ensuring the performance of the model, it significantly reduces storage and computing costs, and improves the applicability of the model in resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888344A_ABST
    Figure CN119888344A_ABST
Patent Text Reader

Abstract

The invention discloses a pneumonia classification lightweight method based on few-sample enhancement. The pneumonia classification lightweight method comprises the following steps: S1, preprocessing a lung chest radiograph image; s2, constructing a deep convolutional generative adversarial network, and performing data enhancement on a few classes of samples to balance the proportion of positive and negative samples; s3, constructing a residual neural network, taking the data set after class balance in the step S2 as network input, and performing training; and S4, pruning the network in the step S3 by adopting a geometric median-based method, removing a redundant filter, and recovering the precision through de novo training. According to the method, the performance of the pneumonia classification model can be basically maintained, meanwhile, the storage occupation and the calculation complexity are remarkably reduced, and the method is particularly suitable for being applied to a resource-constrained environment and has high practical application value and popularization potential.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the fields of computer vision and biomedicine, and specifically relates to a lightweight method for pneumonia classification based on few-sample enhancement. Background Art

[0002] In recent years, pneumonia has become a public health issue of great concern worldwide. However, the traditional manual reading method may have certain instability in the diagnosis results due to factors such as expert fatigue and emotional fluctuations, which poses a challenge to the timely diagnosis and treatment of the disease. At present, as an advanced technical tool, deep neural networks have shown important application potential in medical image classification tasks with their excellent performance in the field of visual recognition. Pneumonia classification, as a classic medical image classification problem, occupies an important position in medical diagnosis. However, most current methods fail to fully consider the common class imbalance problem in medical data, resulting in the model tending to identify classes with a large number of samples, thereby increasing the misclassification rate of minority classes. In addition, with the continuous deepening and complexity of the structure of pneumonia classification models, the number of parameters and the amount of calculation have increased significantly, which seriously limits the application and promotion of this technology in resource-constrained environments.

[0003] In order to solve the problem of class imbalance, a common technical means is to improve the balance of the dataset through data augmentation. However, although traditional image data augmentation methods (such as random rotation, flipping and cropping) can expand the number of samples, the generated samples are often too similar to the original samples, which limits the improvement of the diversity of the dataset. In the context of complex texture features of medical images, the samples generated by these traditional enhancement methods may not meet actual clinical needs. In recent years, data augmentation technology based on generative adversarial networks (GANs) has received widespread attention. Unlike traditional methods, GANs can automatically learn the distribution characteristics of data without manual labeling. However, GANs are prone to mode collapse problems in practical applications, which affects the quality and diversity of generated samples. Therefore, there is an urgent need for a method to stabilize network training to ensure that the generator can generate high-quality medical image samples, balance the distribution of minority samples, and combine residual neural networks to achieve pneumonia classification tasks.

[0004] In addition, in order to deal with the problem of high parameter quantity and computational complexity in pneumonia classification models, lightweight strategies have become an effective solution. For example, model pruning optimizes the model structure by removing redundant filters, thereby reducing computing and storage resource consumption. However, traditional norm-based pruning methods are easily limited by problems such as small norm deviation and large minimum norm in practical applications, and the performance of the pruned model is difficult to meet expectations. Therefore, it is necessary to propose a more accurate filter importance evaluation method to achieve effective compression of the pneumonia classification model, while ensuring the accuracy of the model, significantly reducing storage and computing costs, thereby improving the applicability of the model in practical scenarios. Summary of the invention

[0005] The purpose of the present invention is to solve the common category imbalance problem in pneumonia classification tasks, and propose a lightweight pneumonia classification method based on few-sample enhancement. The method is a few-sample data enhancement strategy based on a deep convolutional generative adversarial network. The strategy effectively stabilizes the training process of the generative adversarial network by introducing spectral normalization technology and adopting a hinge adversarial loss function, thereby significantly improving the quality of chest X-ray samples generated by the generator; at the same time, on the basis of balancing the ratio of positive and negative samples in the data set, a pneumonia classification strategy combining an attention mechanism and a residual neural network is proposed, which can not only alleviate the gradient vanishing problem in the deep network, but also enhance the model's attention to key areas in the chest X-ray, thereby improving the accuracy and robustness of the classification; in addition, in view of the practical problems that the pneumonia classification model has high computational complexity, large number of parameters and is difficult to deploy on resource-constrained devices, a lightweight model pruning strategy based on the geometric median is adopted. By calculating and removing redundant filters, the number of parameters and computational complexity of the model are significantly reduced, while retaining the model performance, its applicability and operating efficiency in resource-constrained environments are improved.

[0006] To achieve the above object, the technical solution adopted by the present invention is: a lightweight method for pneumonia classification based on few-sample enhancement, which comprises the following steps:

[0007] S1. Preprocessing lung chest X-ray images;

[0008] S2. Build a deep convolutional generative adversarial network to perform data enhancement on minority samples to balance the ratio of positive and negative samples;

[0009] S3, construct a residual neural network, use the data set after category balancing in step S2 as network input and train it;

[0010] S4. Prune the network in step S3 using a method based on geometric median to remove redundant filters and restore accuracy by training from scratch.

[0011] Furthermore, the preprocessing steps in step S1 are:

[0012] S1-1. All images in the original Chest X-ray 2017 lung chest radiograph dataset were centrally cropped according to the window size of the short side length, and then all images were adjusted to a size of 64×64 using the bilinear interpolation method. Finally, the input data was standardized according to the mean and standard deviation of 0.5.

[0013] S1-2. The training set was re-divided according to the ratio of 9:1, where the number of normal chest X-rays and pneumonia chest X-rays in the training set was 1215 and 3495 respectively; the number of normal chest X-rays and pneumonia chest X-rays in the validation set was 134 and 388 respectively; the number of normal chest X-rays and pneumonia chest X-rays in the test set was 234 and 390 respectively. The number of normal chest X-rays was 1583, the number of pneumonia chest X-rays was 4273, and the total number of samples was 5886.

[0014] Furthermore, the specific steps of step S2 are:

[0015] S2-1. Build the deep convolutional generative adversarial network DCGAN infrastructure, which includes the generator and the discriminator. The generator is responsible for generating fake samples similar to real samples, while the discriminator is used to evaluate the authenticity of the samples.

[0016] S2-2. Apply spectral normalization in the generator and discriminator of DCGAN.

[0017] S2-3. Introduce hinge adversarial loss into the network training process, where the generator L G With the discriminator L D The losses are:

[0018]

[0019] Where P x With P z represent the real data distribution and the noise distribution respectively, and represents the expectation of the distribution of real samples x and noise z, D(x) and D(G(z)) represent the output of the discriminator for x and G(z), respectively;

[0020] S2-4, sending all the images in the training set processed by steps S1-1 and S1-2 into the network in batches for iterative training;

[0021] S2-5. After obtaining the model of step S2-4, the quality of image generation is evaluated using the FID and KID indicators, and the optimal generator is selected;

[0022] S2-6. Use the generator in step S2-5 to generate 2280 lung chest X-ray images to obtain a training set with balanced categories.

[0023] Furthermore, the step S2-2 is specifically as follows: adding a spectrum normalization layer after the convolution layer of the generator and the transposed convolution layer of the discriminator, and the formula is as follows:

[0024]

[0025] Where σ(W) represents the spectral norm of the weight parameter W, h is the non-zero input vector, representing the characteristics of the data sample, and ‖·‖2 represents the l2 norm, which is the square root of the sum of the squares of the vector elements;

[0026] Then we can get the weight parameters after spectrum normalization:

[0027]

[0028] Furthermore, the specific process of step S3 is as follows:

[0029] S3-1, construct a basic residual block and use it to construct a residual neural network;

[0030] S3-2, based on step S3-1, integrating the spatial attention mechanism into the residual neural network;

[0031] S3-3. The feature F obtained by the first convolutional layer first And the feature F obtained after the last convolution layer last After fusion, the fused feature F fused It is expressed as follows:

[0032] F fused =0.5×(F first +F last )

[0033] S3-4. Use cross entropy loss to measure the difference between the probability distribution of model prediction and the probability distribution of the true label;

[0034] S3-5, sending the class-balanced training set images in step S2-6 to the network in batches for iterative training;

[0035] S3-6. After obtaining the model of step S3-5, use accuracy, recall, precision and F1 score evaluation to obtain the model with the best effect on the validation set.

[0036] Furthermore, in step S3-2, the spatial attention mechanism is expressed as:

[0037] M s (F) = σ(f 7×7 (concat[AvgPool(F);MaxPool(F)]))

[0038] In the formula, F represents the input feature. The feature vectors AvgPool(F) and MaxPool(F) obtained by average pooling and maximum pooling are concatenated, and then a convolution layer with a convolution kernel size of 7×7 is used for calculation. Finally, σ (which represents the Sigmoid activation function) is used to obtain the output spatial attention map M. s (F);

[0039] Next, the spatial attention map M s (F) is multiplied element-wise with the original input feature to obtain the feature map F for spatial attention enhancement ′ , which is expressed as follows:

[0040]

[0041] Furthermore, in step S3-4, the formula of the cross entropy loss function is:

[0042] L(y,a)=-[ylog(a)+(1-y)log(1-a)]

[0043] Among them, y is the true label and a is the probability of the model predicting the positive class.

[0044] Furthermore, the specific process of step S4 is as follows:

[0045] S4-1, loading the model in step S3-6, and setting the global pruning ratio r;

[0046] S4-2, according to the global pruning ratio r set in step S4-1, traverse the convolutional layers of the model layer by layer and obtain the filters, and then calculate their geometric centers

[0047] Then, according to the geometric center Calculate the distance D between each layer filter and it n ,

[0048]

[0049] Next, for D n After sorting, we get D ′ n , and calculate the pruning threshold T,

[0050] Finally, the filters that are less than or equal to T are set to 0 and regarded as redundant filters;

[0051] S4-3, traverse the convolutional layers in the model, remove the zero-value filters, and ensure that the remaining filter weights remain unchanged;

[0052] S4-4, using the class-balanced training set in step S2-6 to iteratively optimize the pruned model to recover the accuracy loss caused by pruning;

[0053] S4-5. Evaluate the retrained pruned model through the validation data set, and use the three indicators of accuracy, number of parameters, and amount of computation to obtain the best model.

[0054] Furthermore, in step S4-2, the geometric center It is expressed as follows:

[0055]

[0056] Where F is an arbitrary K×K filter, F n is the filter in the network, n∈[1,N], and N is the total number of filters in the convolutional layer.

[0057] Furthermore, in step S4-2, the distance D n , which is expressed as follows:

[0058]

[0059] The pruning threshold T is expressed as follows:

[0060] T=D ′ n [int(r·N)].

[0061] Compared with the prior art, the present invention has the following beneficial effects:

[0062] (1) Compared with traditional image enhancement technology, the present invention can automatically learn data distribution characteristics without manual annotation. By introducing spectral normalization and hinge adversarial loss, the network training process is effectively stabilized and the mode collapse problem is effectively alleviated. The generator can generate higher quality lung chest radiographs, thereby solving the problem of class imbalance and improving the generalization ability of the model.

[0063] (2) The present invention alleviates the gradient vanishing problem in deep neural network training, enhances the network's ability to focus on the lesion area, and at the same time expands the global field of view of the model, effectively weakening the influence of irrelevant areas in the background, and improving the accuracy and robustness of pneumonia classification.

[0064] (3) Aiming at the deployment requirements of resource-constrained devices, the present invention designs a lightweight model pruning method based on geometric median. By setting a global threshold, redundant filters are identified and removed at one time, which significantly reduces the number of model parameters and computational complexity. While ensuring the classification performance of the model, its applicability in resource-constrained environments is improved. The present invention can help medical practitioners to efficiently carry out pneumonia diagnosis at a lower hardware cost, and has a high clinical promotion value. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 is a flow chart of the overall method in an embodiment of the present invention;

[0066] Figure 2 This is a diagram of the architecture of a deep convolutional generative adversarial network in an embodiment of the present invention;

[0067] Figure 3 A training curve diagram of a deep convolution adversarial network generated in an embodiment of the present invention;

[0068] Figure 4 This is a flow chart of pneumonia classification using a residual neural network in an embodiment of the present invention;

[0069] Figure 5 This is a structural diagram of the spatial attention mechanism in an embodiment of the present invention;

[0070] Figure 6 A schematic diagram of pruning the lightweight part of the model in an embodiment of the present invention;

[0071] Figure 7 A comparison diagram of a chest X-ray image generated in an embodiment of the present invention and an original image;

[0072] Figure 8 This is a classification confusion matrix result diagram in an embodiment of the present invention. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and implementation plans.

[0074] like Figure 1 As shown, this embodiment provides a pneumonia classification model based on few-sample enhancement and a lightweight method thereof, and the steps are as follows:

[0075] (1) Configure the PyTorch deep learning environment and obtain a lung chest X-ray dataset. The dataset comes from the officially published Chest X-ray 2017 chest X-rays, which are selected from pediatric patients aged 1 to 5 years old at the Guangzhou Women and Children's Medical Center. All X-rays were screened to remove low-quality or unreadable images, and then two expert doctors graded the diagnoses of these images. The lung chest X-ray images were then preprocessed, mainly including the following steps:

[0076] (1.1) All images in the original Chest X-ray 2017 lung chest radiograph dataset are centrally cropped according to the window size of the short side length, and then all images are adjusted to a size of 64×64 using the bilinear interpolation method. Finally, the input data is standardized according to the mean and standard deviation of 0.5;

[0077] (1.2) The training set was re-divided according to the ratio of 9:1, where the number of normal chest X-rays and pneumonia chest X-rays in the training set was 1215 and 3495 respectively; the number of normal chest X-rays and pneumonia chest X-rays in the validation set was 134 and 388 respectively; the number of normal chest X-rays and pneumonia chest X-rays in the test set was 234 and 390 respectively. The number of normal chest X-rays was 1583, the number of pneumonia chest X-rays was 4273, and the total number of samples was 5886.

[0078] (2) Construct a deep convolutional generative adversarial network to perform data enhancement on minority samples to balance the ratio of positive and negative samples. The basic architecture is as follows: Figure 2 This part mainly includes the following steps:

[0079] (2.1) Construct the deep convolutional generative adversarial network DCGAN infrastructure, which includes two main components: the generator and the discriminator. The generator is responsible for generating fake samples similar to real samples, while the discriminator is used to evaluate the authenticity of the samples;

[0080] (2.2) The spectral normalization technique is applied in the generator and discriminator of DCGAN. Specifically, a spectral normalization layer is added after the convolution layer of the generator and the transposed convolution layer of the discriminator. The formula is as follows:

[0081]

[0082] Among them, σ(W) represents the spectral norm of the weight parameter W, h is the non-zero input vector, representing the characteristics of the data sample, and ‖·‖2 represents the l2 norm, that is, the square root of the sum of the squares of the vector elements;

[0083] Thus, we can get the weight parameters after spectrum normalization:

[0084]

[0085] (2.3) The hinge adversarial loss is introduced into the network training process, where the generator L G With the discriminator L D The losses are:

[0086]

[0087] Among them, P x With P z represent the real data distribution and noise distribution respectively, and represents the expectation of the distribution of real samples x and noise z, D(x) and D(G(z)) represent the output of the discriminator for x and G(z), respectively;

[0088] (2.4) All images in the training set processed by steps (1.1) and (1.2) are sent to the network in batches for iterative training. The training curve is as follows: Figure 3 As shown in Figure 2, the loss function values ​​of the generator and the discriminator show a downward trend and eventually stabilize;

[0089] (2.5) After obtaining the model of step (2.4), the quality of image generation is evaluated using the FID and KID indicators, and the optimal generator is selected;

[0090] (2.6) Use the generator in step (2.5) to generate 2280 lung chest X-ray images to obtain a class-balanced training set.

[0091] (3) Construct a residual neural network, use the balanced data set in step (2) as the network input and train it. The overall process is as follows: Figure 4 This part mainly includes the following steps:

[0092] (3.1) Construct a basic residual block and use it to construct a residual neural network;

[0093] (3.2) Based on step (3.1), the spatial attention mechanism is integrated into the residual neural network. The structure of the spatial attention mechanism is as follows: Figure 5 As shown, it can be expressed as:

[0094] M s (F) = σ(f 7×7 (concat[AvgPool(F);MaxPool(F)]))

[0095] Among them, F represents the input feature. The feature vectors AvgPool(F) and MaxPool(F) obtained by average pooling and maximum pooling are concatenated, and then a convolution layer with a convolution kernel size of 7×7 is used for calculation. Finally, σ (which represents the Sigmoid activation function) is used to obtain the output spatial attention map Ms (F);

[0096] Next, the spatial attention map M s (F) is multiplied element-wise with the original input feature to obtain the feature map F for spatial attention enhancement ′ , which is expressed as follows:

[0097]

[0098] (3.3) The feature F obtained by the first convolutional layer first And the feature F obtained after the last convolution layer last After fusion, the fused feature F fused It is expressed as follows:

[0099] F fused =0.5×(F first +F last );

[0100] (3.4) The cross entropy loss is used to measure the difference between the probability distribution predicted by the model and the probability distribution of the true label. In the binary classification problem of the present invention, the formula of the cross entropy loss function is:

[0101] L(y,a)=-[ylog(a)+(1-y)log(1-a)]

[0102] Among them, y is the true label, and a is the probability of the model predicting the positive class;

[0103] (3.5) Send the class-balanced training set images in step (2.6) to the network in batches for iterative training;

[0104] (3.6) After obtaining the model of step (3.5), use accuracy, recall, precision and F1 score to evaluate and obtain the model with the best effect on the validation set.

[0105] (4) The network in step (3) is pruned using a method based on the geometric median to remove redundant filters and restore accuracy by retraining from scratch. The pruning diagram is shown in the figure below: Figure 6 This part mainly includes the following steps:

[0106] (4.1) Load the model in step (3.6) and set the global pruning ratio r;

[0107] (4.2) According to the global pruning ratio r set in step (4.1), traverse the convolutional layers of the model layer by layer and obtain the filters, and then calculate their geometric centers It is expressed as follows:

[0108]

[0109] Where F is an arbitrary K×K filter, F n is the filter in the network, n∈[1,N], N is the total number of filters in the convolutional layer;

[0110] Then, according to the geometric center Calculate the distance D between each layer filter and it n , which is expressed as follows:

[0111]

[0112] Next, for D n After sorting, we get D ′ n , and calculate the pruning threshold T, which is expressed as follows:

[0113] T=D ′ n [int(r·N)]

[0114] Finally, the filters that are less than or equal to T are set to 0 and regarded as redundant filters;

[0115] (4.3) Traverse the convolutional layers in the model and remove the zero-value filters while ensuring that the remaining filter weights remain unchanged;

[0116] (4.4) Use the class-balanced training set in step (2.6) to iteratively optimize the pruned model to recover the accuracy loss caused by pruning;

[0117] (4.5) The retrained pruned model is evaluated through the validation data set, and the best model is obtained using three indicators: accuracy, number of parameters, and amount of computation.

[0118] The experimental results show that the proposed method based on deep convolutional generative adversarial network has achieved 36.92 and 0.03 in FID and KID indicators, respectively, which are about 60% and 73% lower than the original network. This result shows that the lung chest X-ray samples generated by the generator are of high quality. Figure 7 In addition, the pneumonia classification model proposed by the present invention, which integrates the attention mechanism and the residual neural network, has achieved 95.5%, 95.2%, 95.3% and 95.2% in accuracy, precision, recall and F1 score respectively. The classification confusion matrix is ​​shown in Figure 8As shown, it shows a high classification performance, which meets the expected goals of practical applications. In terms of model lightweighting, the number of parameters and the amount of calculation of the original pneumonia classification model are 7.4M and 391.4M FLOPs, respectively. By adopting the model pruning method based on the geometric median, the number of parameters and the amount of calculation of the lightweight model obtained by the present invention are reduced to 2.4M and 119.5M FLOPs, respectively, which are reduced by about 68% and 70%, respectively. After testing, the lightweight model can still maintain a high performance, as shown in the following table:

[0119]

[0120] In summary, the method proposed in the present invention can significantly reduce storage occupancy and computational complexity while basically maintaining the performance of the pneumonia classification model. It is particularly suitable for applications in resource-constrained environments and has strong practical application value and promotion potential.

[0121] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the above embodiments do not limit the protection scope of the present invention in any form, and all technical solutions obtained by equivalent replacement and the like fall within the protection scope of the present invention. The parts not involved in the present invention are the same as the prior art or can be implemented by the prior art.

Claims

1. A lightweight method for pneumonia classification based on few-sample enhancement, characterized in that: The steps include: S1. Preprocessing lung chest X-ray images; S2. Build a deep convolutional generative adversarial network to perform data enhancement on minority samples to balance the ratio of positive and negative samples; S3, construct a residual neural network, use the data set after category balancing in step S2 as network input and train it; S4. Prune the network in step S3 using a method based on geometric median to remove redundant filters and restore accuracy by training from scratch.

2. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 1, characterized in that: The pre-processing steps in step S1 are: S1-1, all images in the original lung chest X-ray dataset are centrally cropped according to the window size of the short side length, and then all images are adjusted to the set size using the bilinear interpolation method, and finally the input data is standardized according to the mean and standard deviation; S1-2. Redivide the training set according to a certain ratio.

3. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 1, characterized in that: The specific steps of step S2 are: S2-1. Build the deep convolutional generative adversarial network DCGAN infrastructure, which includes the generator and the discriminator. The generator is responsible for generating fake samples similar to real samples, while the discriminator is used to evaluate the authenticity of the samples. S2-2. Apply spectral normalization in the generator and discriminator of DCGAN. S2-3. Introduce hinge adversarial loss into the network training process, where the generator L G With the discriminator L D The losses are: Where P x With P z represent the real data distribution and noise distribution respectively, and represents the expectation of the distribution of real samples x and noise z, D(x) and D(G(z)) represent the output of the discriminator for x and G(z), respectively; S2-4, sending all the images in the training set processed by steps S1-1 and S1-2 into the network in batches for iterative training; S2-5. After obtaining the model of step S2-4, the quality of image generation is evaluated using the FID and KID indicators, and the optimal generator is selected; S2-6. Use the generator in step S2-5 to generate several lung chest X-ray images to obtain a training set with balanced categories.

4. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 3, characterized in that: The step S2-2 is specifically: adding a spectrum normalization layer after the convolution layer of the generator and the transposed convolution layer of the discriminator, and the formula is as follows: Where σ(W) represents the spectral norm of the weight parameter W, h is the non-zero input vector, representing the characteristics of the data sample, and ‖·‖2 represents the l2 norm, which is the square root of the sum of the squares of the vector elements; Then we can get the weight parameters after spectrum normalization:

5. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 3, characterized in that: The specific process of step S3 is: S3-1, construct a basic residual block and use it to construct a residual neural network; S3-2, based on step S3-1, integrating the spatial attention mechanism into the residual neural network; S3-3. The feature F obtained by the first convolutional layer first And the feature F obtained after the last convolution layer last After fusion, the fused feature F fused It is expressed as follows: F fused =0.5×(F first +F last ) S3-4. Use cross entropy loss to measure the difference between the probability distribution of model prediction and the probability distribution of the true label; S3-5, sending the class-balanced training set images in step S2-6 to the network in batches for iterative training; S3-6. After obtaining the model of step S3-5, use accuracy, recall, precision and F1 score evaluation to obtain the model with the best effect on the validation set.

6. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 5, characterized in that: In step S3-2, the spatial attention mechanism is expressed as: M s (F)=σ(f 7×7 (concat[AvgPool(F);MaxPool(F)])) In the formula, F represents the input feature. The feature vectors AvgPool(F) and MaxPool(F) obtained by average pooling and maximum pooling are concatenated, and then a convolution layer with a convolution kernel size of 7×7 is used for calculation. Finally, the output spatial attention map M is obtained by the Sigmoid activation function. s (F); Next, the spatial attention map M s (F) is multiplied element-wise with the original input feature to obtain the feature map F for spatial attention enhancement ′ , which is expressed as follows:

7. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 5, characterized in that: In step S3-4, the formula of the cross entropy loss function is: L(y,a)=-[ylog(a)+(1-y)log(1-a)] Among them, y is the true label and a is the probability of the model predicting the positive class.

8. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 5, characterized in that: The specific process of step S4 is as follows: S4-1, loading the model in step S3-6, and setting the global pruning ratio r; S4-2, according to the global pruning ratio r set in step S4-1, traverse the convolutional layers of the model layer by layer and obtain the filters, and then calculate their geometric centers Then, according to the geometric center Calculate the distance D between each layer filter and it n , Next, for D n After sorting, we get D ′ n , and calculate the pruning threshold T, Finally, filters less than or equal to T are set to 0 and regarded as redundant filters; S4-3, traverse the convolutional layers in the model, remove the zero-value filters, and ensure that the remaining filter weights remain unchanged; S4-4, using the class-balanced training set in step S2-6 to iteratively optimize the pruned model to recover the accuracy loss caused by pruning; S4-5. Evaluate the retrained pruned model through the validation data set, and use the three indicators of accuracy, number of parameters, and amount of calculation to obtain the best model.

9. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 7, characterized in that: In step S4-2, the geometric center It is expressed as follows: Where F is an arbitrary K×K filter, F n is the filter in the network, n∈[1,N], and N is the total number of filters in the convolutional layer.

10. A lightweight method for pneumonia classification based on few-sample enhancement according to claim 7, characterized in that: In step S4-2, the distance D n , which is expressed as follows: The pruning threshold T is expressed as follows: T=D ′ n [int(r·N)]。