A method for detecting parasite eggs based on improved YOLOv8s

By improving the YOLOv8s model and combining lightweight convolution and attention mechanisms, LCN-YOLOv8 was designed, which solved the problems of high computational complexity and low accuracy in the detection of parasite eggs in microscopic images, and achieved efficient and accurate detection of parasite eggs.

CN119942533BActive Publication Date: 2025-11-14JIANGNAN UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411939328.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-11-14
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

Existing deep learning models suffer from high computational complexity, large number of parameters, and low detection accuracy in the detection of parasite eggs in microscopic images. They are particularly ineffective in detecting dense or occluded eggs and are difficult to run efficiently on mobile devices.

Method used

Using YOLOv8s as the baseline model, a new object detection model, LCN-YOLOv8, is designed by combining lightweight convolution, attention mechanism and efficient neck network. The conventional convolution is replaced by PA-C2f module, the SEAM attention module is introduced, and the SPDConv and LHSFPN modules are used to optimize feature extraction and fusion, thereby reducing computational complexity and improving detection accuracy.

Benefits of technology

It achieves efficient parasite egg microscopic image detection under resource-constrained conditions, improves the detection effect of dense eggs and occluded eggs, reduces model complexity and number of parameters, and improves detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119942533B_ABST
    Figure CN119942533B_ABST
Patent Text Reader

Abstract

This invention discloses a parasite egg detection method based on an improved YOLOv8s, belonging to the field of image processing technology. The method includes: using YOLOv8s as the baseline network, designing a lightweight object detection model, LCN-YOLOv8 algorithm, by fusing lightweight convolution, attention mechanisms, and an efficient neck network to achieve efficient detection of parasite eggs in complex situations; improving the model's feature extraction capability by using the PA-C2f module while reducing computational load and memory access; reducing fine-grained feature loss of parasite eggs during feature extraction by the SPDConv module; and enhancing the model's multi-scale feature fusion capability by using an improved HSFPN module. By combining the above modules, the model's detection capability is improved in cases of background occlusion, small parasite eggs, and low resolution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for detecting parasite eggs based on an improved YOLOv8s, belonging to the field of image processing technology. Background Technology

[0002] Parasitic infections are a significant public health problem worldwide. Protozoan, worm, and ectoparasite eggs reside in the human body, continuously absorbing nutrients and leading to malnutrition and anemia, particularly hindering growth and development in children. Traditional optical microscopy is the gold standard for diagnosing parasitic diseases. By visually observing the morphology and structure of parasites and their impact on host tissues, and comparing them with known parasite morphologies, the type of parasite can be identified and the severity of the infection assessed. However, microscopic parasite identification and quantitative analysis are highly challenging, requiring significant time and manpower, demanding highly skilled researchers, and resulting in substantial waste of time and resources.

[0003] With the rapid development of computing power and deep learning, artificial intelligence technology has been successfully applied in natural language processing, facial recognition, biomedical analysis, and other applications. Traditional machine learning algorithms for identifying parasite egg microscopic images require manual feature selection, resulting in low processing efficiency. However, deep learning-based target detection methods can automatically extract egg features from large amounts of image data, quickly completing tasks such as classification, detection, and counting. This significantly improves the speed and accuracy of parasite egg microscopic image recognition, providing timely and accurate information to inspectors, alleviating the workload of microscopic personnel, and reducing inspection costs.

[0004] Currently, numerous deep learning-based methods for detecting parasite microscopic images have emerged. Wan et al. proposed C2BNet, a coupled composite backbone network with a dual-path structure, in "C2BNet: deep learning architecture with coupled composite backbone for parasitic egg detection in microscopic images[J].IEEE Journal of Biomedical and HealthInformatics,2023,15(02):1-13." for automatic detection of parasite egg microscopic images. By learning object features from different perspectives through model heterogeneity, the feature representation ability between different paths of the backbone is enhanced. At the same time, a multi-scale weighted box fusion module is proposed to fuse the position and confidence scores of all bounding boxes. The average detection accuracy on the Chula-Parasite-Egg dataset reaches 94.56%. Nouar et al., in "Parasitic egg recognition using convolution and attention network[J]. Scientific reports,2023,13:14475.", proposed the CoAt Net model using convolutional neural networks and attention modules to detect parasite microscopic images in the Chula-Parasite-Egg dataset, achieving an average accuracy and F1 score of 93%. Graciela et al., in "FiCRoN, a deep learning-based algorithm for the automatic determination of intracellular parasite burden from fluorescence microscopy images[J]. Medical Image Analysis,2024,91:103036.", proposed a FiCRoN model based on a fully convolutional regression network for detecting intracellular parasites. This model uses small-scale feature maps to detect intracellular parasites and large-scale feature maps to detect host cells, achieving an average accuracy of 96%.

