Real-time plasmodium detection method based on lightweight neural network model
By using a lightweight neural network model in the detection of malaria parasites, the model structure and design are optimized, and the problems of high demand for computing resources, insufficient real-time and poor adaptability in the existing technology are solved, and efficient, economical and real-time detection of malaria parasites are achieved.
Patent Information
- Application Number
- CN202510387835.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-03-31
AI Technical Summary
The existing deep learning models have problems such as high demand for computing resources, insufficient real-time and poor adaptability in malaria detection, making it difficult to achieve efficient and real-time detection in low-resource environments.
The real-time detection method of Plasmodium based on lightweight neural network model is adopted. By optimizing the model structure and lightweight design, including dynamic bottleneck module, sparse attention module and efficient bidirectional feature pyramid module, the recognition accuracy and efficiency of Plasmodium are significantly improved.
It realizes high-precision malaria parasite detection, optimizes the inference time to milliseconds, and is suitable for low resource environments, reducing detection costs and reducing dependence on professionals, especially suitable for areas with scarce medical resources.
Smart Images

Figure CN119919936A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision and deep learning technology, and more specifically, to a real-time detection method for malarial parasites based on a lightweight neural network model. Background Art
[0002] Malaria is a major parasitic disease that threatens global health. The traditional method of malaria detection is to manually examine the malarial parasites in thick or thin blood smears using a microscope. The traditional method has high accuracy, but it relies on experienced parasitologists, is time-consuming and labor-intensive, has low detection efficiency, is difficult to implement on a large scale, and may result in misdiagnosis or missed diagnosis due to differences in working environments and technical limitations.
[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, help them 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, which is of great significance to the prevention and control of malaria.
[0004] For example, a deep learning-based blood smear malarial cell detection system is disclosed in a patent document with publication number "CN116844158A", which includes the following modules: data processing module: using a part of the data samples as a training set and another part of the data samples as a test set; anchor frame clustering module: clustering the data set to generate anchor frames; model training module: using the data set to train the YOLOv5-CoT network; blood smear detection module: the blood smear image enters the trained YOLOv5-CoT network for prediction; in the prior art, the malarial parasite in the blood smear image is detected by the YOLOv5-CoT network, however, the model structure of the scheme is relatively complex and the processing speed is slow, which 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 and other regions with poor infrastructure, and the detection effect is difficult to guarantee; In general, current deep learning models have the following shortcomings in malarial parasite detection: 1) High computing resource requirements: Complex models (such as the YOLOv5-CoT network) require powerful computing power and are difficult to achieve real-time processing in a low-resource environment; 2) Lack of real-time performance: The existing models have a slow processing speed 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; 3) Lack of adaptability: Existing technologies often rely on complex data preprocessing and feature extraction, have poor adaptability, and cannot cope well with differences in diagnostic environments and infrastructures from different regions (such as Africa).
[0005] 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
[0006] In order to overcome the defects of high computing resource requirements and insufficient real-time performance of deep learning models related to malaria detection in the above-mentioned prior art, the present invention provides a real-time detection method for Plasmodium based on a lightweight neural network model. By optimizing the model structure and lightweight design, the accuracy and efficiency of Plasmodium recognition are significantly improved. At the same time, the present invention reduces the model's dependence on hardware and bandwidth, and meets the needs of automated real-time detection of malaria in remote and low-resource areas.
[0007] In order to solve the above technical problems, the technical solution of the present invention is as follows: A real-time detection method for malarial parasites based on a lightweight neural network model comprises the following steps: S1: Obtain blood smear image dataset and perform preprocessing; The blood smear image data set includes a plurality of blood smear images with malarial parasites; S2: Establish a lightweight Plasmodium detection model based on deep learning algorithm; 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 for adaptive lightweight feature extraction of 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 a malarial parasite detection result according to the fused features; S3: inputting the preprocessed blood smear image dataset into the malarial parasite detection model for iterative training to obtain a trained malarial parasite detection model; S4: Obtain a blood smear image to be detected and input it into the trained malarial parasite detection model for detection to obtain a corresponding malarial parasite detection result.
[0008] Preferably, in step S1, the preprocessing includes: Performing denoising on all acquired blood smear images, wherein the denoising includes gamma correction and adaptive contrast enhancement; All blood smear images after denoising were normalized to reduce the impact of illumination and background differences; Performing data enhancement processing on all normalized blood smear images, wherein the data enhancement processing includes: random rotation, random scaling, random cropping and mirror flipping; Labeling each blood smear image after data enhancement; the labels include red blood cells without malarial parasites, malarial parasites in the ring stage, malarial parasites in the trophozoite stage, and malarial parasites in the schizont stage; After labeling is completed, the preprocessed blood smear image dataset is obtained.
[0009] 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 (Spatial Pyramid Pooling –Fast, SPPF) 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.
[0010] Preferably, 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.
[0011] 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; 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, position and confidence score of the malarial parasite.
[0012] 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; 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:
[0013] 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 λ.
[0014] 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:
[0015] in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multi-layer perceptron; represents the average pooling operation; Represents the maximum pooling operation; The feature weights of each channel are multiplied by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as:
[0016] in, It is the feature map updated based on the channel attention mechanism; In the feature map Based on , the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as:
[0017] in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation; The spatial attention weights are combined with the feature map Multiply, expressed as:
[0018] in, It is the feature map after spatial attention processing; For feature maps Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, expressed as:
[0019] in, is the pixel point in the feature map Y ( i , j )’s eigenvalues; is a pixel ( i , j ) corresponding to the spatial attention weight; is the preset dynamic sparse threshold; The feature map Middle pixel ( i , j )’s eigenvalues.
[0020] Preferably, in step S2, the efficient bidirectional feature pyramid module is specifically a BiFPN network.
[0021] 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 reaches a maximum number of iterations, the trained Plasmodium detection model is obtained; The total loss function is expressed as:
[0022] in, is the total loss function value; is the classification loss; To locate the loss; To exclude losses; and are the first and second hyperparameters, respectively; The classification loss Calculated according to the following formula:
[0023] in, is the class weight of Plasmodium, The target category for Plasmodium malariae; is the predicted probability; The positioning loss Calculated according to the following formula:
[0024] in, is the total number of positive sample prediction boxes, which are screened by those whose IoU with the real target box exceeds a certain threshold (such as 0.5); 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; The rejection loss Calculated according to the following formula:
[0025] in, represents an attractor; indicates RepGT loss; RepBox loss; and denote the third and fourth hyperparameters respectively.
[0026] 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.
[0027] Compared with the prior art, the technical solution of the present invention has the following beneficial effects: The present invention provides a real-time malarial parasite detection method based on a lightweight neural network model. First, a blood smear image data set is obtained and preprocessed; then a lightweight malarial parasite detection model is established based on a deep learning algorithm; then the preprocessed blood smear image data set is input into the malarial parasite detection model for iterative training; finally, the trained malarial parasite detection model is used to perform malarial parasite detection on the blood smear image to be detected; The present invention constructs a lightweight detection model based on a deep learning algorithm, which not only realizes 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 life cycle, and the model can accurately identify various forms 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, and is particularly suitable for areas with scarce medical resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] 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.
[0029] Figure 2 Schematic diagram of blood smear images with different labels provided in Example 2.
[0030] Figure 3 This is a structural diagram of the lightweight Plasmodium detection model provided in Example 2.
[0031] Figure 4 This is a structural diagram of the dynamic bottleneck module provided in Example 2.
[0032] Figure 5 This is a PR curve diagram of the trained Plasmodium detection model provided in Example 2.
[0033] Figure 6 This is a schematic diagram of the confusion matrix of the trained Plasmodium detection model provided in Example 2.
[0034] Figure 7 This is a schematic diagram of the normalized confusion matrix of the trained Plasmodium detection model provided in Example 2.
[0035] Figure 8 Schematic diagram of the confusion matrix of the existing YOLOv8n model provided in Example 2. DETAILED DESCRIPTION
[0036] The accompanying drawings are only used for illustrative purposes and are not to be construed as limiting the present application; In order to better illustrate the present embodiment, some parts in the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; It is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.
[0037] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0038] Example 1 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: S1: Obtain blood smear image dataset and perform preprocessing; The blood smear image data set includes a plurality of blood smear images with malarial parasites; S2: Establish a lightweight Plasmodium detection model based on deep learning algorithm; 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 for adaptive lightweight feature extraction of 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 a malarial parasite detection result according to the fused features; S3: inputting the preprocessed blood smear image dataset into the malarial parasite detection model for iterative training to obtain a trained malarial parasite detection model; S4: Obtain a blood smear image to be detected and input it into the trained malarial parasite detection model for detection to obtain a corresponding malarial parasite detection result.
[0039] In the specific implementation process, firstly, a blood smear image data set is obtained and preprocessed; in order to improve the comprehensiveness of model detection, in this embodiment, the obtained data set includes malarial parasite images of the whole life cycle and malarial parasite-free red blood cell images, and each type of image is evenly distributed; Then, a lightweight malarial parasite detection model is established based on a deep learning algorithm. This embodiment provides an efficient deep learning architecture, which combines lightweight design with advanced dynamic modules to significantly improve the detection performance in microscopic inspection tasks. It mainly includes the following components: 1) Backbone network for feature extraction: A lightweight dynamic bottleneck module (Dynamic Bottleneck) is set up: Based on the traditional lightweight convolutional network, the dynamic pruning technology is used to reduce unnecessary channel calculations, further reduce the demand for computing resources, and enhance the feature extraction capability; the dynamic channel pruning technology can reduce the amount of calculation while retaining important feature information, and improve the running efficiency of the model on low-power devices such as embedded systems; Sparse Attention: Introducing a sparse attention module, which focuses on the target area through dynamic sparseness, suppresses background interference, and optimizes computational efficiency. Multi-scale feature extraction: retain the multi-scale structure, extract local to global feature information layer by layer, and provide strong semantic support for subsequent detection; 2) Neck network for feature fusion: Efficient Bi-directional Feature Pyramid (Efficient BiFPN): replaces the traditional unidirectional feature pyramid (FPN), further enhances the perception of small targets through bidirectional information flow and streamlined feature fusion, and optimizes robustness in complex backgrounds; Sparse feature fusion: During the fusion process, unimportant features are sparsely processed to reduce redundant information and retain only the most important features for detection. Through bidirectional feature flow and sparse feature fusion, the detection capability of multi-scale targets is significantly improved without increasing the amount of calculation. At the same time, the model is made more robust in complex backgrounds and adaptable to different lighting conditions and noise environments. Hierarchical fusion strategy: Combining low-level fine-grained features with high-level semantic features, through hierarchical feature integration, while maintaining lightweight, the model's adaptability to multi-scale targets is enhanced, and the target detection effect in complex backgrounds is optimized; 3) Detection head network: Dynamically optimized detection head: The anchor-free detection head is combined with a dynamic weight adjustment mechanism to perform specialized optimization on small target areas (such as malarial ring bodies), significantly improving detection performance. Strengthen small target features: Increase the participation of low-level features and enhance the ability to capture small targets through multiple fusions and dynamic attention mechanisms; In this embodiment, the preprocessed blood smear image dataset is input into the constructed malarial parasite detection model for training. The model uses a lightweight dynamic bottleneck module to extract features layer by layer, and optimizes the computational complexity through dynamic channel pruning; uses a sparse attention mechanism to dynamically focus on important areas, while suppressing background noise, and significantly improving the feature expression of the target area; integrates multi-scale features through a bidirectional feature pyramid and sparse fusion technology to improve adaptability to multi-scale targets; finally outputs the target category, position, and confidence score to optimize the detection performance of small targets (such as annular bodies); Finally, the trained malarial parasite detection model is used to perform real-time malarial parasite detection on the blood smear image to be detected; Compared with existing deep learning models, this method has the following advantages: 1) Significantly improve the accuracy of malarial parasite recognition: malarial parasites and blood cells are relatively small and fixed. Through the specific design of the model structure, the real-time reasoning task of small targets at the cellular level can be carried out; 2) Improve computing efficiency: reduce reliance on high-performance hardware and make the model applicable to areas with limited resources; 3) Achieve efficient real-time detection: Improve the inference speed and meet the real-time detection requirements by optimizing the model structure and lightweight design; 4) Reduce dependence on professionals: Through fully automated model reasoning and high-precision result output, the demand for human expertise is reduced; 5) High detection efficiency, accuracy and adaptability, especially suitable for the automatic diagnosis of malaria in low-resource areas.
[0040] Example 2 This embodiment provides a real-time detection method for Plasmodium based on a lightweight neural network model, comprising the following steps: S1: Obtain blood smear image dataset and perform preprocessing; The blood smear image data set includes a plurality of blood smear images with malarial parasites; S2: Establish a lightweight Plasmodium detection model based on deep learning algorithm; 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 for adaptive lightweight feature extraction of 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 a malarial parasite detection result according to the fused features; S3: inputting the preprocessed blood smear image dataset into the malarial parasite detection model for iterative training to obtain a trained malarial parasite detection model; S4: obtaining a blood smear image to be detected and inputting it into the trained malarial parasite detection model for detection, thereby obtaining a corresponding malarial parasite detection result; Post-processing operations based on non-maximum suppression are performed on the malarial parasite detection results to improve the detection accuracy; In step S1, the preprocessing includes: Performing denoising on all acquired blood smear images, wherein the denoising includes gamma correction and adaptive contrast enhancement; All blood smear images after denoising were normalized to reduce the impact of illumination and background differences; Performing data enhancement processing on all normalized blood smear images, wherein the data enhancement processing includes: random rotation, random scaling, random cropping and mirror flipping; Labeling each blood smear image after data enhancement; the labels include red blood cells without malarial parasites, malarial parasites in the ring stage, malarial parasites in the trophozoite stage, and malarial parasites in the schizont stage; After labeling is completed, the preprocessed blood smear image dataset is obtained.
[0041] 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 features extracted by the first dynamic bottleneck module, the second dynamic bottleneck module and the spatial pyramid pooling module; 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, which are 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; 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; In step S2, the dynamic bottleneck module includes: a 2D convolution layer, a batch normalization 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; 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:
[0042] 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 For channels that are less than or equal to the preset pruning threshold λ, the pruning threshold λ is dynamically adjusted according to computing resources; In step S2, the sparse attention module calculates the feature weight of each channel based on the channel attention mechanism, which is expressed as:
[0043] in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multi-layer perceptron; represents the average pooling operation; Represents the maximum pooling operation; The feature weights of each channel are multiplied by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as:
[0044] in, It is the feature map updated based on the channel attention mechanism; In the feature map Based on , the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as:
[0045] in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation; The spatial attention weights are combined with the feature map Multiply, expressed as:
[0046] in, It is the feature map after spatial attention processing; For feature maps Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, expressed as:
[0047] in, is the pixel point in the feature map Y ( i , j )’s eigenvalues; is a pixel ( i , j ) corresponding to the spatial attention weight; is the preset dynamic sparse threshold; The feature map Middle pixel ( i , j )’s eigenvalues; In step S2, the efficient bidirectional feature pyramid module is specifically a BiFPN network; In the 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 reaches a maximum number of iterations, the trained Plasmodium detection model is obtained; The total loss function is expressed as:
[0048] in, is the total loss function value; is the classification loss; To locate the loss; To exclude losses; and are the first and second hyperparameters, respectively; The classification loss Calculated according to the following formula:
[0049] in, is the class weight of Plasmodium, The target category for Plasmodium malariae; is the predicted probability; The positioning loss Calculated according to the following formula:
[0050] in, is the total number of positive sample prediction boxes, which are screened by those whose IoU with the real target box exceeds a certain threshold (such as 0.5); 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; The rejection loss Calculated according to the following formula:
[0051] in, represents an attractor; indicates RepGT loss; RepBox loss; and denote the third and fourth hyperparameters respectively.
[0052] In the specific implementation process, this embodiment first uses malaria samples provided by a certain unit, collects images through a microscope, 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 the clarity and details of the image; in the image acquisition process, a high-resolution digital microscope and an automatic focusing system are combined to ensure that clear cell images without stacking are captured; the number of cells in each image is controlled between 325 and 350 to ensure the representativeness of the sample; 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 history of malarial parasites in the human body. Figure 2 As shown; Then, the collected data set is preprocessed by denoising, contrast enhancement, and standardization to ensure the image quality of the model input. 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. 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, and an efficient and lightweight network is redesigned for the identification 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; The model in this embodiment mainly includes the following parts: 1) Backbone network: This embodiment adopts a dynamically optimized backbone network and uses a Dynamic Bottleneck module to replace the traditional convolution unit. The module optimizes channel calculations through dynamic pruning, reduces redundant calculations and retains key features. Specifically, Dynamic Bottleneck determines which channels can be pruned by evaluating the importance of each channel, thereby significantly reducing the computational complexity while ensuring the quality of feature extraction. This design is particularly suitable for processing high-resolution microscope images, and can efficiently extract multi-scale features while reducing computational overhead. like Figure 4 As shown in the figure, the dynamic bottleneck module reduces unnecessary calculations through pruning optimization strategies while retaining important features, which is 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, which is expressed as:
[0053] 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 For channels that are less than or equal to the preset pruning threshold λ, the pruning threshold λ is dynamically adjusted according to the computing resources; after the introduction of the dynamic bottleneck module, the model is more lightweight, which can reduce the participation of more than 50% of unimportant channels and reduce the 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; Introducing Sparse Attention: In this embodiment, a sparse attention mechanism is introduced in the deep feature extraction process of the backbone network; by dynamically sparse processing of unimportant features, the model can more effectively focus on the key areas of malarial parasites 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 detection accuracy of malarial parasites; The sparse attention module calculates the feature weights of each channel based on the channel attention mechanism, which is expressed as:
[0054] in, The original feature map input for channel c; is the feature weight of channel c; Represents the Sigmoid activation function; represents a multi-layer perceptron; represents the average pooling operation; Represents the maximum pooling operation; The feature weights of each channel are multiplied by the original feature map to highlight the features of important channels and suppress the features of unimportant channels, which can be expressed as:
[0055] in, It is the feature map updated based on the channel attention mechanism; In the feature map Based on , the spatial attention weight is calculated based on the spatial attention to enhance the key area feature representation, which is expressed as:
[0056] in, is the spatial attention weight, It is a two-dimensional convolution operation; Represents feature concatenation operation; The spatial attention weights are combined with the feature map Multiply, expressed as:
[0057] in, It is the feature map after spatial attention processing; In addition, this embodiment also introduces a dynamic sparseness mechanism in the sparse attention module to sparse out low-weight areas in the spatial dimension, effectively reducing computational redundancy by eliminating feature areas with low attention weights. Specifically, for the feature map Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, expressed as:
[0058] 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 to the spatial attention weight; is the preset dynamic sparse threshold; The feature map Middle pixel (i , j )’s eigenvalues; Multi-scale feature extraction: The backbone network in this embodiment adopts a hierarchical design, and gradually extracts 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. 2) Neck network: Efficient Bi-directional Feature Pyramid (Efficient BiFPN): This embodiment adopts an efficient BiFPN design in the feature fusion module to replace the traditional PANet. BiFPN significantly enhances the efficiency of feature fusion by introducing a bidirectional feature flow mechanism, and is particularly suitable for the detection of small targets (such as malarial parasite rings). The BiFPN network is provided with an uplink path and a downlink path, and the small target capture capability is enhanced through feature upsampling and downsampling mechanisms. The module integrates high-level semantic information with low-level fine-grained features, and improves the recognition capability of different stages of the malarial parasite life cycle (such as rings, trophozoites, and schizonts). Compared with the traditional FPN, the computational overhead is reduced, the detection accuracy of small targets is optimized, and the fusion efficiency of multi-scale features is improved. Hierarchical Feature Integration: In 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 improves the feature fusion speed, thereby optimizing the utilization of computing resources; Lightweight Optimization: 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. 3) Detection head network: Lightweight detection head: This embodiment uses an Anchor-Free (no anchor box) detection head to simplify the target positioning process and reduce the computational overhead of anchor box generation and matching; In addition, in order to further improve the detection effect, this embodiment can also use 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, and optimize the detection ability of small target (such as malarial ring body) area; this mechanism is particularly suitable for malarial parasites with small characteristic sizes, and enhances the model's detection ability for small targets; The detection head network further improves the detection performance of small targets by increasing the participation ratio of low-level features; combined with efficient feature fusion technology, the model can more accurately locate and detect tiny targets such as malarial parasites; At the same time, the detection head focuses on optimizing the inference speed, which improves the response speed of the model in real-time detection by reducing unnecessary calculations. This enables the model to provide feedback quickly in an environment with a large diagnostic workload, meeting the needs of real-time diagnosis. After the model is built, the preprocessed blood smear image data set is input into the malarial parasite detection model for iterative training to obtain a trained malarial parasite detection model; In this embodiment, the data set is divided into a training set and a validation set in a ratio of 7:3, of which 70% is used for model training and the remaining 30% is used to verify the model performance; during the division process, it is ensured that the distribution of samples of each category is balanced to enhance the generalization ability of the model; 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:
[0059] 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:
[0060] in, and are the first-order and second-order moment estimates of the gradient, respectively; For the detection task of thin blood smear images, this embodiment uses Repulsion Loss as the core loss function, and combines classification loss and positioning loss to optimize the model's detection performance for red blood cells and malarial parasites; In this embodiment, the total loss function is expressed as:
[0061] in, is the total loss function value; is the classification loss; To locate the loss; To exclude losses; and are the first and second hyperparameters, respectively; Classification Loss Calculated according to the following formula:
[0062] in, is the class weight of Plasmodium, The target category for Plasmodium malariae; is the predicted probability; Positioning loss Calculated according to the following formula:
[0063] in, is the total number of positive sample prediction boxes, which are screened by those whose IoU with the real target box exceeds a certain threshold (such as 0.5); 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; The rejection loss Calculated according to the following formula:
[0064] in, represents an attractor; indicates RepGT loss; RepBox loss; and denote the third and fourth hyperparameters respectively; Furthermore, the attraction :
[0065] RepGT loss:
[0066] RepBox Loss:
[0067] When the value of the total loss function is less than or equal to a preset threshold or reaches the maximum number of iterations, a trained malarial parasite detection model is obtained; finally, the blood smear image to be detected is input into the trained malarial parasite detection model for detection, and the corresponding malarial parasite detection result is obtained to complete the detection; in addition, this embodiment also performs a post-processing operation based on non-maximum suppression on the malarial parasite detection result to further improve the detection accuracy; 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 shows 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 problem of class imbalance in the data set, this method cannot be applied to clinical evaluation. Therefore, the recall rate of the malarial parasite category is introduced, that is, the ratio of the total number of samples successfully identified as the three categories of malarial parasites (i.e., excluding those identified as background and red blood cells) to the total number of actual malarial parasite samples in the confusion matrix; Figure 5 and Figure 6 As shown; Figure 5 is the relationship between the recall rate and 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 This is a diagram of the confusion matrix (actual values) of the trained model; In the performance evaluation, this embodiment also uses a 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 accuracy and recall 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); In addition, the inference time of the model in this embodiment on a low-power device is about 0.187 seconds per image, 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 and other regions; 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 can adapt 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 life cycle, and the model can accurately identify various forms and life cycle stages of malarial parasites, thereby improving the comprehensiveness of detection; in addition, this method reduces the cost of malarial parasite detection, and the automated malaria detection model greatly reduces dependence on experts and reduces diagnostic costs, and is particularly suitable for areas with scarce medical resources.
[0068] The same or similar reference numerals correspond to the same or similar components; The terms used to describe the positional relationship in the drawings are only used for illustrative purposes and should not be construed as limiting the present application; Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A real-time detection method for malarial parasites based on a lightweight neural network model, characterized in that: The following steps are involved: S1: Obtain blood smear image dataset and perform preprocessing; The blood smear image data set includes a plurality of blood smear images with malarial parasites; S2: Establish a lightweight Plasmodium detection model based on deep learning algorithm; 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 for adaptive lightweight feature extraction of 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 a malarial parasite detection result according to the fused features; S3: inputting the preprocessed blood smear image dataset into the malarial parasite detection model for iterative training to obtain a trained malarial parasite detection model; S4: Obtain a blood smear image to be detected and input it into the trained malarial parasite detection model for detection to obtain a corresponding malarial parasite detection result.
2. A method for real-time detection of malarial parasites based on a lightweight neural network model according to claim 1, characterized in that: In step S1, the preprocessing includes: Performing denoising on all acquired blood smear images, wherein the denoising includes gamma correction and adaptive contrast enhancement; All blood smear images after denoising were normalized to reduce the impact of illumination and background differences; Performing data enhancement processing on all normalized blood smear images, wherein the data enhancement processing includes: random rotation, random scaling, random cropping and mirror flipping; Labeling each blood smear image after data enhancement; the labels include red blood cells without malarial parasites, malarial parasites in the ring stage, malarial parasites in the trophozoite stage, and malarial parasites in the schizont stage; After labeling is completed, the preprocessed blood smear image dataset is obtained.
3. A real-time detection method for 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. A method for real-time detection of malarial parasites based on a lightweight neural network model according to claim 3, characterized in that: In the 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. A method for real-time detection of malarial parasites 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, position and confidence score of the malarial parasite.
6. A real-time detection method for Plasmodium based on a lightweight neural network model according to any one of claims 1 to 5, characterized in that: In step S2, the dynamic bottleneck module includes: a 2D convolution layer, a batch normalization 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; 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 λ.
7. A real-time detection method for 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 multi-layer perceptron; represents the average pooling operation; Represents the maximum pooling operation; The feature weights of each channel are multiplied 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 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; The spatial attention weights are combined with the feature map Multiply, expressed as: in, It is the feature map after spatial attention processing; For feature maps Perform dynamic sparsification to obtain the feature map Y output by the sparse attention module, expressed as: in, is the pixel point in the feature map Y ( i , j )’s eigenvalues; is a pixel ( i , j ) corresponding to the spatial attention weight; is the preset dynamic sparse threshold; The feature map Middle pixel ( i , j )’s eigenvalues.
8. A real-time detection method for Plasmodium based on a lightweight neural network model according to any one of claims 1 to 5, characterized in that: In the step S2, the efficient bidirectional feature pyramid module is specifically a BiFPN network.
9. The method for real-time detection of malarial parasites based on a lightweight neural network model according to claim 1, characterized in that: In the 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 reaches a maximum number of iterations, 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; To locate the loss; To exclude losses; and are the first and second hyperparameters, respectively; The classification loss Calculated according to the following formula: in, is the class weight of Plasmodium, The target category for Plasmodium malariae; 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 denote the third and fourth hyperparameters respectively.
10. The method for real-time detection of malarial parasites based on a lightweight neural network model according to claim 1, characterized in that: The step S4 also 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
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
Asphalt pavement disease detection method based on YOLOv8n model
CN118247636A
Lightweight parking detection method based on multi-scale attention mechanism
CN119314141A
Cited By
Malaria pathogen detection system based on improved YOLO algorithm
CN120376009A
Rapid detection equipment for cordyceps sinensis
CN120385668A
Plasmodium infection stage detection method and system
CN121033053A