A real-time detection method for malaria parasites based on a lightweight neural network model
Through the design of the lightweight neural network model, the problems of high demand for computing resources and insufficient real-time performance in the existing technology are solved, and high-precision and real-time detection of malaria parasites are achieved, which is suitable for low resource environments and reduces hardware dependence and diagnostic costs.
Patent Information
- Application Number
- CN202510387835.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-03-31
AI Technical Summary
The existing deep learning models have high demand for computing resources and insufficient real-time performance in malaria detection, which cannot meet the real-time detection needs in low-resource environments, and are poorly adaptable, making it difficult to cope with the differences in diagnostic environments and infrastructure in different regions.
A lightweight neural network model is adopted, including backbone network, neck network and detection head network, and feature extraction and fusion is performed through dynamic bottleneck module, sparse attention module and efficient bidirectional feature pyramid module. Combined with anchor-free detection heads, a lightweight Plasmodium detection model is built, and iterative training is carried out to improve detection accuracy and efficiency.
It realizes high-precision and real-time detection of malaria parasites, reduces hardware dependence, is suitable for low-resource environments, can operate efficiently on low-power equipment, and reduces diagnostic costs. It is especially suitable for areas with scarce medical resources.
Smart Images

Figure CN119919936B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision and deep learning technologies, and more specifically, to a real-time detection method for malaria parasites based on a lightweight neural network model. Background Art
[0002] Malaria is a major parasitic disease threatening global health. Traditional malaria detection involves manual microscopic examination of thick or thin blood smears for parasites. While this method offers high accuracy, it relies on experienced parasitologists, is time-consuming and labor-intensive, has low detection efficiency, and is difficult to implement on a large scale. Furthermore, due to differences in working environments and technical limitations, misdiagnosis or missed diagnoses may occur.
[0003] In recent years, with the advancement of deep learning technology, a large number of target detection models have been applied in biological image processing. The use of computer-aided diagnosis can greatly reduce the pressure on medical workers, helping them to automatically identify cells and types of diseases, thereby effectively reducing the risks of false detection and missed detection in traditional medical methods, and improving detection accuracy and efficiency. This is of great significance to the prevention and control of malaria.
[0004] For example, the patent document with publication number "CN116844158A" discloses a blood smear malarial cell detection system based on deep learning, which includes the following modules: a data processing module: using a portion of data samples as a training set and another portion of data samples as a test set; an anchor frame clustering module: clustering the data set to generate anchor frames; a model training module: using the data set to train the YOLOv5-CoT network; a blood smear detection module: the blood smear image enters the trained YOLOv5-CoT network for prediction; in the prior art, malarial parasites in the blood smear image are detected by the YOLOv5-CoT network. However, the model structure of this solution is relatively complex and the processing speed is slow. It is not suitable for application scenarios with low bandwidth, low computing resources and real-time diagnosis, especially in remote areas with scarce resources, such as Africa, where the infrastructure is poor and the detection effect is difficult to guarantee;
[0005] In general, current deep learning models have the following shortcomings in Plasmodium detection:
[0006] 1) High computing resource requirements: Complex models (such as the YOLOv5-CoT network) require strong computing power and are difficult to achieve real-time processing in low-resource environments;
[0007] 2) Insufficient real-time performance: Existing models have slow processing speeds and cannot meet the needs of rapid and immediate diagnosis. Especially when the diagnostic workload is large, they may not be able to provide timely feedback.
[0008] 3) Lack of adaptability: Existing technologies often rely on complex data preprocessing and feature extraction, have poor adaptability, and cannot cope well with the differences in diagnostic environments and infrastructure in different regions (such as Africa).
[0009] Therefore, in order to meet the urgent need for efficient and real-time malaria detection in resource-limited regions such as Africa, it is necessary to propose a lightweight, high-precision and high-real-time Plasmodium detection solution. Summary of the Invention
[0010] To overcome the shortcomings of the above-mentioned prior art deep learning models related to malaria detection, such as high computing resource requirements and insufficient real-time performance, the present invention provides a real-time detection method for Plasmodium falciparum based on a lightweight neural network model. By optimizing the model structure and lightweight design, the present invention significantly improves the accuracy and efficiency of Plasmodium falciparum identification. At the same time, the present invention reduces the model's dependence on hardware and bandwidth, meeting the needs of automated real-time malaria detection in remote and low-resource areas.
[0011] In order to solve the above technical problems, the technical solutions of the present invention are as follows:
[0012] A real-time detection method for Plasmodium based on a lightweight neural network model comprises the following steps:
[0013] S1: Acquire blood smear image dataset and perform preprocessing;
[0014] The blood smear image dataset includes a plurality of blood smear images containing malarial parasites;
[0015] S2: Establish a lightweight Plasmodium detection model based on deep learning algorithms;
[0016] The malarial parasite detection model comprises a backbone network, a neck network and a detection head network connected in sequence;
[0017] The backbone network is provided with a dynamic bottleneck module and a sparse attention module, and the backbone network is used to perform adaptive lightweight feature extraction on blood smear images;
[0018] The neck network is provided with a dynamic bottleneck module, a sparse attention module and an efficient bidirectional feature pyramid module, and the neck network is used to realize feature fusion;
[0019] The detection head network is provided with an anchor-free detection head, and the detection head network is used to output the malarial parasite detection result according to the fused features;
[0020] S3: Inputting the preprocessed blood smear image dataset into the Plasmodium detection model for iterative training to obtain a trained Plasmodium detection model;
[0021] S4: Obtain a blood smear image to be detected and input it into the trained Plasmodium detection model for detection to obtain a corresponding Plasmodium detection result.
[0022] Preferably, in step S1, the preprocessing includes:
[0023] Performing denoising on all collected blood smear images, wherein the denoising includes gamma correction and adaptive contrast enhancement;
[0024] All blood smear images after denoising were normalized to reduce the influence of illumination and background differences;
[0025] Performing data augmentation processing on all normalized blood smear images, wherein the data augmentation processing includes random rotation, random scaling, random cropping, and mirror flipping;
[0026] Labeling each data-augmented blood smear image; the labels include red blood cells without Plasmodium, and Plasmodium in the ring stage, trophozoite stage, and schizont stage;
[0027] After labeling is completed, the preprocessed blood smear image dataset is obtained.
[0028] Preferably, in step S2, the backbone network includes: a first convolutional layer, a second convolutional layer, a first dynamic bottleneck module, a third convolutional layer, a second dynamic bottleneck module, a fourth convolutional layer, a third dynamic bottleneck module, a first sparse attention module, and a spatial pyramid pooling-fast (SPPF) module connected in sequence;
[0029] The first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module are also respectively connected to the neck network;
[0030] The input of the backbone network is a blood smear image, and the output is the features extracted by the first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module.
[0031] Preferably, in step S2, the neck network includes sequentially connected: a first upsampling layer, a first splicing layer, a fourth dynamic bottleneck module, a first efficient bidirectional feature pyramid module, a second sparse attention module, a fifth dynamic bottleneck module, a second efficient bidirectional feature pyramid module, a third sparse attention module, a second upsampling layer, a second splicing layer, a sixth dynamic bottleneck module, a fifth convolutional layer, a third splicing layer, a seventh dynamic bottleneck module, a sixth convolutional layer, a fourth splicing layer and an eighth dynamic bottleneck module;
[0032] The output of the fourth dynamic bottleneck module is connected to the fourth splicing layer; the output of the fourth dynamic bottleneck module is connected to the third splicing layer;
[0033] For the connection between the backbone network and the neck network, the output of the spatial pyramid pooling module is connected to the first upsampling layer; the output of the second dynamic bottleneck module is connected to the first splicing layer; the output of the first dynamic bottleneck module is connected to the second splicing layer;
[0034] The output of the neck network is the output of the sixth dynamic bottleneck module, the seventh dynamic bottleneck module and the eighth dynamic bottleneck module.
[0035] Preferably, in step S2, the detection head network includes a first anchor-free detection head, a second anchor-free detection head, and a third anchor-free detection head arranged in parallel;
[0036] For the connection between the neck network and the detection head network, the output of the sixth dynamic bottleneck module is connected to the first anchor-free detection head; the output of the seventh dynamic bottleneck module is connected to the second anchor-free detection head; the output of the eighth dynamic bottleneck module is connected to the third anchor-free detection head;
[0037] The malarial parasite detection result output by the detection head network includes the type, location and confidence score of the malarial parasite.
[0038] Preferably, in step S2, the dynamic bottleneck module includes: a 2D convolution layer, a batch normalization (BatchNorm) layer, a ReLU activation layer, and a dynamic channel pruning layer connected in sequence; the input of the 2D convolution layer also forms a residual connection with the output of the dynamic channel pruning layer;
[0039] The dynamic channel pruning layer is used to calculate the importance score of each channel and dynamically decide whether to retain it, which is expressed as:
[0040]
[0041] in, is the importance score of channel c; is a pixel ( i , j ) is the eigenvalue output at channel c, H and W are the height and width of the entire feature map respectively;
[0042] reserve Channels larger than the preset pruning threshold λ are deleted Channels that are less than or equal to the preset pruning threshold λ.
[0043] Preferably, in step S2, the sparse attention module calculates the feature weight of each channel based on the channel attention mechanism, which is expressed as:
[0044]
[0045] in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multilayer perceptron; represents the average pooling operation; Represents the maximum pooling operation;
[0046] Multiply the feature weights of each channel by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as:
[0047]
[0048] in, It is the feature map updated based on the channel attention mechanism;
[0049] In the feature map Based on the spatial attention, the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as:
[0050]
[0051] in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation;
[0052] Combine the spatial attention weights with the feature map Multiplication is expressed as:
[0053]
[0054] in, is the feature map after spatial attention processing;
[0055] Feature Map Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, which is expressed as:
[0056]
[0057] in, is the pixel point in the feature map Y ( i , j )’s eigenvalues; is a pixel ( i , j ) corresponding spatial attention weights; is the preset dynamic sparse threshold; is the feature map Middle pixel ( i , j )’s eigenvalues.
[0058] Preferably, in step S2, the efficient bidirectional feature pyramid module is specifically a BiFPN network.
[0059] Preferably, in step S3, a total loss function is set to supervise the iterative training of the Plasmodium detection model, and the AdamW optimizer is used to update the model parameters; when the value of the total loss function is less than or equal to a preset threshold or the maximum number of iterations is reached, the trained Plasmodium detection model is obtained;
[0060] The total loss function is expressed as:
[0061]
[0062] in, is the total loss function value; is the classification loss; For positioning loss; To exclude losses; and are the first and second hyperparameters, respectively;
[0063] The classification loss Calculated according to the following formula:
[0064]
[0065] in, is the category weight of Plasmodium, Target species for Plasmodium; is the predicted probability;
[0066] The positioning loss Calculated according to the following formula:
[0067]
[0068] in, is the total number of positive sample prediction boxes, which are obtained by screening by exceeding a certain threshold (such as 0.5) of the IoU with the real target box; for Loss function; is the predicted bounding box of the i-th positive sample, and the box coordinates output by network regression; is the target ground truth bounding box that matches the i-th positive sample;
[0069] The rejection loss Calculated according to the following formula:
[0070]
[0071] in, represents an attractor; indicates RepGT loss; RepBox loss; and represent the third and fourth hyperparameters respectively.
[0072] Preferably, the step S4 further comprises: performing a post-processing operation based on non-maximum suppression (NMS) on the malarial parasite detection result to improve the detection accuracy.
[0073] Compared with the prior art, the beneficial effects of the technical solution of the present invention are:
[0074] The present invention provides a real-time malarial parasite detection method based on a lightweight neural network model. The method comprises the following steps: first, obtaining a blood smear image dataset and preprocessing it; then, establishing a lightweight malarial parasite detection model based on a deep learning algorithm; then, inputting the preprocessed blood smear image dataset into the malarial parasite detection model for iterative training; and finally, using the trained malarial parasite detection model to perform malarial parasite detection on the blood smear image to be detected.
[0075] The present invention constructs a lightweight detection model based on a deep learning algorithm, which not only achieves high-precision malarial parasite detection, but also optimizes the inference time to the millisecond level, which can meet the needs of rapid detection, is suitable for clinical applications, and effectively improves the real-time performance of detection; at the same time, the lightweight model design of the present invention can adapt to low-resource environments, has low hardware resource requirements, and the model can run efficiently on low-power devices; secondly, the present invention can realize malarial parasite detection throughout the entire life cycle, and the model can accurately identify the various morphologies and life cycle stages of malarial parasites, thereby improving the comprehensiveness of detection; in addition, the present invention reduces the cost of malarial parasite detection, and the automated malaria detection model greatly reduces dependence on experts and reduces diagnostic costs, making it particularly suitable for areas with scarce medical resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 This is a flow chart of a real-time detection method for Plasmodium based on a lightweight neural network model provided in Example 1.
[0077] Figure 2 Schematic diagram of blood smear images with different labels provided in Example 2.
[0078] Figure 3 This is a structural diagram of the lightweight Plasmodium detection model provided in Example 2.
[0079] Figure 4 This is a structural diagram of the dynamic bottleneck module provided in Example 2.
[0080] Figure 5 This is a PR curve diagram of the trained Plasmodium detection model provided in Example 2.
[0081] Figure 6 This is a schematic diagram of the confusion matrix of the trained Plasmodium detection model provided in Example 2.
[0082] Figure 7 This is a schematic diagram of the normalized confusion matrix of the trained Plasmodium detection model provided in Example 2.
[0083] Figure 8 This is a schematic diagram of the confusion matrix of the existing YOLOv8n model provided in Example 2. DETAILED DESCRIPTION
[0084] The accompanying drawings are for illustrative purposes only and are not to be construed as limiting the present application;
[0085] In order to better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product size;
[0086] It is understandable to those skilled in the art that some well-known structures and descriptions thereof may be omitted in the drawings.
[0087] The technical solution of the present invention is further described below with reference to the accompanying drawings and embodiments.
[0088] Example 1
[0089] like Figure 1 As shown, this embodiment provides a real-time detection method for Plasmodium based on a lightweight neural network model, comprising the following steps:
[0090] S1: Acquire blood smear image dataset and perform preprocessing;
[0091] The blood smear image dataset includes a plurality of blood smear images containing malarial parasites;
[0092] S2: Establish a lightweight Plasmodium detection model based on deep learning algorithms;
[0093] The malarial parasite detection model comprises a backbone network, a neck network and a detection head network connected in sequence;
[0094] The backbone network is provided with a dynamic bottleneck module and a sparse attention module, and the backbone network is used to perform adaptive lightweight feature extraction on blood smear images;
[0095] The neck network is provided with a dynamic bottleneck module, a sparse attention module and an efficient bidirectional feature pyramid module, and the neck network is used to realize feature fusion;
[0096] The detection head network is provided with an anchor-free detection head, and the detection head network is used to output the malarial parasite detection result according to the fused features;
[0097] S3: Inputting the preprocessed blood smear image dataset into the Plasmodium detection model for iterative training to obtain a trained Plasmodium detection model;
[0098] S4: Obtain a blood smear image to be detected and input it into the trained Plasmodium detection model for detection to obtain a corresponding Plasmodium detection result.
[0099] In the specific implementation process, a blood smear image dataset is first obtained and preprocessed. To improve the comprehensiveness of the model detection, in this embodiment, the acquired dataset includes images of Plasmodium throughout its life cycle, as well as images of red blood cells without Plasmodium, and each type of image is evenly distributed.
[0100] Next, a lightweight Plasmodium detection model was established based on a deep learning algorithm. This embodiment provides an efficient deep learning architecture that combines lightweight design with advanced dynamic modules to significantly improve detection performance in microscopy tasks. It mainly includes the following components:
[0101] 1) Backbone network for feature extraction:
[0102] A lightweight dynamic bottleneck module (Dynamic Bottleneck) is set up: Based on the traditional lightweight convolutional network, dynamic pruning technology is used to reduce unnecessary channel calculations, further reducing computing resource requirements while enhancing feature extraction capabilities. Dynamic channel pruning technology can reduce the amount of calculation while retaining important feature information, improving the model's operating efficiency on low-power devices such as embedded systems.
[0103] Sparse Attention: Introduces a sparse attention module that uses dynamic sparsification to focus on the target area, suppress background interference, and optimize computational efficiency.
[0104] Multi-scale feature extraction: Preserving the multi-scale structure, extracting feature information from local to global layer by layer, providing strong semantic support for subsequent detection;
[0105] 2) Neck network for feature fusion:
[0106] Efficient Bidirectional Feature Pyramid (Efficient BiFPN): This replaces the traditional unidirectional feature pyramid (FPN) and further enhances the perception of small objects through bidirectional information flow and streamlined feature fusion, while also optimizing robustness in complex backgrounds.
[0107] Sparse feature fusion: During the fusion process, unimportant features are thinned out to reduce redundant information, retaining only the most important features for detection. Through bidirectional feature flow and sparse feature fusion, the ability to detect multi-scale objects is significantly improved without increasing the computational load. The model is also more robust in complex backgrounds and adaptable to varying lighting conditions and noise environments.
[0108] Hierarchical fusion strategy: Combining low-level fine-grained features with high-level semantic features, through hierarchical feature integration, while maintaining lightweight, it enhances the model's adaptability to multi-scale targets and optimizes target detection in complex backgrounds;
[0109] 3) Detection head network:
[0110] Dynamically optimized detection head: The anchor-free detection head, combined with a dynamic weight adjustment mechanism, performs specialized optimization on small target areas (such as malarial rings), significantly improving detection performance.
[0111] Strengthening small target features: Increasing the participation of low-level features and enhancing the ability to capture small targets through multiple fusions and dynamic attention mechanisms;
[0112] In this example, the preprocessed blood smear image dataset is input into a constructed Plasmodium detection model for training. The model uses a lightweight dynamic bottleneck module to extract features layer by layer and optimizes computational complexity through dynamic channel pruning. A sparse attention mechanism is used to dynamically focus on important areas while suppressing background noise, significantly improving the feature expression of the target area. A bidirectional feature pyramid and sparse fusion technique are used to integrate multi-scale features and improve adaptability to multi-scale targets. Finally, the model outputs the target category, location, and confidence score, optimizing detection performance for small targets (such as annular bodies).
[0113] Finally, the trained malarial parasite detection model is used to perform real-time malarial parasite detection on the blood smear image to be tested;
[0114] Compared with existing deep learning models, this method has the following advantages:
[0115] 1) Significantly improve the accuracy of malarial parasite recognition: malarial parasites are relatively small and immobile compared to blood cells. Through a specifically designed model structure, it is possible to perform real-time reasoning on small targets at the cellular level.
[0116] 2) Improve computational efficiency: Reduce reliance on high-performance hardware, making the model applicable to resource-limited areas;
[0117] 3) Achieve efficient real-time detection: By optimizing the model structure and lightweight design, the inference speed is improved to meet the real-time detection requirements;
[0118] 4) Reduced reliance on professionals: Fully automated model reasoning and high-precision output reduce the need for human expertise.
[0119] 5) High detection efficiency, accuracy and adaptability, especially suitable for the automatic diagnosis of malaria in low-resource areas.
[0120] Example 2
[0121] This embodiment provides a real-time detection method for Plasmodium based on a lightweight neural network model, comprising the following steps:
[0122] S1: Acquire blood smear image dataset and perform preprocessing;
[0123] The blood smear image dataset includes a plurality of blood smear images containing malarial parasites;
[0124] S2: Establish a lightweight Plasmodium detection model based on deep learning algorithms;
[0125] The malarial parasite detection model comprises a backbone network, a neck network and a detection head network connected in sequence;
[0126] The backbone network is provided with a dynamic bottleneck module and a sparse attention module, and the backbone network is used to perform adaptive lightweight feature extraction on blood smear images;
[0127] The neck network is provided with a dynamic bottleneck module, a sparse attention module and an efficient bidirectional feature pyramid module, and the neck network is used to realize feature fusion;
[0128] The detection head network is provided with an anchor-free detection head, and the detection head network is used to output the malarial parasite detection result according to the fused features;
[0129] S3: Inputting the preprocessed blood smear image dataset into the Plasmodium detection model for iterative training to obtain a trained Plasmodium detection model;
[0130] S4: Obtain a blood smear image to be tested and input it into the trained Plasmodium detection model for detection to obtain a corresponding Plasmodium detection result;
[0131] Perform post-processing based on non-maximum suppression on the malarial parasite detection results to improve detection accuracy;
[0132] In step S1, the pre-processing includes:
[0133] Performing denoising on all collected blood smear images, wherein the denoising process includes gamma correction and adaptive contrast enhancement;
[0134] All blood smear images after denoising were normalized to reduce the influence of illumination and background differences;
[0135] Performing data augmentation processing on all normalized blood smear images, wherein the data augmentation processing includes random rotation, random scaling, random cropping, and mirror flipping;
[0136] Labeling each data-augmented blood smear image; the labels include red blood cells without Plasmodium, and Plasmodium in the ring stage, trophozoite stage, and schizont stage;
[0137] After labeling is completed, the preprocessed blood smear image dataset is obtained.
[0138] In step S2, the backbone network includes: a first convolutional layer, a second convolutional layer, a first dynamic bottleneck module, a third convolutional layer, a second dynamic bottleneck module, a fourth convolutional layer, a third dynamic bottleneck module, a first sparse attention module, and a spatial pyramid pooling module connected in sequence;
[0139] The first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module are also respectively connected to the neck network;
[0140] The input of the backbone network is a blood smear image, and the output is the features extracted by the first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module;
[0141] The neck network includes: a first upsampling layer, a first splicing layer, a fourth dynamic bottleneck module, a first efficient bidirectional feature pyramid module, a second sparse attention module, a fifth dynamic bottleneck module, a second efficient bidirectional feature pyramid module, a third sparse attention module, a second upsampling layer, a second splicing layer, a sixth dynamic bottleneck module, a fifth convolutional layer, a third splicing layer, a seventh dynamic bottleneck module, a sixth convolutional layer, a fourth splicing layer, and an eighth dynamic bottleneck module, connected in sequence;
[0142] The output of the fourth dynamic bottleneck module is connected to the fourth splicing layer; the output of the fourth dynamic bottleneck module is connected to the third splicing layer;
[0143] For the connection between the backbone network and the neck network, the output of the spatial pyramid pooling module is connected to the first upsampling layer; the output of the second dynamic bottleneck module is connected to the first splicing layer; the output of the first dynamic bottleneck module is connected to the second splicing layer;
[0144] The output of the neck network is the output of the sixth dynamic bottleneck module, the seventh dynamic bottleneck module and the eighth dynamic bottleneck module;
[0145] The detection head network includes a first anchor-free detection head, a second anchor-free detection head and a third anchor-free detection head arranged in parallel;
[0146] For the connection between the neck network and the detection head network, the output of the sixth dynamic bottleneck module is connected to the first anchor-free detection head; the output of the seventh dynamic bottleneck module is connected to the second anchor-free detection head; the output of the eighth dynamic bottleneck module is connected to the third anchor-free detection head;
[0147] The malarial parasite detection result output by the detection head network includes the type, location and confidence score of the malarial parasite;
[0148] In step S2, the dynamic bottleneck module includes: a 2D convolutional layer, a batch normalization layer, a ReLU activation layer, and a dynamic channel pruning layer connected in sequence; the input of the 2D convolutional layer also forms a residual connection with the output of the dynamic channel pruning layer;
[0149] The dynamic channel pruning layer is used to calculate the importance score of each channel and dynamically decide whether to retain it, which is expressed as:
[0150]
[0151] in, is the importance score of channel c; is a pixel ( i , j ) is the eigenvalue output at channel c, H and W are the height and width of the entire feature map respectively;
[0152] reserve Channels larger than the preset pruning threshold λ are deleted For channels whose pruning threshold is less than or equal to the preset pruning threshold λ, the pruning threshold λ is dynamically adjusted according to computing resources;
[0153] In step S2, the sparse attention module calculates the feature weight of each channel based on the channel attention mechanism, which is expressed as:
[0154]
[0155] in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multilayer perceptron; represents the average pooling operation; Represents the maximum pooling operation;
[0156] Multiply the feature weights of each channel by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as:
[0157]
[0158] in, It is the feature map updated based on the channel attention mechanism;
[0159] In the feature map Based on the spatial attention, the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as:
[0160]
[0161] in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation;
[0162] Combine the spatial attention weights with the feature map Multiplication is expressed as:
[0163]
[0164] in, is the feature map after spatial attention processing;
[0165] Feature Map Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, which is expressed as:
[0166]
[0167] in, is the pixel point in the feature map Y ( i , j )’s eigenvalues; is a pixel ( i , j ) corresponding spatial attention weights; is the preset dynamic sparse threshold; is the feature map Middle pixel ( i , j )’s eigenvalues;
[0168] In step S2, the efficient bidirectional feature pyramid module is specifically a BiFPN network;
[0169] In step S3, a total loss function is set to supervise the iterative training of the Plasmodium detection model, and the model parameters are updated using the AdamW optimizer; when the value of the total loss function is less than or equal to a preset threshold or the maximum number of iterations is reached, the trained Plasmodium detection model is obtained;
[0170] The total loss function is expressed as:
[0171]
[0172] in, is the total loss function value; is the classification loss; For positioning loss; To exclude losses; and are the first and second hyperparameters, respectively;
[0173] The classification loss Calculated according to the following formula:
[0174]
[0175] in, is the category weight of Plasmodium, Target species for Plasmodium; is the predicted probability;
[0176] The positioning loss Calculated according to the following formula:
[0177]
[0178] in, is the total number of positive sample prediction boxes, which are obtained by screening by exceeding a certain threshold (such as 0.5) of the IoU with the real target box; for Loss function; is the predicted bounding box of the i-th positive sample, and the box coordinates output by network regression; is the target ground truth bounding box that matches the i-th positive sample;
[0179] The rejection loss Calculated according to the following formula:
[0180]
[0181] in, represents an attractor; indicates RepGT loss; RepBox loss; and represent the third and fourth hyperparameters respectively.
[0182] In the specific implementation process, this example first uses malaria samples provided by a certain unit, collects images through a microscope, and uses traditional methods (such as Giemsa staining) to process the samples and generate thin blood smear images. The image resolution is 1360×1024 to ensure image clarity and detail. During the image acquisition process, a high-resolution digital microscope and an autofocus system are combined to ensure that clear, non-stacked cell images are captured. The number of cells in each image is controlled between 325 and 350 to ensure sample representativeness.
[0183] This example constructs a dataset based on 347 thin blood smear images, which are divided into four categories during annotation: red blood cells, and rings, trophozoites, and schizonts according to the life cycle of Plasmodium in the human body. Figure 2 As shown;
[0184] The collected data set is then preprocessed to ensure the image quality of the model input by performing image denoising, contrast enhancement, and standardization. At the same time, random rotation, scaling, cropping, and mirror flipping techniques are used to expand the data to improve the generalization ability of the model.
[0185] Then, a lightweight malarial parasite detection model is constructed based on the deep learning algorithm. The model architecture in this embodiment refers to the YOLOv8 architecture. An efficient and lightweight network is redesigned for the recognition of malarial parasites (small targets). The model structure is as follows: Figure 3 As shown, it combines dynamic optimization and sparse attention mechanism to improve the detection capability and resource utilization efficiency of the model;
[0186] The model in this embodiment mainly includes the following parts:
[0187] 1) Backbone network:
[0188] This embodiment uses a dynamically optimized backbone network, replacing traditional convolutional units with a Dynamic Bottleneck module. This module optimizes channel computation through dynamic pruning, reducing redundant computation while preserving key features. Specifically, Dynamic Bottleneck evaluates the importance of each channel and determines which channels to prune, significantly reducing computational complexity while ensuring feature extraction quality. This design is particularly suitable for processing high-resolution microscopy images, enabling efficient extraction of multi-scale features while reducing computational overhead.
[0189] like Figure 4As shown in Figure 2, the Dynamic Bottleneck module uses a pruning optimization strategy to reduce unnecessary computation while retaining important features, making it suitable for low-computing resource scenarios. Specifically, the dynamic channel pruning strategy is used to calculate the importance score of each channel and dynamically decide whether to retain it, as expressed as:
[0190]
[0191] in, is the importance score of channel c; is a pixel ( i , j ) is the eigenvalue output at channel c, H and W are the height and width of the entire feature map respectively;
[0192] reserve Channels larger than the preset pruning threshold λ are deleted For channels that are less than or equal to the preset pruning threshold λ, the pruning threshold λ is dynamically adjusted based on computing resources. After introducing the dynamic bottleneck module, the model is more lightweight, reducing the participation of more than 50% of unimportant channels and reducing computational complexity. At the same time, it is more flexible and supports dynamic adjustment of the number of channels to adapt to different microscopic image inputs.
[0193] Introducing Sparse Attention:
[0194] This embodiment introduces a sparse attention mechanism during the deep feature extraction process of the backbone network. By dynamically sparsifying unimportant features, the model can more effectively focus on the key areas of the malarial parasite while suppressing background noise. Especially under complex background conditions in microscopic images, the sparse attention mechanism can enhance the robustness of the model, thereby improving the accuracy of malarial parasite detection.
[0195] The sparse attention module calculates the feature weights of each channel based on the channel attention mechanism, which is expressed as:
[0196]
[0197] in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multilayer perceptron; represents the average pooling operation; Represents the maximum pooling operation;
[0198] Multiply the feature weights of each channel by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as:
[0199]
[0200] in, It is the feature map updated based on the channel attention mechanism;
[0201] In the feature map Based on the spatial attention, the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as:
[0202]
[0203] in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation;
[0204] Combine the spatial attention weights with the feature map Multiplication is expressed as:
[0205]
[0206] in, is the feature map after spatial attention processing;
[0207] In addition, this embodiment also introduces a dynamic sparsification mechanism in the sparse attention module, which sparsifies the low-weight areas in the spatial dimension and effectively reduces computational redundancy by eliminating feature areas with low attention weights. Specifically, the feature map Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, which is expressed as:
[0208]
[0209] in, is the pixel point in the feature map Y ( i , j ) is set to zero in areas with low attention weights to reduce the interference of background noise; is a pixel ( i , j ) corresponding spatial attention weights; is the preset dynamic sparse threshold; is the feature map Middle pixel ( i , j )’s eigenvalues;
[0210] Multi-scale feature extraction:
[0211] The backbone network in this embodiment adopts a hierarchical design, gradually extracting multi-scale features from low-level details to high-level semantics through the Dynamic Bottleneck module. In this process, the network can simultaneously capture fine-grained local features and global semantic information, providing strong support for subsequent detection tasks.
[0212] 2) Neck network:
[0213] Efficient Bi-directional Feature Pyramid (Efficient BiFPN):
[0214] This embodiment uses a highly efficient BiFPN design in the feature fusion module, replacing the traditional PANet. By introducing a bidirectional feature flow mechanism, BiFPN significantly enhances the efficiency of feature fusion, making it particularly suitable for detecting small targets (such as malarial parasite rings). The BiFPN network is equipped with an uplink path and a downlink path, which enhances the ability to capture small targets through feature upsampling and downsampling mechanisms. This module integrates high-level semantic information with low-level fine-grained features, improving the ability to recognize different stages of the malarial parasite life cycle (such as rings, trophozoites, and schizonts). Compared with the traditional FPN, it reduces computational overhead, optimizes the detection accuracy of small targets, and improves the efficiency of multi-scale feature fusion.
[0215] Hierarchical feature integration:
[0216] During the feature fusion process, this embodiment adopts a dynamic sparse fusion strategy to retain only the most important features for detection. This not only reduces redundant information but also increases the speed of feature fusion, thereby optimizing the utilization of computing resources.
[0217] Lightweight optimization:
[0218] In the neck network, a dynamic channel pruning strategy is further introduced to dynamically adjust unimportant feature channels, thereby reducing computational overhead. This lightweight design enables the model to run efficiently even in resource-limited environments and is particularly suitable for low-power devices.
[0219] 3) Detection head network:
[0220] Lightweight detection head:
[0221] This embodiment uses an Anchor-Free (no anchor box) detection head, which simplifies the target positioning process and reduces the computational overhead of anchor box generation and matching;
[0222] In addition, to further improve detection performance, this embodiment also uses a dynamic head as the detection head. By introducing a dynamic weight adjustment mechanism, the model can dynamically adjust the weight according to the target size and importance, optimizing the detection capability of small targets (such as malarial ring bodies). This mechanism is particularly suitable for malarial parasites with small characteristic sizes, enhancing the model's detection capability for small targets.
[0223] The detection head network further improves the detection performance of small targets by increasing the proportion of low-level features. Combined with efficient feature fusion technology, the model can more accurately locate and detect tiny targets such as malarial parasites.
[0224] At the same time, the detection head focuses on optimizing inference speed, improving the model's response speed during real-time detection by reducing unnecessary computation. This enables the model to provide rapid feedback in environments with high diagnostic workloads, meeting the needs of real-time diagnosis.
[0225] After the model is built, the preprocessed blood smear image dataset is input into the Plasmodium detection model for iterative training to obtain a trained Plasmodium detection model;
[0226] In this example, the dataset is divided into a training set and a validation set in a ratio of 7:3, with 70% used for model training and the remaining 30% used to verify model performance. During the partitioning process, the distribution of samples in each category is ensured to enhance the generalization ability of the model.
[0227] In this embodiment, the iterative training of the Plasmodium detection model is supervised by setting a total loss function, and the model parameters are updated using the AdamW optimizer. The update rule of the AdamW optimizer is:
[0228]
[0229] in, is the parameter of the tth iteration; A small constant to prevent division by zero; is the learning rate, and the initial value is set to 1×10 -4 , and combined with the cosine annealing strategy to gradually decay, it can be expressed as:
[0230]
[0231] in, and are the first-order and second-order moment estimates of the gradient, respectively;
[0232] For the detection task of thin blood smear images, this example uses Repulsion Loss as the core loss function, and combines classification loss and localization loss to optimize the model's detection performance for red blood cells and malarial parasites.
[0233] In this embodiment, the total loss function is expressed as:
[0234]
[0235] in, is the total loss function value; is the classification loss; For positioning loss; To exclude losses; and are the first and second hyperparameters, respectively;
[0236] Classification loss Calculated according to the following formula:
[0237]
[0238] in, is the category weight of Plasmodium, Target species for Plasmodium; is the predicted probability;
[0239] Positioning loss Calculated according to the following formula:
[0240]
[0241] in, is the total number of positive sample prediction boxes, which are obtained by screening by exceeding a certain threshold (such as 0.5) of the IoU with the real target box; for Loss function; is the predicted bounding box of the i-th positive sample, and the box coordinates output by network regression; is the target ground truth bounding box that matches the i-th positive sample;
[0242] The rejection loss Calculated according to the following formula:
[0243]
[0244] in, represents an attractor; indicates RepGT loss; RepBox loss; and denote the third and fourth hyperparameters respectively;
[0245] Furthermore, the attraction :
[0246]
[0247] RepGT loss:
[0248]
[0249] RepBox Loss:
[0250]
[0251] When the value of the total loss function is less than or equal to a preset threshold or the maximum number of iterations is reached, a trained Plasmodium detection model is obtained. Finally, the blood smear image to be detected is input into the trained Plasmodium detection model for detection, and a corresponding Plasmodium detection result is obtained, thereby completing the detection. In addition, this embodiment also performs a post-processing operation based on non-maximum suppression on the Plasmodium detection result to further improve detection accuracy.
[0252] This embodiment also uses a validation set to verify the performance of the trained model. Through experiments on the validation set, the model of this embodiment demonstrates significant detection performance. The traditional method for calculating the overall recall rate is to sum and average the recall rates of each category. However, due to the serious class imbalance problem of the dataset, this method is not suitable for clinical evaluation. Therefore, the Plasmodium category recall rate is introduced, that is, the ratio of the total number of samples successfully identified as the three categories of Plasmodium (i.e., excluding those identified as background and red blood cells) to the total number of actual Plasmodium samples in the confusion matrix; Figure 5 and Figure 6 As shown; Figure 5 is the relationship between the recall rate and the threshold of each category, that is, when the confidence threshold is 0 (all prediction boxes are included), the overall regression rate is 91%; Figure 6 Schematic diagram of the confusion matrix (actual value) of the trained model;
[0253] In the performance evaluation, this embodiment also uses the confusion matrix (such as Figure 7 The normalized confusion matrix is shown in Figure 2. The detection accuracy of different Plasmodium species was evaluated. The experimental results show that for the same Plasmodium thin blood dataset, the precision and recall rate of the model far exceed those of the traditional YOLOv8n model (such as Figure 8 Shown is the confusion matrix of the YOLOv8n model under the same dataset);
[0254] In addition, the model in this embodiment has an inference time of approximately 0.187 seconds per image on a low-power device, which meets the needs of real-time detection and is particularly suitable for applications in low-resource environments, such as malaria screening and diagnosis in Africa.
[0255] This method constructs a lightweight detection model based on a deep learning algorithm, which not only achieves high-precision malarial parasite detection, but also optimizes the inference time to milliseconds, which can meet the needs of rapid detection, is suitable for clinical applications, and effectively improves the real-time performance of detection. At the same time, the lightweight model design in this embodiment is adaptable to low-resource environments, has low hardware resource requirements, and the model can run efficiently on low-power devices. Secondly, this method can achieve malarial parasite detection throughout the entire life cycle. The model can accurately identify the various morphologies and life cycle stages of malarial parasites, improving the comprehensiveness of detection. In addition, this method reduces the cost of malarial parasite detection. The automated malaria detection model greatly reduces dependence on experts and reduces diagnostic costs, making it particularly suitable for areas with scarce medical resources.
[0256] The same or similar reference numerals correspond to the same or similar components;
[0257] The terms used in the drawings to describe positional relationships are for illustrative purposes only and are not to be construed as limiting the present application.
[0258] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. A real-time detection method for Plasmodium based on a lightweight neural network model, characterized in that: The following steps are involved: S1: Acquire blood smear image dataset and perform preprocessing; The blood smear image dataset includes a plurality of blood smear images containing malarial parasites; S2: Establish a lightweight Plasmodium detection model based on deep learning algorithms; The malarial parasite detection model comprises a backbone network, a neck network and a detection head network connected in sequence; The backbone network is provided with a dynamic bottleneck module and a sparse attention module, and the backbone network is used to perform adaptive lightweight feature extraction on blood smear images; The neck network is provided with a dynamic bottleneck module, a sparse attention module and an efficient bidirectional feature pyramid module, and the neck network is used to realize feature fusion; The detection head network is provided with an anchor-free detection head, and the detection head network is used to output the malarial parasite detection result according to the fused features; The dynamic bottleneck module includes: a 2D convolutional layer, a batch normalization layer, a ReLU activation layer, and a dynamic channel pruning layer connected in sequence; the input of the 2D convolutional layer also forms a residual connection with the output of the dynamic channel pruning layer; The dynamic channel pruning layer is used to calculate the importance score of each channel and dynamically decide whether to retain it, which is expressed as: in, is the importance score of channel c; is a pixel ( i , j ) is the eigenvalue output at channel c, H and W are the height and width of the entire feature map respectively; reserve Channels larger than the preset pruning threshold λ are deleted Channels that are less than or equal to the preset pruning threshold λ; S3: Inputting the preprocessed blood smear image dataset into the Plasmodium detection model for iterative training to obtain a trained Plasmodium detection model; S4: Obtain a blood smear image to be detected and input it into the trained Plasmodium detection model for detection to obtain a corresponding Plasmodium detection result.
2. The method for real-time detection of Plasmodium based on a lightweight neural network model according to claim 1, characterized in that: In step S1, the pre-processing includes: Performing denoising on all collected blood smear images, wherein the denoising includes gamma correction and adaptive contrast enhancement; All blood smear images after denoising were normalized to reduce the influence of illumination and background differences; Performing data augmentation processing on all normalized blood smear images, wherein the data augmentation processing includes random rotation, random scaling, random cropping, and mirror flipping; Labeling each data-augmented blood smear image; the labels include red blood cells without Plasmodium, and Plasmodium in the ring stage, trophozoite stage, and schizont stage; After labeling is completed, the preprocessed blood smear image dataset is obtained.
3. The method for real-time detection of Plasmodium based on a lightweight neural network model according to claim 1, characterized in that: In step S2, the backbone network includes: a first convolutional layer, a second convolutional layer, a first dynamic bottleneck module, a third convolutional layer, a second dynamic bottleneck module, a fourth convolutional layer, a third dynamic bottleneck module, a first sparse attention module, and a spatial pyramid pooling module connected in sequence; The first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module are also respectively connected to the neck network; The input of the backbone network is a blood smear image, and the output is the features extracted by the first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module.
4. The method for real-time detection of Plasmodium based on a lightweight neural network model according to claim 3, characterized in that: In step S2, the neck network includes: a first upsampling layer, a first splicing layer, a fourth dynamic bottleneck module, a first efficient bidirectional feature pyramid module, a second sparse attention module, a fifth dynamic bottleneck module, a second efficient bidirectional feature pyramid module, a third sparse attention module, a second upsampling layer, a second splicing layer, a sixth dynamic bottleneck module, a fifth convolutional layer, a third splicing layer, a seventh dynamic bottleneck module, a sixth convolutional layer, a fourth splicing layer, and an eighth dynamic bottleneck module, connected in sequence; The output of the fourth dynamic bottleneck module is connected to the fourth splicing layer; the output of the fourth dynamic bottleneck module is connected to the third splicing layer; For the connection between the backbone network and the neck network, the output of the spatial pyramid pooling module is connected to the first upsampling layer; the output of the second dynamic bottleneck module is connected to the first splicing layer; the output of the first dynamic bottleneck module is connected to the second splicing layer; The output of the neck network is the output of the sixth dynamic bottleneck module, the seventh dynamic bottleneck module and the eighth dynamic bottleneck module.
5. The method for real-time detection of Plasmodium based on a lightweight neural network model according to claim 4, characterized in that: In step S2, the detection head network includes a first anchor-free detection head, a second anchor-free detection head, and a third anchor-free detection head arranged in parallel; For the connection between the neck network and the detection head network, the output of the sixth dynamic bottleneck module is connected to the first anchor-free detection head; the output of the seventh dynamic bottleneck module is connected to the second anchor-free detection head; the output of the eighth dynamic bottleneck module is connected to the third anchor-free detection head; The malarial parasite detection result output by the detection head network includes the type, location and confidence score of the malarial parasite.
6. A method for real-time detection of Plasmodium based on a lightweight neural network model according to any one of claims 1 to 5, characterized in that: In step S2, the sparse attention module calculates the feature weight of each channel based on the channel attention mechanism, which is expressed as: in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multilayer perceptron; represents the average pooling operation; Represents the maximum pooling operation; Multiply the feature weights of each channel by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as: in, It is the feature map updated based on the channel attention mechanism; In the feature map Based on the spatial attention, the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as: in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation; Combine the spatial attention weights with the feature map Multiplication is expressed as: in, is the feature map after spatial attention processing; Feature Map Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, which is expressed as: in, is the pixel point in the feature map Y ( i , j )’s eigenvalues; is a pixel ( i , j ) corresponding spatial attention weights; is the preset dynamic sparse threshold; is the feature map Middle pixel ( i , j )’s eigenvalues.
7. A method for real-time detection of Plasmodium based on a lightweight neural network model according to any one of claims 1 to 5, characterized in that: In step S2, the efficient bidirectional feature pyramid module is specifically a BiFPN network.
8. The method for real-time detection of Plasmodium based on a lightweight neural network model according to claim 1, characterized in that: In step S3, a total loss function is set to supervise the iterative training of the Plasmodium detection model, and the model parameters are updated using the AdamW optimizer; when the value of the total loss function is less than or equal to a preset threshold or the maximum number of iterations is reached, the trained Plasmodium detection model is obtained; The total loss function is expressed as: in, is the total loss function value; is the classification loss; For positioning loss; To exclude losses; and are the first and second hyperparameters, respectively; The classification loss Calculated according to the following formula: in, is the category weight of Plasmodium, Target species for Plasmodium; is the predicted probability; The positioning loss Calculated according to the following formula: in, is the total number of positive sample prediction boxes; for Loss function; is the predicted bounding box of the i-th positive sample; is the target ground truth bounding box that matches the i-th positive sample; The rejection loss Calculated according to the following formula: in, represents an attractor; indicates RepGT loss; RepBox loss; and represent the third and fourth hyperparameters respectively.
9. The method for real-time detection of Plasmodium based on a lightweight neural network model according to claim 1, characterized in that: The step S4 further includes: performing a post-processing operation based on non-maximum suppression on the malarial parasite detection result to improve the detection accuracy.
Citation Information
Patent Citations
Blood smear malaria cell detection system based on deep learning
CN116844158A
Tobacco insect target detection method fusing attention model
CN113673618A
Method for detecting plant diseases and insect pests of tomato leaves based on improved YOLOv5s
CN116994056A