[0005] With the widespread application of object detection models in industrial settings, model deployment has become increasingly critical. The pursuit of a balance between model detection efficiency and accuracy has become a research hotspot in deep learning models. Several efficient lightweight models and lightweight convolutions have been proposed and proven to be successfully applied in object detection models. Di et al., in "AMMNet: a multimodal medical image fusion method based on an attention mechanism and MobileNetV3[J]. Biomedical Signal Processing and Control, 2024, 96:106561.", proposed the concept of depthwise separable convolution. By decomposing ordinary convolution into depthwise convolution and pointwise convolution, the number of model parameters is reduced. Furthermore, the introduction of inverse residual structures and linear bottlenecks reduces information loss while better utilizing limited computational resources. In "Improved ShuffleNetv2 network with attention for speech emotion recognition[J]. Information Sciences, 2025, 689: 121488.", CP Udeh et al. proposed using grouped convolutions for feature extraction and reducing the number of parameters. Channel shuffling was used to shuffle the channels of the resulting feature maps, promoting the exchange of feature information between different groups. Mercedes et al., in "Ghost Net for hyperspectral image classification[J]. IEEE Transactions on Geoscience and Remote Sensing, 2021, 59(12): 10378-10393.", first used ordinary convolutions to generate a small number of original images, and then generated phantom feature maps through simple linear operations, reducing computation and parameter count while efficiently extracting features. To address the feature redundancy problem of ordinary convolution, Chen et al., in their paper "Real-time detection of mature table grapes using ESP-YOLO network on embedded platforms[J].Biosystems Engineering,2024,246:122-134.", utilized regular convolution for feature extraction on some input channels while keeping other channels unchanged, followed by pointwise convolution to fully utilize channel information and reduce computational redundancy and memory access.

[0006] While the methods described above utilize deep learning models for automatic detection of parasite microscopic images, they still suffer from numerous false negatives and missed detections due to issues such as the small size of parasite eggs, complex background occlusion of eggs, and low resolution of densely packed parasites. This necessitates significant time-consuming verification by personnel. Although most improved models enhance detection accuracy, these improvements often increase the number of model parameters, leading to a heavier computational burden and hindering deployment on mobile devices. Some lightweight improvements, while reducing the number of model parameters, also result in decreased detection accuracy, highlighting the difficulty in achieving a good balance between model complexity and detection precision. Summary of the Invention

[0007] To address the problems existing in the prior art, this invention uses YOLOv8s as the baseline model and combines lightweight convolution, attention mechanism and efficient neck network to design a new target detection model LCN-YOLOv8 for efficient detection of parasite egg microscopic images. This not only significantly reduces the computational complexity and number of parameters of the model, enabling it to run efficiently under resource constraints, but also improves the detection accuracy of the model, providing better detection results for dense parasite eggs and occluded parasite eggs.

[0008] A method for detecting parasite eggs based on an improved YOLOv8s method, comprising:

[0009] Step 1: Construct a parasite egg dataset and divide it into training, validation, and test sets;

[0010] Step 2: Combining lightweight convolution, attention mechanism, and efficient neck network, a new object detection model LCN-YOLOv8 is designed, which includes three parts: backbone feature extraction network, neck feature fusion network, and head detection head.

[0011] Step 3: Design a new feature extraction module PA-C2f, using partial convolution (Patial Conv, PConv) instead of regular convolution to reduce computation and memory access, and introduce a Separated and Enhancement Attention Module (SEAM) to ensure the model's efficient feature extraction capability;

[0012] Step 4: Introduce the Space-to-depth Conv (SPDConv) module to replace all conventional convolutional modules other than PA-C2f in the model. This reduces the loss of fine-grained features during feature extraction, improves the detection capability of dense eggs and low-resolution eggs in multi-egg images, and reduces model complexity.

[0013] Step 5: Design the LHSFPN (Lightweight High-level Screening-feature FusionPyramid Network) module as the neck network for efficient feature fusion, reduce the number of model parameters while increasing the model's multi-scale feature fusion capability, and improve the detection accuracy of occluded insect eggs;

[0014] Step 6: Train the LCN-YOLOv8 network using the training set constructed in Step 1, introduce the total loss function L to constrain the training process of the model, and use Mosaic and Mixup techniques to augment the data and expand the samples.

[0015] Step 7: Use the validation set built in Step 1 to evaluate the model's performance during training, adjust the model's hyperparameters, and train for a total of 300 rounds. If the model's performance does not improve for 50 consecutive rounds, stop training early to save the best model.

[0016] Step 8: Use the test set images constructed in Step 1 to input the best model saved in Step 7 for testing, obtain the visual detection results of parasite egg microscopic images, and automatically count the number of eggs of different types of parasites.

[0017] Optionally, step 1 includes:

[0018] 1a) Collect microscopic images of parasite eggs;

[0019] 2a) Under the guidance of experts, the collected parasite egg images were labeled and divided into single-egg and multi-egg datasets according to the number of parasite egg species in the images.

[0020] 3a) Divide the single-egg dataset and the multi-egg dataset into training set, validation set and test set respectively according to the ratio of 7:2:1.

[0021] Optionally, in step 3, the PA-C2f module uses PA Block instead of the Bottleneck structure in C2f for feature extraction, and concatenates the features from different branches to enrich the expressive power of the features. Compared with the original Bottleneck, PA Block uses PConv for efficient feature extraction and introduces the SEAM attention module, which helps the model distinguish between insect eggs and backgrounds with similar colors. This reduces the number of model parameters and computational cost, while improving the model's feature extraction capability and enhancing the model's detection performance of densely packed insect eggs in complex backgrounds.

[0022] Optionally, the PA Block first uses a 3×3 PConv layer for efficient feature extraction, reducing the extra computation caused by feature redundancy. Following the PConv layer are two 1×1 PWConv layers, fully utilizing the unprocessed channel information in the PConv layer to concentrate the receptive field in the center. Finally, after a shortcut operation with the input features, the SEAM module is used to make the model focus more on insect features in complex backgrounds, reducing interference from other features and improving the model's ability to detect occluded insects.

