Precise sheep coccidiosis parasitic ovum detection method based on deep learning
By using an improved YOLOv5s-ST deep learning model and image preprocessing technology, the problems of time consumption and misjudgment in the detection of coccidiosis parasite eggs in sheep have been solved, achieving efficient and accurate automated detection and analysis, generating detailed reports, and making it suitable for the detection and control of coccidiosis in sheep in large-scale farms.
Patent Information
- Application Number
- CN202511267281.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-05
- Publication Date
- 2025-11-14
AI Technical Summary
Existing methods for detecting coccidiosis parasite eggs in sheep rely on manual microscopic analysis, which is time-consuming and easily affected by subjective human factors, resulting in high rates of misjudgment and missed detection, making it difficult to meet the needs for efficient and accurate detection.
An improved YOLOv5s-ST deep learning model, combined with a shift window Transformer module and a normalized attention mechanism (NAM), is used to automatically collect, preprocess, and detect coccidiosis parasite eggs in sheep, including image noise removal, enhancement, and size normalization. The deep learning model is then used for accurate identification and counting.
It significantly improves detection efficiency and accuracy, reduces false positives and false negatives, lowers labor costs, and can process a large number of samples in a short time to generate detailed test reports, providing a scientific basis for aquaculture management.
Smart Images

Figure CN120953257A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology, specifically relating to a method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning networks. Background Technology
[0002] Coccidiosis in sheep is a global animal health problem. Its pathogenic mechanism stems from the invasive parasitic infection of the intestinal mucosa of ruminants by coccidia belonging to the family Eimeria. The pathogen is transmitted through sporulated oocysts. After the host ingests contaminated water or feed, the parasite completes its complex life cycle within the digestive system. Epidemiological surveys show that the infection rates in sheep and goats in my country range from 43.2% to 93.8% and 35.8% to 91.5%, respectively. Significant infections are also observed in major livestock-producing countries such as Brazil and India, exhibiting clear regional epidemic characteristics.
[0003] The pathological progression of this disease can be divided into three stages: the initial stage manifests as digestive dysfunction caused by mechanical damage to the intestinal mucosa; the middle stage develops into a nutritional and metabolic disorder syndrome; and the late stage may lead to multiple organ failure. Clinical features include progressive emaciation, bloody stools, anemia, and growth retardation. These pathological changes not only reduce the commercial value of livestock products but also significantly increase the disease control costs for livestock farms. It is estimated that feed conversion rates in severely infected populations can decrease by up to 30%, directly hindering the sustainable development of the livestock industry.
[0004] Traditional diagnostic techniques primarily rely on microscopic examination, identifying pathogens by recognizing the morphological characteristics of oocysts. However, this method suffers from several technical bottlenecks: firstly, it requires qualified laboratory personnel; secondly, sample processing is time-consuming, taking 2-3 hours per batch; and more importantly, there is a high risk of false negatives (up to 35%) when the oocyst density is below 100 oocysts per gram of feces. These limitations have prompted the academic community to shift towards the development of intelligent detection technologies.
[0005] The iterative development of computer vision technology has opened up new avenues for parasite detection. Early systems employed a detection scheme combining grayscale thresholding with morphological filtering, achieving a detection rate of around 60%, but lacking specificity when dealing with complex biological samples. With the evolution of machine learning algorithms, support vector machine models based on HOG features have improved accuracy to 78%, while the introduction of deep convolutional networks has broken through the 90% threshold. Notably, the improved YOLOv5 architecture achieved a 97.2% mAP value in slide sample testing, reducing single-frame processing time to 120ms, demonstrating significant potential for engineering applications.
[0006] Current technological breakthroughs focus on three dimensions: First, by fusing attention mechanisms with feature pyramid networks, the recognition accuracy of small targets (<50×50 pixels) has been successfully improved by 23%. Second, knowledge distillation techniques have been applied to compress the model size, reducing the number of parameters in MobileNetV3 to 1 / 8 of the original model, meeting the needs of mobile deployment. Third, a multi-scale feature fusion framework has been constructed, improving the detection stability of low-quality images (PSNR<20dB) by 18.6%. These advancements lay the technological foundation for building automated detection systems.
[0007] Nevertheless, the practical application of intelligent detection systems still faces key challenges: at the algorithm level, the false positive rate caused by overlapping eggs and interference from impurities remains at 12%-15%; in terms of hardware integration, the cost of fully automated microscopic imaging equipment remains high; and clinical validation data show that the accuracy of existing systems in subtype identification is only 82.7%, which is still far from meeting clinical needs. Summary of the Invention
[0008] To address the aforementioned technical problems, this invention provides a deep learning-based method for the accurate detection of coccidiosis parasite eggs in sheep. This method can effectively improve the detection accuracy and recall rate of coccidiosis parasite eggs in sheep, reduce the computational complexity of the model, and enhance the automation level of detection.
[0009] The specific plan is as follows: Step 1: Image collection and preprocessing; (S11): Automatically collect images of sheep coccidiosis parasite eggs; (S12): Perform image noise removal and image enhancement processing on the sample image; (S13): After adding processing to the image, perform image size standardization; Step 2: Input the preprocessed image into the automatic detection model for sheep coccidiosis parasite eggs for training, and use the deep learning model to automatically detect sheep coccidiosis parasite eggs; (S21): Construct a framework for detecting parasite eggs in sheep coccidiosis; (S22): The detection model framework embeds a shift window Transformer module and a normalized attention mechanism; Step 3: Analyze the data and generate a report on the number of coccidiosis parasite eggs output by the deep learning model; (S31): Statistical analysis of the number of parasite eggs and infection density analysis of coccidiosis in sheep; (S32): Visualize the results and generate a test report.
[0010] In (S11), a microscope and camera are used to automatically acquire microscopic images of sheep feces samples. The formula for acquiring each sample image is as follows: I i =f ( x,y ) in, I i This represents the first acquired image. f ( x,y ) is the image function output by the acquisition device. x and y Represents the spatial coordinates of the image.
[0011] In step (S12), median filtering or Gaussian filtering is used for noise reduction. Let the original image have [number] pixels. I ( x,y The image with noise removal has the following pixel count: I'(x,y) Therefore, the Gaussian filtering formula is: in, w ( i,j ) is the Gaussian filter kernel, k This represents the "half-width" of the Gaussian filter kernel, or the "half-size" of the kernel, which controls the size of the filtering region.
[0012] In (S12), contrast adjustment and histogram equalization are used for image enhancement. The formula for histogram equalization is: in, minutes ( I ) and max ( I ) are image pixels I ( x,y The minimum and maximum values of ) I enhanced ( x,y (This is the enhanced image.)
[0013] In (S13), the size normalization process is performed using bilinear interpolation. The formula for bilinear interpolation is: in, I resized ( x',y' () represents the pixel values of the adjusted image. N ( x',y' ) is related to the target location ( x',y' The corresponding neighboring pixels, w ( x,y ) is the interpolation weight.
[0014] The detection model framework is the YOLOv5s-ST detection architecture, which includes a cross-stage feature extraction network CSPDarknet, a multi-scale feature fusion module PANet, and an optimized detection head. The improved YOLOv5s-ST detection architecture also embeds a shift window Transformer and a normalized attention mechanism NAM.
[0015] The Transformer module for shifting windows described in (S22) adopts a hierarchical local window partitioning strategy to perform self-attention calculations within non-overlapping windows; it establishes long-range dependencies through a cross-window displacement mechanism to balance global feature modeling and computational efficiency. The layered window partitioning strategy of the shift window Transformer module reduces computational complexity while retaining the ability to model long-range dependencies; in specific implementation, the encoder of the shift window Transformer module is embedded in each detection head. Let the input feature tensor be The query matrix is generated after linear mapping. P Key matrix M Value matrix N The query matrix P Key matrix M Value matrix N, These are used respectively for self-attention calculation in the Transformer module of the shift window; in, , L=H×W , H Represents image height, W Represents the image width. L D represents the image area, D is the dimension of the input feature (number of channels), and D′ is the embedding dimension after linear mapping. The Transformer module employs a non-overlapping window partitioning strategy to segment the feature map into... k× k Within a window, local attention calculations are performed. The attention weight matrix S is calculated as follows: S = softmax ( PM T ) U=SN In the formula, Characterizes the strength of the correlation between feature points. U For attention-enhanced feature representation, P For query matrix (Query), M The key matrix (Key)M T This is the transpose of the key matrix. PM T To calculate the similarity between the query and the key using the dot product; Comparison of defined complexities: I ( MHA ) =4HWD 2 +2 ( HW ) 2 D I ( W-MHA ) =4HWD 2 +2t 2 HWD The purpose of defining the complexity comparison is to evaluate the change in computational efficiency of the model after introducing the window attention mechanism. In the formula, I ( ∙ () indicates the time complexity of the operation; MHA This refers to Multi-Head Attention, or global multi-head attention. W-MHA This is Windowed Multi-Head Attention, which limits the attention computation to a local window. t Indicates the size of the attention window; The shifted window Transformer module encoder includes a window attention sublayer and a multilayer perceptron (MLP), with residual connections used to mitigate gradient decay.
[0016] In (S22), the normalized attention mechanism optimizes the weights through channel-space dual-path attention and dynamically allocates feature weights using the batch normalized BN scaling factor; the five-level cascaded NAM module enhances the model's sensitivity to insect egg details and suppresses background interference under lightweight computation conditions. For the channel dimension: Channel weights are evaluated using a scaling factor based on batch normalization (BN), assuming the input feature is... Channel attention weight W C The calculation formula is: W C = s ( ϕ ( BN ( GC ))) in, ϕ This represents the learnable scaling parameter. s Use the Sigmoid activation function; For the spatial dimension: for feature maps Perform spatial normalization, weights W S The calculation is as follows: W S = s ( ψ ( BN S ( G S ))) In the formula, ψ Parameters for scaling spatial dimensions.
[0017] In (S31), the method for counting the number of coccidiosis parasite eggs and analyzing the infection density in sheep includes the following steps: S311): In the preprocessed image, sheep coccidiosis parasite eggs are detected and counted. The method for detecting and counting sheep coccidiosis parasite eggs is to process the image using a segmentation algorithm to extract the region of sheep coccidiosis parasite eggs; assuming that the sheep coccidiosis parasite egg region obtained through segmentation is... M i Then, the number of coccidiosis parasite eggs in each image is calculated as follows: N i This can be accomplished by counting the regions: in, d ( M ij ) is an indicator function, when M ij When it is the egg of the coccidiosis parasite in sheep, d ( M ij )=1, otherwise d ( M ij )=0; S312): Infection density analysis of the number of coccidiosis parasite eggs in sheep, assuming A i Let D be the effective area of the image, in mm², then the infection density D of the i-th image is... i It can be calculated using the following formula: Calculate the average infection level D for all images. avg : Where n is the total number of images, the density of coccidiosis parasite eggs in the sample is initially assessed by the infection density.
[0018] In (S32), the visualization method uses heatmaps or bar charts to show the infection density in different regions and at different time points; assuming the infection density of the result is D. i The following formula can be used to generate a heatmap: Among them, H i (x,y) represents the normalized heatmap values, D region This represents the maximum infection density in the region. The report generation module is used to generate a test report, which includes statistics on the number of coccidiosis parasite eggs, infection density analysis, and regional and seasonal infection trends. The process of generating the test report can be represented as follows: R=f(D i D r H i ) Where R is the generated report, and D is... i It is the infection density data in the image, D r This is regional infection density data, H i It is heatmap data.
[0019] This invention discloses a method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning, comprising sequentially set modules for image collection and preprocessing, automatic detection of coccidiosis parasite eggs in sheep, and data analysis and report generation.
[0020] By combining image acquisition and preprocessing with deep learning technology, we can automatically acquire and preprocess images of coccidiosis parasite eggs in sheep, ensuring high-quality data input. Specifically, this includes: automated image acquisition, image noise removal, image enhancement and contrast adjustment, and image size standardization.
[0021] The automated detection of coccidiosis parasite eggs in sheep combines deep learning and image recognition technologies to achieve automatic identification and localization of coccidiosis parasite eggs in sheep feces samples under a microscope, ensuring the accuracy and efficiency of detection. Specifically, it includes: image segmentation and region recognition, coccidia egg feature extraction, and oocyst detection and counting.
[0022] The data analysis and report generation module, based on machine learning and statistical analysis techniques, performs in-depth analysis of the test results, providing detailed assessments of infection status and trend predictions. Specifically, it includes statistics on the number of coccidiosis parasite eggs in sheep, visualization of results, and automatic generation of test reports for reference by livestock managers, enabling them to take timely prevention and control measures.
[0023] Compared with the prior art, the present invention has the following advantages: 1. Improved Detection Efficiency: Traditional detection of coccidiosis parasite eggs in sheep often relies on manual microscopic analysis, which is not only labor-intensive and time-consuming but also inefficient. In contrast, this invention, by introducing deep learning and automated detection technology, can complete the automatic detection of large-scale samples in a short time. For example, the improved YOLOv5s-ST model reduces the inference time per image by approximately 15%, thus significantly improving detection efficiency. In practical applications, this system can process hundreds of sample images within minutes, greatly shortening the time required by traditional methods, which typically take several hours or even longer.
[0024] 2. Improved Detection Accuracy: Traditional methods are easily affected by subjective human factors, especially when detecting tiny parasite eggs, which can easily lead to false positives or false negatives. This invention employs an improved YOLOv5s-ST deep learning model, combining a shifted window Transformer module and a normalized attention mechanism (NAM), effectively enhancing the detection capability for tiny targets (such as sheep coccidioidomycete eggs). Compared with the traditional YOLOv5 model, the improved model achieves a 6.4% improvement in precision and a 7.4% improvement in recall, significantly reducing false positives and false negatives and ensuring high accuracy of detection results.
[0025] 3. Convenient results analysis and report generation: It can perform data analysis and generate test reports to help aquaculture managers make scientific decisions and take timely prevention and control measures.
[0026] 4. High adaptability: This invention has strong adaptability and can handle the detection needs of coccidiosis in sheep in different regions and seasons. It is suitable for daily monitoring and management in large-scale farms.
[0027] 5. Reduced Labor Costs: Traditional manual testing methods require a large labor input, especially in large-scale farms where labor costs remain high. By introducing the automated testing and analysis process of this invention, the need for manual operation can be significantly reduced, particularly in large-scale farms and research institutions.
[0028] 6. Improve disease prevention and control: Through accurate and real-time detection and data analysis, this invention helps to detect the spread of coccidiosis in sheep at an early stage, providing a scientific basis for the timely implementation of prevention and control measures, reducing economic losses and protecting the health of sheep. Attached Figure Description
[0029] Figure 1 This is a schematic diagram illustrating the implementation process of the method for accurate detection of coccidiosis parasite eggs in sheep according to the present invention.
[0030] Figure 2This is a schematic diagram of each image in the image processing process of the present invention.
[0031] Figure 3 This is a schematic diagram of the structure of the sheep coccidiosis parasite egg detection model of the present invention.
[0032] Figure 4 This is an example of the detection and identification of coccidiosis parasite eggs in sheep.
[0033] Figure 5 This is a comparison table of detection efficiency between the improved YOLOv5s-ST model and traditional methods.
[0034] Figure 6 This is a comparison table of the detection accuracy, recall, and F1 score between the improved YOLOv5s-ST model and the traditional YOLOv5 model. Detailed Implementation
[0035] The technical solutions in the embodiments of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the implementation of the present invention, and not all of it. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0036] This invention discloses a deep learning-based method for accurate detection of coccidiosis parasite eggs in sheep, comprising the following steps: automatically acquiring images of sheep feces samples and performing noise removal and enhancement on the images to ensure image quality; inputting the preprocessed images into an automatic detection model for sheep coccidiosis parasite eggs for training, the training process including image segmentation, feature extraction, and accurate recognition, and automatically identifying sheep coccidiosis parasite eggs using the deep learning model; performing infection density analysis on the number of sheep coccidiosis parasite eggs output by the improved deep learning model to assess the infection risk of the sheep flock; visualizing the detection results and generating a detailed analysis report, including data on the number, type distribution, and infection density of sheep coccidiosis parasite eggs, thereby improving and shortening the time required by traditional methods (several hours or even longer) and ensuring high accuracy of the detection results.
[0037] The workflow framework of the deep learning-based method for accurate detection of coccidiosis parasite eggs in sheep is as follows: Figure 1 As shown, it includes the following steps: 1. Image collection and preprocessing: Automatic acquisition of images of sheep coccidiosis parasite eggs: The high-resolution camera device automatically acquires microscopic images of sheep fecal samples using a microscope camera.
[0038] like Figure 2As shown, the specific steps for automatically acquiring images of sheep coccidiosis parasite eggs are as follows: The first step in this system is to automatically collect images of sheep coccidiosis parasite eggs. For example... Figure 2 As shown in (a), the system can automatically acquire microscopic images of sheep feces samples without human intervention using a high-resolution microscope and camera device. Each sample image can be obtained in the following manner: I i =f ( x,y ) in, I i This represents the first acquired image. f ( x,y ) is the image function output by the acquisition device. x and y This represents the spatial coordinates of the image. This ensures the integrity of each sample image and provides high-quality input for subsequent processing.
[0039] Image noise removal and image enhancement: Preprocessing of the acquired images includes noise removal and image enhancement to improve the visibility of coccidiosis parasite eggs in sheep. Noise removal is performed using median filtering or Gaussian filtering, and image enhancement includes contrast adjustment and histogram equalization. For example... Figure 2 As shown in (b) Image noise removal and image enhancement, the specific steps are as follows: Acquired images are often affected by noise, such as electronic noise from imaging equipment and unstable light sources. Removing this noise is crucial for improving image quality. Common denoising methods include Gaussian filtering or median filtering.
[0040] Let the original image have pixels of 1. I ( x,y The image with noise removal has the following pixel count: I'(x,y) Therefore, the Gaussian filtering formula is: in, w ( i,j ) is the Gaussian filter kernel, k This represents the "half-width" of the Gaussian filter kernel, or the "half-size" of the kernel, which controls the size of the filtering region.
[0041] After noise removal, the image is then enhanced, primarily to improve the contrast and clarity of the coccidiosis parasite eggs, making them stand out more. For example... Figure 2As shown in (c); by adjusting parameters such as image contrast and brightness, the visibility of the coccidiosis parasite egg region can be enhanced using the histogram equalization method: in, minutes ( I ) and max ( I ) are image pixels I ( x,y The minimum and maximum values of ) I enhanced ( x,y (This is the enhanced image.)
[0042] Image size normalization: Resize all input images to a uniform resolution to ensure stability and consistency in subsequent processing. Figure 2 As shown in (d) in the figure.
[0043] Image size standardization, the specific steps are as follows: To ensure that all images input to subsequent modules have a uniform size, image size normalization is a necessary operation. Assume the size of the input image is ( W i ,H i Adjust it to a uniform size. W,H Size transformation can be performed using bilinear interpolation. The specific operation is as follows: in, I resized ( x',y' () represents the pixel values of the adjusted image. N ( x',y' ) is related to the target location ( x',y' The corresponding neighboring pixels, w ( x,y ) is the interpolation weight.
[0044] 2. Automated detection of coccidiosis parasite eggs in sheep: like Figure 3 As shown, the detection model framework for coccidiosis parasite eggs in sheep is as follows: a detection architecture based on the improved YOLOv5s-ST is constructed, integrating the cross-stage feature extraction network CSPDarknet, the multi-scale feature fusion module PANet, and the optimized detection head; a shift window Transformer and a normalized attention mechanism NAM are embedded to improve the localization accuracy of small targets in complex backgrounds. The embedded shift window Transformer can be abbreviated as ST.
[0045] The framework design of the detection model for coccidiosis parasite eggs in sheep is as follows: This model is an improvement on the YOLOv5 framework, using a single-stage convolutional neural network (CNN) architecture, which can simultaneously perform target classification and localization tasks.
[0046] In terms of balancing speed and accuracy, YOLOv5 outperforms most traditional detection algorithms. However, the existing YOLOv5 often faces the problem of decreased accuracy when dealing with small targets and complex backgrounds, especially in the microscopic image detection of tiny parasite eggs such as sheep coccidioidomycetes.
[0047] To improve the model's detection accuracy, especially in recognizing small targets, this model incorporates several improvements. The core architecture of YOLOv5 remains unchanged, still including a feature extraction layer, a feature fusion layer, and a detection output layer. The backbone network 1 uses CSPDarknet, effectively reducing computational redundancy and accelerating model convergence through a cross-stage fusion CSP design. The neck module 2 integrates PANet, further enhancing multi-scale feature interaction capabilities; the head network 3 is responsible for outputting detection results including class confidence and location coordinates. This layered design enables the model to maintain efficient target recognition capabilities even in complex scenes.
[0048] With the continuous development of the YOLO series algorithms, the hierarchical shift window Transformer (ST) module has been proposed in recent years. By implementing an attention mechanism within a local window and combining it with a cross-window association strategy, it effectively improves the ability to capture global features. This model adopts an improved YOLOv5s-ST architecture and embeds skip connections, cross-layer feature aggregation, normalized attention mechanism (NAM), and the ST module, significantly improving the detection accuracy of coccidioidomycete eggs in microscopic images, especially greatly enhancing the detection effect of small targets in complex backgrounds.
[0049] The Transformer module for shifting windows employs a hierarchical local window partitioning strategy, performing self-attention computation within non-overlapping windows. The window size... k×k Long-range dependencies are established through a cross-window displacement mechanism, balancing global feature modeling and computational efficiency, thus optimizing complexity to [value missing]. I ( W-MHA ) =4HWD 2 +2t 2 HWD .
[0050] The Transformer module for shifting windows involves the following steps: Compared to traditional CNNs, the Transformer architecture can extract richer global contextual features, which is particularly important for the identification of tiny parasite eggs in microscopic images. The Transformer module employs a hierarchical window partitioning strategy, reducing computational complexity while retaining long-range dependency modeling capabilities. In practice, the Transformer encoder is embedded in each detection head. Let the input feature tensor be The query matrix is generated after linear mapping. P Key matrix M Value matrix N The query matrix P Key matrix M Value matrix N, These are used respectively for self-attention calculation in the Transformer module of the shift window; in, , L=H×W , H Represents image height, W Represents the image width. L D represents the image area, D is the dimension of the input feature (number of channels), and D′ is the embedding dimension after linear mapping. The above operation constitutes one of the core computational steps in the process of embedding the shift window Transformer encoder into each detection head, effectively enhancing the ability to model local and global features.
[0051] Attention weight matrix S The calculation method is as follows: S = softmax ( PM T ) U=SN In the formula, Characterizes the strength of the correlation between feature points. U For attention-enhanced feature representation, P For query matrix (Query), M The key matrix (Key) M T This is the transpose of the key matrix. PM T To calculate the similarity between the query and the key using the dot product.
[0052] To alleviate the quadratic complexity of traditional multi-head attention (MHA), ST employs a non-overlapping window partitioning strategy: dividing the feature map into... k×k A window where local attention calculations are performed.
[0053] Comparison of defined complexities: I ( MHA ) =4HWD 2 +2 ( HW ) 2 D I ( W-MHA ) =4HWD 2 +2t 2 HWD The purpose of defining the complexity comparison is to evaluate the change in computational efficiency of the model after introducing the window attention mechanism. In the formula, I ( ∙ () indicates the time complexity of the operation; MHA This refers to Multi-Head Attention, or global multi-head attention. W-MHA This is Windowed Multi-Head Attention, which limits the attention computation to a local window. t Indicates the size of the attention window; The ST encoder includes a window attention sublayer and a multilayer perceptron (MLP), with residual connections used to mitigate gradient decay.
[0054] Normalized attention mechanism: Design channel-space dual-path collaborative attention, and dynamically allocate feature weights using batch normalized BN scaling factor; enhance the model’s sensitivity to insect egg details through five-level cascaded NAM module, and suppress background interference under lightweight computation conditions.
[0055] The normalized attention mechanism consists of the following steps: To address the shortcomings of traditional YOLO in its sensitivity to small targets, this model introduces a lightweight NAM module. This mechanism optimizes feature weights through channel-space dual-path attention: Channel dimension: Channel importance is evaluated using a scaling factor based on batch normalization (BN). Let the input features be... Channel attention weight W C The calculation formula is: W C = s ( ϕ ( BN ( GC ))) in, ϕ This represents the learnable scaling parameter. s Use the Sigmoid activation function; For the spatial dimension: for feature maps Perform spatial normalization, weights W S The calculation is as follows: W S = s ( ψ ( BN S ( G S ))) In the formula, ψ Parameters for scaling spatial dimensions.
[0056] The NAM module is embedded at the output of the ST layer, and its five-level cascade structure enhances the model's focus on the detailed features of coccidiosis parasite eggs in sheep. Experiments show that this design significantly improves the detection rate of small targets in complex backgrounds with almost no increase in computational load.
[0057] 3. Data Analysis and Report Generation: like Figure 4 As shown, the number of coccidiosis parasite eggs in sheep and the analysis of infection density were statistically analyzed: the number of detected coccidiosis parasite eggs in sheep was statistically analyzed, the infection density of the samples was calculated, and the data were compared with historical data to assess the infection status.
[0058] Figure 4 Figure (A) in the image is the original input image, which contains multiple coccidia eggs that are difficult to identify with the naked eye, as well as a large amount of background impurities, noise and other non-target areas; Figure 4 Figure (B) shows the detection results of the object detection model. It is the output obtained after the trained object detection model performs inference on the original image. Each identified coccidioidomycete egg is outlined in red and labeled with its category, demonstrating the model's ability to correctly detect multiple targets in complex backgrounds. Figure 4 Figure (C) in the figure is a magnified view of the detection result of a single target, focusing on a successfully identified and labeled coccidia egg instance, intuitively demonstrating the model's detection accuracy and localization effect on small targets.
[0059] The specific steps for counting the number of coccidiosis parasite eggs and analyzing the infection density in sheep are as follows: In the preprocessed image, the first step is to detect and count the coccidiosis parasite eggs in sheep. A segmentation algorithm (such as U-Net) is used to process the image and extract the regions containing the coccidiosis parasite eggs. Let's assume the segmented regions containing the coccidiosis parasite eggs are... M i Then, the number of coccidiosis parasite eggs in each image is calculated as follows: N i This can be accomplished by counting the regions: in, d ( M ij ) is an indicator function, when M ij When it is the egg of the coccidiosis parasite in sheep, d ( M ij )=1, otherwise d ( M ij )=0.
[0060] Subsequently, an infection density analysis was performed on the number of coccidiosis parasite eggs in sheep. Hypothesis A i Let D be the effective area of the image, in mm², then the infection density D of the i-th image is... i It can be calculated using the following formula: Calculate the average infection level D for all images. avg : Where n is the total number of images. The infection density can be used to preliminarily assess the density of coccidiosis parasite eggs in the sample.
[0061] Results visualization and report generation: Visualization tools are used to display information such as infection density and the number of parasite eggs, which is convenient for aquaculture managers to refer to and make decisions.
[0062] The specific steps for results visualization and report generation are as follows: To facilitate understanding of the analysis results by aquaculture managers, the system will visualize the data. Common visualization methods include heatmaps and bar charts, which can intuitively show the infection density in different regions and at different time points. Let's assume the infection density of the results is D. i The following formula can be used to generate a heatmap: Among them, H i (x,y) represents the normalized heatmap values, D region This represents the maximum infection density in the region.
[0063] Finally, the system will generate a report that includes statistics on the number of coccidiosis parasite eggs in sheep, infection density analysis, and regional and seasonal infection trends. This report can be automatically exported as a PDF or Excel file for reference by livestock managers. The report generation process can be represented as follows: R=f(D i D r H i ) Where R is the generated report, and D is... i It is the infection density data in the image, D r This is regional infection density data, H i It is heatmap data.
[0064] In summary, this invention proposes a deep learning-based intelligent detection and analysis method for sheep coccidiosis parasite eggs. Compared with traditional detection methods, this method introduces a multi-layered, modular technical architecture, including image collection and preprocessing, target detection, infection density analysis, and result report generation, constructing an efficient and automated intelligent detection system. In this process, we specifically improved the deep learning target detection model, significantly enhancing the detection accuracy and automation level of sheep coccidiosis parasite eggs. The improved YOLOv5s-ST model reduces inference time per image by approximately 15%, and compared to the traditional YOLOv5 model, improves accuracy by 6.4% and recall by 7.4%, especially in the detection of complex backgrounds and small targets, such as… Figure 5 to 6 As shown.
[0065] To further improve the system's accuracy, this invention incorporates advanced image preprocessing techniques, such as noise removal, image enhancement, and size normalization, to ensure input image quality and effectively reduce external noise interference. This innovative processing flow enables the system to accurately identify and classify different types of coccidiosis parasite eggs in sheep within a short time, significantly improving overall diagnostic efficiency.
[0066] During the data analysis phase, this invention designs an intelligent analysis method that provides aquaculture managers with scientific and accurate decision-making support by calculating infection density in real time and combining it with regional and seasonal trend analysis. Furthermore, the system possesses powerful visualization capabilities, generating infection trend heatmaps and detailed reports to help users comprehensively understand the parasite infection status and provide strong support for prevention and control decisions.
[0067] The intelligent detection and analysis solution provided by this invention has significant advantages in terms of accuracy, automation, and real-time performance. In practical applications, the automation level of this system is increased by about 90%, and the labor cost is effectively reduced by about 70%. It can be widely used in sheep coccidiosis detection, disease prevention and control, and agricultural breeding, providing the breeding industry with an efficient and intelligent tool and significantly improving the prevention and control efficiency of sheep coccidiosis.
[0068] The technical means disclosed in this invention are not limited to those disclosed in the above embodiments, but also include technical solutions composed of any combination of the above technical features. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications are also considered within the scope of protection of this invention.
Claims
1. A method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning, characterized by: Includes the following steps, Step 1: Image collection and preprocessing; (S11): Automatically collect images of sheep coccidiosis parasite eggs; (S12): Perform image noise removal and image enhancement processing on the sample image; (S13): After adding processing to the image, perform image size standardization processing; Step 2: Input the preprocessed image into the automatic detection model for sheep coccidiosis parasite eggs for training, and use the deep learning model to automatically detect sheep coccidiosis parasite eggs; (S21): Construct a framework for detecting parasite eggs in sheep coccidiosis; (S22): The detection model framework embeds a shift window Transformer module and a normalized attention mechanism; Step 3: Analyze the data and generate a report on the number of coccidiosis parasite eggs output by the deep learning model; (S31): Statistical analysis of the number of parasite eggs and infection density analysis of coccidiosis in sheep; (S32): Visualize the results and generate a test report.
2. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In (S11), a microscope and camera are used to automatically acquire microscopic images of sheep feces samples. The formula for acquiring each sample image is as follows: I i =f ( x,y ) in, I i This represents the first acquired image. f ( x,y ) is the image function output by the acquisition device. x and y Represents the spatial coordinates of the image.
3. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In step (S12), median filtering or Gaussian filtering is used for noise reduction. Let the original image have [number] pixels. I ( x,y The image with noise removal has the following pixel count: I'(x,y) Therefore, the Gaussian filtering formula is: in, w ( i,j ) is the Gaussian filter kernel, k This represents the "half-width" of the Gaussian filter kernel, or the "half-size" of the kernel, which controls the size of the filtering region.
4. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In (S12), contrast adjustment and histogram equalization are used for image enhancement. The formula for histogram equalization is: in, min ( I ) and max ( I ) are image pixels I ( x,y The minimum and maximum values of ) I enhanced ( x,y (This is the enhanced image.) 5. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In (S13), the size normalization process is performed using bilinear interpolation. The formula for bilinear interpolation is: in, I resized ( x',y' () represents the pixel values of the adjusted image. N ( x',y' ) is related to the target location ( x',y' The corresponding neighboring pixels, w ( x,y ) is the interpolation weight.
6. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: The detection model framework is the YOLOv5s-ST detection architecture, which includes a cross-stage feature extraction network CSPDarknet, a multi-scale feature fusion module PANet, and an optimized detection head. The improved YOLOv5s-ST detection architecture also embeds a shift window Transformer and a normalized attention mechanism NAM.
7. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: The Transformer module for shifting windows described in (S22) adopts a hierarchical local window partitioning strategy to perform self-attention calculations within non-overlapping windows; it establishes long-range dependencies through a cross-window displacement mechanism to balance global feature modeling and computational efficiency. The layered window partitioning strategy of the shift window Transformer module reduces computational complexity while retaining the ability to model long-range dependencies; in specific implementation, the encoder of the shift window Transformer module is embedded in each detection head. Let the input feature tensor be After linear mapping, the query matrix is obtained. P Key matrix M Value matrix N The query matrix P Key matrix M Value matrix N, These are used respectively for self-attention calculation in the Transformer module of the shift window; in, , L=H×W , H Represents image height, W Represents the image width. L D represents the image area, D is the dimension of the input feature (number of channels), and D′ is the embedding dimension after linear mapping. The Transformer module employs a non-overlapping window partitioning strategy to segment the feature map into... k×k Within a window, local attention calculations are performed. The attention weight matrix S is calculated as follows: S = softmax ( PM T ) U=SN In the formula, Characterizes the strength of the correlation between feature points. U For attention-enhanced feature representation, P For query matrix (Query), M The key matrix (Key) M T This is the transpose of the key matrix. PM T To calculate the similarity between the query and the key using the dot product; Comparison of defined complexities: Θ ( MHA ) =4HWD 2 +2 ( HW ) 2 D Θ ( W-MHA ) =4HWD 2 +2τ 2 HWD The purpose of defining the complexity comparison is to evaluate the change in computational efficiency of the model after introducing the window attention mechanism. In the formula, Θ ( ∙ () indicates the time complexity of the operation; MHA This refers to Multi-Head Attention, or global multi-head attention. W-MHA This is Windowed Multi-Head Attention, which limits the attention computation to a local window. τ Indicates the size of the attention window; The shifted window Transformer module encoder includes a window attention sublayer and a multilayer perceptron (MLP), with residual connections used to mitigate gradient decay.
8. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In (S22), the normalized attention mechanism optimizes the weights through channel-space dual-path attention and dynamically allocates feature weights using the batch normalized BN scaling factor. The model's sensitivity to details of insect eggs is enhanced by using a five-level cascaded NAM module, and background interference is suppressed under lightweight computation conditions. For the channel dimension: Channel weights are evaluated using a scaling factor based on batch normalization (BN). Let the input features be Channel attention weight W C The calculation formula is: W C = σ ( ϕ ( BN ( G C ))) in, ϕ This represents the learnable scaling parameter. σ Use the Sigmoid activation function; For the spatial dimension: for feature maps Perform spatial normalization, weights W S The calculation is as follows: W S = σ ( ψ ( BN S ( G S ))) In the formula, ψ Parameters for scaling spatial dimensions.
9. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In (S31), the method for counting the number of coccidiosis parasite eggs and analyzing the infection density in sheep includes the following steps: S311): In the preprocessed image, the coccidiosis parasite eggs of sheep are detected and counted. The method for detecting and counting the coccidiosis parasite eggs of sheep is to process the image using a segmentation algorithm and extract the region of the coccidiosis parasite eggs of sheep. Assuming the region of sheep coccidiosis parasite eggs obtained through segmentation is M i Then, the number of coccidiosis parasite eggs in each image is calculated as follows: N i This can be accomplished by counting the regions: in, δ ( M ij ) is an indicator function, when M ij When it is the egg of the coccidiosis parasite in sheep, δ ( M ij )=1, otherwise δ ( M ij )=0; S312): Infection density analysis of the number of coccidiosis parasite eggs in sheep, assuming A i Let D be the effective area of the image, in mm², then the infection density D of the i-th image is... i It can be calculated using the following formula: Calculate the average infection level D for all images. avg : Where n is the total number of images, the density of coccidiosis parasite eggs in the sample is initially assessed by the infection density.
10. The method for accurate detection of coccidiosis parasite eggs in sheep based on deep learning according to claim 1, characterized in that: In (S32), the visualization method uses heatmaps or bar charts to show the infection density in different regions and at different time points; assuming the infection density of the result is D. i The following formula can be used to generate a heatmap: Where H i (x,y) represents the normalized heatmap values, D region This represents the maximum infection density in the region. The report generation module is used to generate a test report, which includes statistics on the number of coccidiosis parasite eggs, infection density analysis, and regional and seasonal infection trends. The process of generating the test report can be represented as follows: R=f(D i ,D r ,H i ) Where R is the generated report, and D is... i It is the infection density data in the image, D r This is regional infection density data, H i It is heatmap data.
Citation Information
Cited By
Chicken coccidian oocyst identification method, device and equipment, storage medium and program product
CN121838139A
Method, device, equipment, storage medium and program product for recognizing chicken coccidian oocysts
CN121838139B