[0023] Optionally, PConv and the two PWConvs are presented as an inverted residual structure, with the middle PWConv expanding the number of channels in the feature map. Since excessive use of normalization and activation functions can limit feature diversity, reduce model computation speed, and impair computational performance, PA Block only uses a BN layer and ReLU activation function after the middle PWConv to ensure feature diversity and lower latency.

[0024] Optionally, SPDConv in step 4 is divided into two parts: a spatial-to-depth layer and a non-span convolutional layer. First, the spatial-to-depth layer performs interval sampling on the input feature map of size H×W×C to obtain 4 feature maps of size H×W×C. The sub-feature maps are then concatenated along the channel dimension to obtain a size of [size missing]. The feature map is then processed by a 1×1 non-span convolutional layer to reduce dimensionality, preserving as much discriminative feature information as possible, ultimately yielding a feature map of size [size missing]. The feature map is obtained through multiple SPDConv modules, which can extract more abstract and richer feature information. Compared with conventional convolution operations, it has a higher information retention rate and is more suitable for complex tasks such as detecting low-resolution insect eggs and small-pixel insect eggs.

[0025] Optionally, the LHSFPN in step 5 consists of two parts: a feature selection module and a feature fusion module. First, feature maps of different scales extracted by the backbone network are filtered using the SEAM attention module in the feature selection module to highlight important features of the insect eggs. The feature selection module uses SEAM attention for feature filtering, making the model focus more on the shape, edges, and other features of the insect eggs, weakening the influence of background and other impurities on the eggs, and using the lighter and more efficient SPDConv to adjust the number of channels. Subsequently, the LHSFPN uses the Selective Feature Fusion (SFF) module to fuse high-level and low-level information from the feature maps, generating a high-level feature map F containing rich semantic information. high ∈R C×H×W and low-level feature maps It helps detect small-pixel insect eggs and insect eggs occluded by the background, and improves the model's multi-scale feature fusion capability.

[0026] Optionally, given a high-level feature map F high ∈R C×H×W and low-level feature maps The SFF module first expands the high-level feature map using a transposed convolution with a stride of 2 and a kernel size of 3×3, resulting in a map of size F. high ∈R C×2H×2W The feature maps are then analyzed. To unify the dimensions of the high-level and low-level feature maps, bilinear interpolation is used to upsample or downsample the high-level feature map, resulting in a new feature map.

[0027] F att =BL(TConv(F high ))

[0028] In the formula, BL is the bilinear interpolation operation and TConv is the transpose convolution operation.

[0029] Subsequently, the SEAM module converts the high-level feature maps into corresponding attention weights, resulting in features with consistent dimensionality. The low-level feature maps are then filtered. Finally, the filtered low-level feature maps are fused with the sampled high-level feature maps to enhance the model's feature representation, yielding the final output.

[0030]

[0031] In the formula, SEAM represents the weight of the SEAM module. This indicates the dot product operation.

[0032] The beneficial effects of this invention are:

[0033] (1) This invention uses YOLOv8s as the baseline network, integrates lightweight convolution, attention mechanism, and efficient neck network to design a lightweight target detection model LCN-YOLOv8 algorithm for efficient detection of parasite egg microscopic images, reducing the cost of manual microscopic examination; compared with other target detection networks, it has more efficient feature extraction capabilities and fewer parameters, and has better performance in complex situations such as background occlusion, small insect eggs, and low resolution.

[0034] (2) The present invention designs a new feature extraction module PA-C2f to replace the C2f module for extracting rich features of parasite eggs, uses partial convolution to replace conventional convolution to reduce computation and memory access, and introduces a separation-enhanced attention module to improve the model’s efficient feature extraction capability.

[0035] (3) This invention introduces SPDConv to replace conventional convolution, which reduces the loss of fine-grained information of small-pixel insect eggs and low-resolution insect eggs during feature extraction, especially during downsampling, enhances the model's ability to process spatial information, facilitates the differentiation of individual insect eggs in dense insect eggs and complex backgrounds, and improves the detection accuracy of low-resolution insect eggs.

[0036] (4) The present invention designs the LHSFPN module to replace PANet as the neck network, which increases the multi-scale feature fusion capability of the model. While reducing the complexity of the model, it captures the features of insect eggs of different sizes more comprehensively. The SEAM attention module is added to improve the detection accuracy of occluded insect eggs. Attached Figure Description

[0037] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 The overall flowchart of the parasite egg detection method based on the improved YOLOv8s provided in Embodiment 1 of the present invention is shown below.

[0039] Figure 2 This is a diagram showing the overall structure of the LCN-YOLOv8 model constructed based on the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention.

[0040] Figure 3 This is a diagram of the PA-C2f structure in the LCN-YOLOv8 model based on the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention.

[0041] Figure 4 The PConv module structure diagram in the LCN-YOLOv8 model based on the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention is shown below.

[0042] Figure 5 This is a schematic diagram of the SEAM module in the LCN-YOLOv8 model based on the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention.

[0043] Figure 6 This is a schematic diagram of the SPDConv module in the LCN-YOLOv8 model based on the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention.

[0044] Figure 7This is a schematic diagram of the LHSFPN module in the LCN-YOLOv8 model based on the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention.

[0045] Figure 8 This is a visualization of the detection results obtained by the improved YOLOv8s parasite egg detection method provided in Embodiment 2 of the present invention. Detailed Implementation

[0046] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0047] Example 1

[0048] This embodiment provides a method for detecting parasite eggs based on an improved YOLOv8s method. See [link to relevant documentation]. Figure 1 The method includes:

[0049] Step 1: Under the guidance of experts, the collected parasite egg microscopic images were manually labeled. The datasets were divided into two types according to the number of parasite egg species in the images: single parasite eggs and multiple parasite eggs. The training set, validation set and test set were then divided in a 7:2:1 ratio.

[0050] Step 2: Select the YOLOv8s model as the baseline network, integrate lightweight convolution, attention module and efficient neck network to build the target detection model LCN-YOLOv8 with fewer parameters and stronger feature extraction capability, for fast and accurate detection of parasite eggs.

[0051] Step 3: Design the PA-C2f module to replace the C2f module for efficient feature extraction; and introduce the SEAM attention module to ensure the model's efficient feature extraction capability.

[0052] PA-C2f uses PA Block instead of the Bottleneck structure in C2f for feature extraction and concatenates features from different branches to reduce redundant feature maps and additional computational overhead. The SEAM attention module enables the model to focus more on the features of the insect body in complex backgrounds, reducing interference from other features and helping the model distinguish between insect eggs and backgrounds with similar colors. This reduces the number of model parameters and computational cost while improving the model's feature extraction capability and enhancing the model's detection performance of dense insect eggs in complex backgrounds.

[0053] Step 4: Replace all conventional convolutional modules other than PA-C2f in the model with the SPDConv module to reduce the loss of fine-grained information of low-resolution eggs during feature extraction, especially during downsampling, improve the detection capability of dense eggs and low-resolution eggs in multi-egg images, and reduce model complexity.

[0054] The SPDConv module is divided into two parts: a spatial-to-depth layer and a non-span convolutional layer. The spatial-to-depth layer samples the input feature map at intervals and concatenates the sampled feature maps along the channel dimension. The non-span convolutional layer performs dimensionality reduction through non-span convolution, retaining the information of the discriminative features to obtain the final feature map.

[0055] Step 5: Design LHSFPN as the neck network to reduce model complexity while capturing features of eggs of different sizes more comprehensively and completing feature fusion more efficiently.

[0056] The LHSFPN module comprises a feature selection module and a feature fusion module. First, the feature selection module uses SEAM attention for feature filtering, enabling the model to focus more on features such as the shape and edges of the eggs, while minimizing the influence of background and other impurities. Then, the selective feature fusion mechanism fuses high-level and low-level information from the feature map, generating a feature map with rich semantic content. This helps detect small-pixel eggs and eggs occluded by the background, improving the model's multi-scale feature fusion capability.

[0057] Step 6: Train the LCN-YOLOv8 model, introduce the total loss function L to constrain the training process, and use Mosaic and Mixup techniques to augment the data and expand the samples.

[0058] If the model performance does not improve after 50 consecutive rounds, training should be stopped early to save training time, and Mosaic and Mixup techniques should be used to augment the data and expand the sample.

[0059] Step 7: Use the validation set to evaluate the model's performance during training, adjust the model's hyperparameters, and train for a total of 300 rounds. If the model's performance does not improve for 50 consecutive rounds, stop training early to save the best model.

[0060] Step 8: Input the microscopic images of parasite eggs from the test set into the saved best model for testing, and obtain the visual detection results of parasite eggs.

[0061] Example 2

[0062] This embodiment provides a method for detecting parasite eggs based on an improved YOLOv8s, including:

[0063] First, YOLOv8s was selected as the baseline network. PA-C2f and LHSFPN were designed for efficient feature extraction and fusion. PConv and SPDConv were introduced to reduce the number of model parameters and complexity. A lightweight object detection model, LCN-YOLOv8, was constructed for efficient detection of parasite egg microscopic images. Then, a self-made parasite egg microscopic image dataset was created. Images from the training set were input into LCN-YOLOv8 for training, and the network parameters were optimized using the validation set. Finally, the best model weights were saved, and the visualization detection results of parasite egg images in the test set were obtained.

[0064] Step 1: Create a dataset by manually annotating the collected parasite egg microscopic images and dividing them into training, validation, and test sets. The specific content of the dataset is as follows:

[0065] 1a) Collect several microscopic images of human parasite eggs from a medical college, and use LambelImg software to create labels under the guidance of experts to construct a dataset of human parasite microscopic images.

[0066] 1b) The dataset is divided into two parts based on the number of insect egg species in the images: single-egg and multi-egg. The single-egg dataset contains 852 images, and the multi-egg dataset contains 465 images. The single-egg dataset and the multi-egg dataset are divided into training set, validation set and test set in a ratio of 7:2:1.

[0067] 1c) The single-egg dataset has a high magnification, and the number of eggs in each image is relatively small, making identification easier; the multi-egg dataset has a large number of eggs that are densely packed, and the individual egg pixels are small and the resolution is low. In some images, complex backgrounds may obscure the eggs, resulting in the loss of some feature information, making detection more difficult.

[0068] Step 2: Select the YOLOv8s model as the baseline network and improve it to design a lightweight object detection model LCN-YOLOv8 with efficient feature extraction and feature fusion. Figure 2 This is a diagram showing the overall structure of the LCN-YOLOv8 model in this invention. Its overall structure consists of three parts: the backbone feature extraction network, the neck feature fusion network, and the head detection network. The specific structure is as follows:

[0069] 2a) Backbone uses the lightweight module PA-C2f for efficient feature extraction. By concatenating features from different branches, richer gradient information can be obtained, which enriches the expressive power of features and improves the model's detection capability in complex situations.

[0070] 2b) The Neck part uses LHSFPN as the neck network to achieve full fusion between feature maps of different sizes, which reduces the complexity of the model and captures the features of eggs of different sizes more comprehensively.

[0071] 2c) The Head section completes the regression and classification tasks, and detects large, medium and small insect eggs on three different size maps of 13×13, 26×26 and 52×52 respectively.

[0072] Step 3: Replace the regular convolutions in C2f with PConv to design a lightweight and efficient feature extraction module, PA-C2f, and introduce a SEAM attention module. This helps the model distinguish insect eggs from backgrounds of similar color, reducing the number of parameters and computational cost while improving the model's feature extraction capabilities and enhancing its detection performance for densely packed insect eggs in complex backgrounds. The structure diagram of the PA-C2f module and its sub-module PA Block is shown below. Figure 3 As shown, Figure 3 (a) in the diagram is the structure diagram of the PA-C2f module. Figure 3 (b) is the structural diagram of the PA Block submodule of the PA-C2f module; the specific methods include:

[0073] 3a) In the PA Block, 3×3 PConv is first used for efficient feature extraction, reducing the extra computation caused by a large amount of feature redundancy. Figure 4 (a) in the diagram is the PConv structure diagram. Figure 4 (b) in the diagram represents a conventional convolutional structure; PConv selectively applies conventional convolutions only to a subset of input channels for spatial feature extraction, leaving the remaining channels unprocessed. PConv converts the first or last consecutive channel c... p The calculation is performed as a whole feature map, therefore the floating-point number of PConv is:

[0074] FLOPs = h × w × k 2 ×c p 2

[0075] Where h and w are the height and width of the feature map, respectively, and k is the kernel size. If the number of channels in a conventional convolution process is c, then in a typical channel ratio... In this case, PConv's FLOPs are those of regular convolutions.

[0076] 3b) Following PConv are two PWConv layers with a kernel size of 1×1, which fully utilize the unprocessed channel information in PConv to concentrate the receptive field in the middle. For example... Figure 3As shown in (b), PConv and the two PWConvs present an inverted residual structure, with the middle PWConv expanding the number of channels in the feature map. Furthermore, since excessive use of normalization and activation functions can limit feature diversity, reduce model computation speed, and impair computational performance, PA Block only uses a BN layer and ReLU activation function after the middle PWConv to ensure feature diversity and lower latency.

[0077] 3c) Finally, after performing a shortcut operation on the input features, the SEAM module is used to make the model focus more on the insect features in complex backgrounds, reduce interference from other features, and improve the model's ability to detect occluded insects. The structure of the SEAM module is as follows: Figure 5 As shown, Figure 5 (a) in the diagram is the structure diagram of SEAM. Figure 5 (b) shows the structure of the CSMM. The first part is the Channel and Spatial Mixing Module (CSMM) with residual connections. It uses depthwise separable convolutions for channel-wise convolutions to learn the importance of different channels and reduce model parameters. To compensate for information loss between channels, pointwise convolutions are used to combine the outputs of the depthwise convolutions. Then, SEAM uses a two-layer fully connected network to aggregate the channel information extracted from CSMM modules of different patch sizes, enhancing the connectivity between channels and using the information relationship between occluded and unoccluded eggs to compensate for the information loss caused by background occlusion. The output weights learned by the fully connected layers are exponentially transformed to expand the value range from [0,1] to [1,e], which can reduce the positional error of the results and improve the robustness of the model when dealing with occluded eggs.

[0078] Step 4: LCN-YOLOv8 replaces all conventional convolutional modules except PA-C2f in the model with the SPDConv module, reducing the loss of fine-grained information of small-pixel and low-resolution insect eggs during feature extraction, especially during downsampling. The SPDConv module enhances the model's ability to process spatial information, making it easier to distinguish individual insect eggs in dense insect egg formations and complex backgrounds. Its structure is as follows: Figure 6 As shown. Specific methods include:

[0079] 4a) SPDConv consists of two parts: a spatial-to-depth layer and a non-span convolutional layer. First, the input feature map of size H×W×C is sampled at intervals to obtain 4 images of size H×W×C. The sub-feature maps contain global spatial feature information of the original image, enhancing the model's feature extraction capabilities. Then, the sub-feature maps are concatenated along the channel dimension to obtain a size of... The feature map.

[0080] 4b) Perform 1×1 non-span convolution on the concatenated feature map to reduce its dimensionality, preserving as much discriminative feature information as possible, ultimately obtaining a feature map of size [size missing]. The feature map is obtained through multiple SPDConv modules, which can extract more abstract and richer feature information. Compared with conventional convolution operations, it has a higher information retention rate and is more suitable for complex tasks such as detecting low-resolution insect eggs and small-pixel insect eggs.

[0081] Step 5: LCN-YOLOv8 uses LHSFPN as the neck network, such as... Figure 7 As shown, while reducing model complexity, it captures the features of insect eggs of different sizes more comprehensively, and replaces the conventional convolution and C2f modules with SPDConv and PA-C2f modules respectively, thus completing feature fusion more efficiently. Figure 7 (a) in the diagram is the LHSFPN structure diagram. Figure 7 (b) in the diagram is the structure diagram of the SFF module; the specific methods include:

[0082] 5a) LHSFPN mainly consists of two parts: a feature selection module and a feature fusion module. First, in the feature selection module, the feature maps undergo feature filtering through the SEAM attention module, making the model focus more on features such as the shape and edges of the insect eggs, weakening the influence of background and other impurities on the eggs, and using the lighter and more efficient SPDConv to adjust the number of channels. Subsequently, LHSFPN uses the SFF mechanism to fuse high-level and low-level information from the feature maps, generating a high-level feature map F with rich semantic content. high ∈R C×H×W and low-level feature maps Improve the model's multi-scale feature fusion capability.

[0083] 5b) Given a high-level feature map F high ∈R C×H×W and low-level feature maps First, the high-level feature map F... high ∈R C×H×W The high-level features are expanded using a transposed convolution with a stride of 2 and a kernel size of 3×3, resulting in a size F. high ∈R C×2H×2W The feature maps are then analyzed. To unify the dimensions of the high-level and low-level feature maps, bilinear interpolation is used to upsample or downsample the high-level feature map, resulting in a new feature map.

[0084] F att =BL(TConv(F high ))

[0085] In the formula, BL is the bilinear interpolation operation and TConv is the transpose convolution operation.

[0086] Subsequently, the SEAM module converts the high-level feature maps into corresponding attention weights, resulting in features with consistent dimensionality. The low-level feature maps are then filtered. Finally, the filtered low-level feature maps are fused with the sampled high-level feature maps to enhance the model's feature representation, yielding the final output.

[0087]

[0088] In the formula, SEAM represents the weight of the SEAM module. This indicates the dot product operation.

[0089] Step 6: Train the LCN-YOLOv8 network.

[0090] All experiments were conducted on the same computer: an Intel Xeon Silver 4210R CPU and an NVIDIA GeForce RTX 3090 GPU with 24GB of VRAM. The training environment was PyTorch-GPU 1.11.0 and Python version 3.8.13. During the experiments, the epoch count was set to 500, the batch size to 32, and the SGD optimizer with cosine learning rate descent was used. The initial learning rate was set to 0.01. All data were augmented using Mosaic and Mixup. No pre-trained weights were used during training. If the model performance did not improve for 100 consecutive epochs, training was stopped to save time.

[0091] The experiment used mean average precision (mAP), average precision (AP), number of parameters, and giga floating-point operations (GFLOPs) to evaluate the results. Mean precision reflects the overall performance of the algorithm, and it is calculated by integrating the resulting PR curve with recall (R) on the x-axis and precision (P) on the y-axis. Recall represents the percentage of correctly predicted positive samples out of the total number of samples, and precision represents the percentage of correctly predicted positive samples out of all detected positive samples. The calculation methods for these metrics are as follows:

[0092]

[0093] In the formula, TP represents the number of correctly classified positive samples, FP represents the number of incorrectly classified negative samples, FN represents the number of incorrectly classified positive samples, TN represents the number of correctly classified negative samples, and C represents the number of target categories.

[0094] Step 7: Adjust the model's hyperparameters to save the optimal model.

[0095] Step 8: Input the image to be detected into the saved best model for detection.

[0096] Although the backbone network in YOLOv8s uses the C2f module for feature extraction, which can obtain rich feature information, the Bottleneck module inside C2f still uses conventional convolution stacking, leaving room for improvement. Therefore, this study designs the PA-C2f module for efficient feature extraction. To verify the effectiveness of this module, it is compared with five other different Bottleneck modules. The C2f model can be found in the description in "Liu Jia, Zhang Zengwei, Chen Dapeng, et al. Improving the localization accuracy of SLAM in AR based on improved YOLOv8 [J]. Journal of System Simulation, DOI:10.16182 / j.issn1004731x.joss.24-0564."), and the C2f-GhostConv module can be found in "Li Mingyu, Lin Jiaquan. Lightweight driver face target detection algorithm based on YOLOv8-DF [J]". The C2f-DualConv model can be found in "Cao Yu, Li Jiayang, Wang Fang. Lightweight Model for Underwater Fish Target Recognition Based on Improved YOLOv8n [J]. Journal of Shanghai Ocean University. DOI:31.2024.S.20241218.1525.004.html." The C2f-ScConv model can also be found in "Cao Yu, Li Jiayang, Wang Fang. Lightweight Model for Underwater Fish Target Recognition Based on Improved YOLOv8n [J]. Journal of Shanghai Ocean University. DOI:31.2024.S.20241218.1525.004.html." For reference, see "Zheng Yunshui, Meng Yang. A method for extracting railway station signal layout information based on improved YOLOv8s [J]. China Railway Science, 2024, 45(05):209-220.". For C2f-Fasterblock, see "Yang Hongxin, Chen Yue, Pei Guoquan, et al. Research on grading method of Yunnan small-bean coffee beans based on lightweight YOLOv8-FasterBlock model [J]. Food Science. DOI:11.2206.T The C2f-Msblock model can be found in "Wen Tao, Wang Tianyi, Huang Shirui, et al. A Crop and Grass Detection Algorithm Based on Improved YOLOv8: MES-YOLO [J]. Computer Engineering and Science. DOI:43.1258.tp.20241011.1309.004.html". To maintain experimental consistency, all C2f modules in the model were replaced. The comparative experimental results of the C2f modules are shown in Table 1. Although C2f-GhostConv makes the model more lightweight, using GhostConv also reduces the model's feature extraction capability, and the detection accuracy on the multi-egg dataset is significantly reduced, failing to meet the detection requirements. Among the several comparative modules, Fasterblock, which also uses PConv, performs well in terms of model complexity and single-egg detection accuracy, but the detection accuracy on the multi-egg dataset is still not improved.The PA-C2f module not only uses PConv for efficient feature extraction, but also introduces the SEAM attention module, which weakens the interference of background information and focuses more on the features of dense eggs and occluded eggs. This not only makes the model lightweight, but also improves the detection accuracy, especially in the detection of multi-egg datasets, where it has a significant advantage over other modules.

[0097] Table 1 Comparison Experiment of C2f Module

[0098]

[0099] To verify whether the three improved modules in LCN-YOLOv8 can effectively improve detection performance, this section conducts ablation experiments on single-egg and multi-egg datasets. The experimental results are shown in Table 2, with √ indicating the modules used.

[0100] Table 2 Ablation Experiment Results

[0101]

[0102] As shown in Table 2, all improved modules effectively reduced the number of model parameters and computational cost, achieving model lightweighting. The PA-C2f module uses PConv and SEAM attention to achieve efficient feature extraction, showing good performance on the single-egg dataset, with mAP@0.5 and mAP@0.5:0.95 improvements of 0.4% and 0.7%, respectively. LHSFPN uses the SEAM and SFF modules to efficiently fuse feature maps extracted by the backbone network, enhancing the model's detection capability for multi-egg images, with mAP@0.5 and mAP@0.5:0.95 improvements of 0.6% and 1.0%, respectively, on the multi-egg dataset. SPDConv mainly addresses the detection problem of low-resolution and small-pixel eggs in the multi-egg dataset, with mAP@0.5 and mAP@0.5:0.95 both improving by 0.4% on the multi-egg dataset. Finally, after adding all the modules, the number of model parameters decreased by 6M and the computational cost decreased by 7.5G. The mAP@0.5 and mAP@0.5:0.95 of the single egg dataset were improved by 0.4% and 1.7% respectively, and the mAP@0.5 and mAP@0.5:0.95 of the multi-egg dataset were improved by 1.1% and 1.6% respectively, achieving a good balance between detection accuracy and model complexity.

[0103] Table 3. Comparison of experimental results for different models

[0104]

[0105] LCN-YOLOv8 is an improvement based on YOLOv8s. To verify its superior detection performance, this section compares LCN-YOLOv8 with the most advanced single-stage target detection models such as YOLOv5, YOLOv9, and YOLOv10 under the same experimental environment. The experimental results are shown in Table 3. For details on YOLOv3-tiny, please refer to "Jin Xiaofang, Yue Ding, Liu Jinyu. Research on Intelligent Reconnaissance Virtual Training System Based on YOLOv3-tiny [J]. Journal of Ordnance Equipment Engineering, 2023, 44(08): 186-190.", and for YOLOv5m, please refer to "Song Yaolian, Wang Can, Li Dayan, et al. Small Target Detection Algorithm for UAVs Based on Improved YOLOv5s [J]. Journal of Zhejiang University (Engineering Science), 2024, 58(12): 24. 17-2426.)”, YOLOv8s and YOLOv8m can be found in “Zhang Lifeng, Tian Ying. Improved multi-scale lightweight vehicle target detection algorithm of YOLOv8[J]. Computer Engineering and Applications, 2024, 60(03):129-137.)”, YOLOv9s can be found in “Wu Yibang, Chen Zhe, Li Zhe et al. Remote sensing image detection method for illegal cultivation area on steep slope of prohibited land based on improved YOLOv9[J]. Transactions of the Chinese Society of Agricultural Engineering, 2024, 40(17):197-204.)”, YOLOv10s and YOLOv10m can be found in “Yang Haitao, Zhao Junyu, Wang Rui et al. Small target detection of UAV based on DBB-YOLOv10s[J]. Infrared Technology.DOI:53.1053.TN.20241126.1129.002.html.)”.

[0106] The experimental results show that although YOLOv3-tiny has the smallest computational cost, its accuracy in detecting multiple parasite eggs lags far behind other models. Compared with the two latest lightweight models, YOLOv9s and YOLOv10s, LCN-YOLOv8 not only shows a significant improvement in detection accuracy on both datasets, but also has fewer computational and parameter requirements. Compared with the two larger models, YOLOv9m and YOLOv10m, LCN-YOLOv8 has a significant advantage in both parameter and computational cost, and its detection accuracy is slightly higher than these two models. LCN-YOLOv8 integrates efficient convolutional, feature extraction, and feature fusion modules, achieving a good balance between detection accuracy and model complexity, making it effective for parasite egg detection.

[0107] Figure 8 This is a comparison chart of the detection results between YOLOv8s and LCN-YOLOv8. Figure 8 Image (a) shows the detection results from YOLOv8s. Figure 8(b) in the image shows the detection results of LCN-YOLOv8. Eight detection results were selected for display under three conditions: background occlusion, small insect eggs, and low resolution. The images are numbered using (1)-(8). Figure 8 (a) and Figure 8 In (b) of the dataset, images with the same number represent different detection results from two different models applied to the same image; and boxes of different colors represent different types of parasite eggs. This addresses the severe background occlusion problem in datasets with multiple parasite eggs. Figure 8 The detection results show that traditional YOLOv8s exhibits a higher rate of missed detections. In contrast, LCN-YOLOv8, utilizing SEAM attention and PA-C2f for efficient feature extraction, enhances the model's ability to distinguish insect eggs from the background, reducing missed detections due to background occlusion. For small insect eggs in the dataset, YOLOv8s easily misclassifies them as background impurities, while the LCN-YOLOv8 model uses an improved HSFPN for efficient feature fusion, reducing the likelihood of missing small eggs. For low-resolution insect eggs due to issues like image capture, LCN-YOLOv8 uses SPDConv to extract fine-grained features, minimizing the loss of edge and other detail features, thus reducing the probability of misclassifying eggs as impurities. In summary, LCN-YOLOv8, with its more efficient feature extraction and fusion capabilities, performs better than YOLOv8s in detecting complex situations such as background occlusion, small insect eggs, and low resolution.

[0108] Some steps in the embodiments of the present invention can be implemented using software, and the corresponding software program can be stored in a readable storage medium, such as an optical disc or a hard disk.

[0109] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for detecting parasite eggs based on an improved YOLOv8s, characterized in that, The method includes: Step 1: Collect microscopic images of parasite eggs to construct a parasite egg dataset. Based on the number of parasite egg species, the parasite egg dataset is labeled as a single-egg dataset and a multi-egg dataset, and then divided into training set, validation set and test set respectively. Step 2: Select the YOLOv8s model as the baseline network, integrate lightweight convolution, attention module and efficient neck network to build the target detection model LCN-YOLOv8, which is used to detect parasite eggs; Step 3: Design the PA-C2f module to replace the C2f module for feature extraction, and introduce the SEAM attention module to ensure the model's feature extraction capability; Step 4: Replace all conventional convolutional modules other than PA-C2f in the model with the SPDConv module to reduce the loss of fine-grained information of insect eggs during feature extraction; Step 5: Design an HSFPN module, including a feature selection module and a selective feature fusion module, as the neck network for feature fusion; Step 6: Train the LCN-YOLOv8 model using the training set constructed in Step 1, and introduce the total loss function. L The training process of the model is constrained, and Mosaic and Mixup techniques are used to augment the data and expand the samples during the training process; Step 7: Use the validation set built in Step 1 to evaluate the model's performance during training, adjust the model's hyperparameters, and if the model's performance does not improve, stop training early to save the best model. Step 8: Input the microscopic images of parasite eggs from the test set constructed in Step 1 into the saved best model for testing, and obtain the visual detection results of parasite eggs; Step 3 includes: In the PA-C2f module, PA Block is used instead of the Bottleneck structure in C2f for feature extraction, and the features of different branches are concatenated. The convolution kernel size used in the PA Block is [size missing]. Feature extraction is performed using PConv, and two convolutional kernels with a size of [missing value] are used. The PWConv layer utilizes the unprocessed channel information in PConv, and introduces the SEAM module after the input features are shortened to improve the model's ability to focus on features. The PConv and PWConv in the PA Block exhibit an inverted residual structure, and only the middle PWConv layer uses a BN layer and a ReLU activation function to expand the number of channels in the feature map. In step 5, the feature selection module performs feature filtering through the SEAM attention module and adjusts the number of channels using SPDConv. The selective feature fusion module generates a high-level feature map containing semantic information by fusing high-level and low-level information from the feature map. and low-level feature maps ; The selective feature fusion module uses a stride of 2 and a kernel size of [missing value] on the high-level feature maps. Expanding the transposed convolution yields a result of size [size missing]. The feature map is then upsampled or downsampled using bilinear interpolation to obtain a new feature map. , The expression is: in, BL This is a bilinear interpolation operation. This is a transpose convolution operation; The SEAM module converts high-level feature maps into corresponding attention weights to obtain features with consistent dimensionality. Then, the low-level feature maps are filtered. Finally, the filtered low-level feature maps are fused with the high-level feature maps to enhance the model's feature representation, yielding the final output. , The expression is: in, SEAM Indicates the weights of the SEAM modules. This indicates the dot product operation.

2. The method according to claim 1, characterized in that, The SEAM structure includes a channel spatial hybrid module (CSMM) with residual connections and a two-layer fully connected network. The Channel Spatial Hybridization Module (CSMM) with residual connections learns the importance of different channels and combines them through pointwise convolution after the output of depthwise convolution to compensate for information loss between channels; the two fully connected layers aggregate channel information extracted from CSMM modules of different patch sizes.

3. The method according to claim 2, characterized in that, The SPDConv in step 4 includes spatial-to-depth layers and non-span convolutional layers; The space-to-depth layer has an input size of... The feature map is sampled at intervals to obtain a size of The sub-feature maps are then concatenated along the channel dimension to obtain a size of [size missing]. Feature map; The non-span convolutional layer uses Non-span convolution is used for dimensionality reduction, preserving information from all discriminative features, ultimately yielding a result of size [size missing]. The feature map.

4. The method according to claim 3, characterized in that, The total loss function in step 6 L The expression is: in, For classification loss function, Let the target confidence loss function be... The bounding box loss function is... For classification loss function The weighting coefficients, For the target confidence loss function The weighting coefficients, The bounding box loss function The weighting coefficients are used to balance the contributions of different losses to the total loss; The Mosaic technology enhances data by stitching multiple images together into a new image; The Mixup technique expands the dataset by linearly combining samples from different datasets to generate new samples.

5. The method according to claim 4, characterized in that, The criterion for evaluating the model in step 7 is the total loss function. L The model is now at its optimal state, meaning it no longer degrades during training and its performance no longer improves.

6. The method according to claim 5, characterized in that, In step 1, the ratio of the training set, validation set, and test set is 7:2:1.