Next Article in Journal
Effects of Implementing the Digital Storytelling Strategy on Improving the Use of Various Forms of the Passive Voice in Undergraduate EFL Students’ Oral Skills at the University Level
Previous Article in Journal
Cybersecurity Transformation: Cyber-Resilient IT Project Management Framework
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

YOLOv8-Based Estimation of Estrus in Sows Through Reproductive Organ Swelling Analysis Using a Single Camera

Electrical and Computer Engineering, University of Memphis, Memphis, TN 38111, USA
*
Author to whom correspondence should be addressed.
Digital 2024, 4(4), 898-913; https://doi.org/10.3390/digital4040044
Submission received: 16 September 2024 / Revised: 13 October 2024 / Accepted: 24 October 2024 / Published: 27 October 2024

Abstract

:
Accurate and efficient estrus detection in sows is crucial in modern agricultural practices to ensure optimal reproductive health and successful breeding outcomes. A non-contact method using computer vision to detect a change in a sow’s vulva size holds great promise for automating and enhancing this critical process. However, achieving precise and reliable results depends heavily on maintaining a consistent camera distance during image capture. Variations in camera distance can lead to erroneous estrus estimations, potentially resulting in missed breeding opportunities or false positives. To address this challenge, we propose a robust six-step methodology, accompanied by three stages of evaluation. First, we carefully annotated masks around the vulva to ensure an accurate pixel perimeter calculation of its shape. Next, we meticulously identified keypoints on the sow’s vulva, which enabled precise tracking and analysis of its features. We then harnessed the power of machine learning to train our model using annotated images, which facilitated keypoint detection and segmentation with the state-of-the-art YOLOv8 algorithm. By identifying the keypoints, we performed precise calculations of the Euclidean distances: first, between each labium (horizontal distance), and second, between the clitoris and the perineum (vertical distance). Additionally, by segmenting the vulva’s size, we gained valuable insights into its shape, which helped with performing precise perimeter measurements. Equally important was our effort to calibrate the camera using monocular depth estimation. This calibration helped establish a functional relationship between the measurements on the image (such as the distances between the labia and from the clitoris to the perineum, and the vulva perimeter) and the depth distance to the camera, which enabled accurate adjustments and calibration for our analysis. Lastly, we present a classification method for distinguishing between estrus and non-estrus states in subjects based on the pixel width, pixel length, and perimeter measurements. The method calculated the Euclidean distances between a new data point and reference points from two datasets: “estrus data” and “not estrus data”. Using custom distance functions, we computed the distances for each measurement dimension and aggregated them to determine the overall similarity. The classification process involved identifying the three nearest neighbors of the datasets and employing a majority voting mechanism to assign a label. A new data point was classified as “estrus” if the majority of the nearest neighbors were labeled as estrus; otherwise, it was classified as “non-estrus”. This method provided a robust approach for automated classification, which aided in more accurate and efficient detection of the estrus states. To validate our approach, we propose three evaluation stages. In the first stage, we calculated the Mean Squared Error (MSE) between the ground truth keypoints of the labia distance and the distance between the predicted keypoints, and we performed the same calculation for the distance between the clitoris and perineum. Then, we provided a quantitative analysis and performance comparison, including a comparison between our previous U-Net model and our new YOLOv8 segmentation model. This comparison focused on each model’s performance in terms of accuracy and speed, which highlighted the advantages of our new approach. Lastly, we evaluated the estrus–not-estrus classification model by defining the confusion matrix. By using this comprehensive approach, we significantly enhanced the accuracy of estrus detection in sows while effectively mitigating human errors and resource wastage. The automation and optimization of this critical process hold the potential to revolutionize estrus detection in agriculture, which will contribute to improved reproductive health management and elevate breeding outcomes to new heights. Through extensive evaluation and experimentation, our research aimed to demonstrate the transformative capabilities of computer vision techniques, paving the way for more advanced and efficient practices in the agricultural domain.

1. Introduction

Artificial insemination (AI) [1] is the most commonly used reproductive technology in pig farming. However, the best time to inseminate is still determined by technicians who subjectively assess the sow’s behavior and physical signs to detect the start of estrus. Vulva swelling and reddening are signs of approaching estrus and are often checked to detect estrus [2]. This occurs due to increased blood flow due to a rise in the estrogen level during estrus events, causing an increase in the vulva size [3], which can be used as a strong indicator of estrus events. Manually detecting these changes presents significant challenges due to the limited number of farm workers, who must individually measure each sow and compare these measurements with previous data to ascertain whether the sow is in estrus [4]. A significant amount of money is expended, with approximately 30% of the total labor input dedicated to detecting estrus [5]. This is where computer vision offers substantial benefits by automating the detection process on large-scale farms, thereby reducing costs, saving time, and alleviating labor shortages. Technological tools and AI-based models can be used to monitor sow physiological parameters in real time for timely and accurate estrus detection, which directly impacts the breeding efficiency, conception rates, and litter sizes [6]. When using computer vision to monitor the reproductive health of sows, it is crucial to account for the camera’s distance from the vulva. Accurate distance measurement helps ensure the reliability of our analysis and prevents errors in estimating estrus. For instance, if the camera is positioned at varying distances while capturing images of a sow’s vulva, it may lead to incorrect estrus estimations. A closer camera might make the vulva appear larger, potentially resulting in false positives, where the system wrongly identifies a sow as being in heat. Conversely, if the camera is farther away, the vulva might appear smaller, leading to missed detections of estrus. This can significantly impact breeding outcomes. The primary objective of this research was to accurately detect the estrus cycle in sows by analyzing variations in vulva size measurements while considering the camera distance. To achieve this goal, we relied on a study [7] that provided detailed measurements of the average size of a sow’s vulva. According to this research, the typical width of the vulva, measured between the labia, is approximately 3.77 ± 0.05 cm, and the length measured between the clitoris and the perineum is about 5.67 ± 0.10 cm. The study also highlighted that during the breeding period, the size of a sow’s vulva increases due to swelling caused by elevated estrogen levels. This swelling usually occurs 2–3 days before estrus and serves as a key indicator of the sow being in heat. The vulva size can increase significantly, with some sources indicating a swelling of up to 30% or more from the normal size, while the mean percentage of swelling in a sample of 30 sows was 9.02% ± 0.27% according to the same study. In our research, we began by using YOLOv8 segmentation [8] to evaluate the overall size of the vulva by tracking changes in its perimeter. Additionally, we employed YOLOv8 [9] to detect and identify four specific keypoints, which allowed us to precisely measure the vulva’s width and length. Our research involved calibrating the camera using monocular depth estimation to accurately measure the distances on the image, such as the labia distance, clitoris-to-perineum distance, and vulva perimeter. We propose a classification method to distinguish between estrus and non-estrus states by analyzing the pixel width, length, and perimeter of the new vulva’s data. This method calculates the Euclidean distances from the new data to existing points and uses majority voting to determine which category the new data most closely aligns with, indicating whether the new vulva is best represented by the estrus or non-estrus function. This method automates the classification process, improving the accuracy and efficiency when detecting estrus states.
This paper thoroughly examines the theoretical principles that underpin the methods used. Section 3 provides an in-depth explanation of our proposed system, detailing its intricacies and emphasizing the rationale behind our approach. Furthermore, Section 4 focuses on the comprehensive experimental results, demonstrating the performance and effectiveness of our methodology. Additionally, this section evaluates the results of our research using three evaluation stages: calculating the Mean Squared Error (MSE) between the ground truth and predicted keypoints, comparing the performance of our YOLOv8 model with the previous U-Net model [10], and evaluating the classification model using a confusion matrix. Meanwhile, Section 5 provides conclusive remarks based on our findings and outlines potential avenues for future expansion and refinement of this work.

2. Background

The detection of estrus in sows is a pivotal aspect of swine reproduction management, with significant implications for agricultural productivity and animal welfare. Accurate estrus detection ensures timely breeding, which is essential for maximizing the reproductive efficiency and maintaining the health of the breeding stock. Traditional methods of estrus detection, which often involve manual observation and physical examinations, are labor-intensive and prone to human error. These challenges have driven the need for automated and non-invasive techniques to enhance the precision and efficiency of estrus detection.
The global agricultural landscape is undergoing a profound transformation driven by technological innovations. Among these innovations, machine learning and deep learning have emerged as game changers, reshaping farming operations. Recent advancements in object detection and segmentation techniques [11,12] have found widespread applications across various domains. These methodologies have been widely researched and applied in various areas, including autonomous driving [13], medical imaging [14], and industrial automation [15,16]. The evolution of deep learning algorithms, particularly convolutional neural networks (CNNs) [17], has revolutionized many fields [18,19]; in particular, computer vision, driven by these advancements, has shown its value in improving processes across multiple sectors, including healthcare [20,21], security [22], farming studies [23], and 3D reconstruction [24]. Additionally, efficient data processing [25] is crucial before applying any machine or deep learning methods, enabling precise analyses that are critical for optimizing agricultural practices and enhancing decision making in farming.
Recent advancements in computer vision and machine learning have opened new avenues for automating various agricultural processes, including estrus detection [26]. By leveraging these technologies, researchers aim to develop systems that can continuously monitor animals and provide real-time data on their physiological states. One promising approach is the use of computer vision to detect a change in the vulva size of a sow, which is a key indicator of estrus [27]. However, the success of such systems heavily relies on the consistency and accuracy of image capture, as variations in camera distance can significantly affect the measurement outcomes. Some studies focused on sow behavior for estrus detection [28], while others relied on the redness of the vulva [29]. However, according to a survey, five out of six sow farms achieved a high farrowing rate greater than 85% by detecting estrus through the sign of a swollen vulva [30], which is considered the most reliable method.

3. Method Overview

The dataset utilized in this study was collected by the Sivananthan lab on a large farm housing numerous sows, providing a comprehensive representation of various real-world conditions. To ensure diverse lighting scenarios, images were captured three times daily at 10 a.m., 2 p.m., and 6 p.m. over a four-month period. This time-based collection approach effectively captured natural variations in brightness, shadows, and the behavior of the sows throughout the day. While there were slight variations in the camera angles during the image capture, these adjustments were minimal and did not significantly impact the estimation of estrus. The angle changes were carefully controlled to avoid distorting the size or appearance of the vulva, thereby ensuring reliable estrus detection, even with considerations for camera distance. This dataset’s design allows for robust analysis and improves the model’s ability to generalize across different conditions.
YOLOv8 was selected for this research because it effectively combines keypoint detection and segmentation tasks within a single model, providing a streamlined solution. While there are other models that may offer slightly better segmentation accuracy, YOLOv8 achieves an optimal balance between speed and accuracy, making it particularly suitable for real-time applications, like estrus detection in sows. Its robust detection and tracking capabilities ensure consistent performance, even when the sow is in motion or when there are slight changes in the camera angles, thus maintaining accuracy in dynamic conditions. This integrated functionality simplifies the research process, enabling efficient analysis without sacrificing performance.
In this comprehensive overview, we detail our research methodology for an accurate analysis. Initially, we generated masks around the vulva in the images and trained our models using the annotated images with YOLOv8 segmentation. Following this, we annotated four keypoints on the sow’s vulva, specifically the labia, clitoris, and perineum, and trained these keypoints using YOLOv8 for the precise detection and tracking of its features. The third step involved performing precise calculations of the Euclidean distances: first, measuring the horizontal distance between the labia, and second, measuring the distance between the clitoris and the perineum. Additionally, the segmentation model of the vulva helped us to obtain valuable insights into its shape, which facilitated accurate perimeter measurements. In the fourth step, we calibrated the camera using monocular depth estimation, which led to the fifth step, where we linked image measurements to depth distances and created corresponding functions. Finally, we classified the estrus and non-estrus states of new points based on the nearest neighbors method. Figure 1 illustrates our complete pipeline.

3.1. Vulva Segmentation

In our quest to enhance estrus detection in sows, the initial and crucial step involved the precise detection and tracking of the reproductive organ, specifically the vulva. To achieve this, we implemented the YOLOv8 segmentation model and leveraged its advanced capabilities for accurate and efficient segmentation. Our methodology built upon the foundation established in our previous study, where we utilized the U-Net architecture for similar purposes [10]. However, unlike U-Net, our new model with YOLOv8 offers significant improvements in both accuracy and processing speed for detecting the vulva. The enhanced performance of YOLOv8 can be attributed to its superior architecture and optimized training procedures, which are crucial for real-time applications in estrus detection. The segmentation process commenced with meticulous labeling of the vulva’s exact shape. This precise annotation was paramount to training the model effectively, ensuring that it could accurately discern the vulva amidst varying conditions and appearances. Figure 2 illustrates the detailed labeling process, highlighting the importance of accurate ground truth data for model training. Subsequently, we trained the YOLOv8 model using the same dataset employed in our previous segmentation study. This consistency in data ensured a fair comparison between the performance of U-Net and YOLOv8. The dataset comprised images meticulously labeled to reflect the vulva’s diverse presentations, which facilitated robust model learning. The results of our experiments indicate a marked improvement in vulva segmentation accuracy and speed with YOLOv8.
The segmentation of the vulva not only provided detailed insights into its morphology but also facilitated accurate perimeter measurements. These measurements were pivotal for our subsequent steps aimed at estimating estrus in sows. By leveraging the enhanced capabilities of YOLOv8, we could achieve a more reliable and efficient identification process, which was crucial for the overall success of our estrus detection system.

3.2. Keypoints Detection

In the second step of our method, we concentrated on annotating the images to mark four keypoints on the vulva. These keypoints represented the two labia, clitoris, and perineum, which enabled accurate analysis and tracking of the sow’s vulva. This careful annotation helped in achieving precise calculations of the vulva’s width and length. By accurately marking these keypoints, we ensured that the model received high-quality training data, which were crucial for reliable performance. Once the images were meticulously annotated, we proceeded to train the model using YOLOv8, a state-of-the-art object detection algorithm known for its efficiency and accuracy. YOLOv8 is particularly suited for this task due to its ability to process images in real time while maintaining high precision in detecting and localizing objects. The annotated keypoints served as the ground truth for training YOLOv8, which allowed it to learn to identify and track the vulva’s keypoints effectively. During the training process, we used the same large dataset of annotated images that was used in the segmentation training to teach the model to recognize the keypoints under various conditions and angles. This extensive training ensured that the model can generalize well to new, unseen images, making it robust and reliable in practical applications. The trained model can then be used to automatically annotate new images, significantly speeding up the analysis process and reducing the potential for human error. Furthermore, the precise locations of these points obtained from the annotated images can be used to track changes in the vulva’s width and length over time, providing valuable insights into the sow’s reproductive health and cycle. Figure 3 illustrates an example of an annotated image, showcasing the accuracy and effectiveness of our annotation process. By integrating YOLOv8 into our workflow, we enhanced the overall efficiency and reliability of the vulva analysis.

3.3. Euclidean Distances Calculation

Utilizing the trained model’s ability to detect and track keypoints, we calculated the Euclidean distances between the essential vulva points: first, the horizontal distance between each labium, and second, the distance between the clitoris and the perineum. Precise measurement of these distances was crucial for understanding vulva morphology, which aided in our analysis and subsequent estrus detection, which involved calibrating the camera using monocular depth estimation. To obtain these Euclidean distances in pixels, we needed coordinates for each point in the image.
In Figure 4, let us denote the coordinates of each labium as P 1 ( x 1 , y 1 ) and P 2 ( x 2 , y 2 ) . The Euclidean distance (c) between each labium can be calculated using the distance formula:
c l a b i u m = ( x 2 x 1 ) 2 + ( y 2 y 1 ) 2
By calculating these Euclidean distances, we gained valuable insights into the shape features of the sow’s vulva, which significantly contributed to our analysis and subsequent estrus detection accuracy.

3.4. Calibrating the Camera Using Monocular Depth Estimation

In agriculture, when using computer vision to monitor a sow’s reproductive health, it is crucial to consider the camera’s distance from the vulva. Variations in camera distance can cause the vulva to appear larger or smaller, leading to false positives or missed estrus detections, which can significantly affect breeding outcomes. Accurate distance measurement ensures reliable estrus estimation and improves the analysis accuracy.
Our dataset included images of sow vulvas captured from multiple distances, with each image providing pixel measurements for the width, length, and perimeter. Since all images were taken with the same camera, the focal length, sensor width, and pixel dimensions remained consistent. According to the study [7], the average dimensions of the vulva are as follows: for non-estrus, the width is 3.77 cm, the length is 5.67 cm, and the perimeter is 16.06 cm; for estrus, the width is 4.16 cm, the length is 6.13 cm, and the perimeter is 17.43 cm. Using this information, we could begin our method by converting the pixel measurements to physical dimensions. We calculated the pixel size using the formula:
Pixel Size = Sensor Width Image Width in Pixels
or
Pixel Size = Sensor length Image length in Pixels
Next, we converted the pixel width, length, and perimeter to physical measurements using the following formulas:
w = w p × Pixel Size , l = l p × Pixel Size , p = p p × Pixel Size
For the monocular depth estimation, as in Figure 5, we determined the distance from the camera using these equations:
d w = W × f w , d l = L × f l , d p = P × f p
where
  • w p is the width in pixels;
  • l p is the length in pixels;
  • p p is the perimeter in pixels;
  • d w is the distance from the camera based on the width;
  • d l is the distance from the camera based on the length;
  • d p is the distance from the camera based on the perimeter;
  • W is the real vulva width;
  • L is the real vulva length;
  • P is the real vulva perimeter;
  • f is the focal length;
  • w is the physical width;
  • l is the physical length;
  • p is the physical perimeter.
These measurements assisted us in identifying a suitable function that accurately represented the relationship between each of the width, length, and perimeter measurements on one hand, and the depth distance from the camera on the other hand.

3.5. Function Discovery

Establishing a function that accurately represents the relationship between the Euclidean distances in the image and the actual depth distance from the camera is crucial for adjusting our analysis to account for varying camera positions. To achieve this, we developed six distinct functions to model the relationships between the width, length, and perimeter of the vulva for both the estrus and non-estrus states. Specifically, there are two functions each for width, length, and perimeter: one corresponding to the estrus state and the other to the non-estrus state. These functions encapsulate the variations in the vulva dimensions between the two estrus states and provide a basis for comparing new data points to determine their classification.
Figure 6 illustrates these functions, which allowed us to make precise adjustments to our estrus detection algorithm and ensure consistent and reliable results despite variations in the camera distance.

3.6. Classification Based on K-Nearest Neighbors (KNNs)

K-nearest neighbors (KNNs) is a simple and powerful supervised learning algorithm used for classification and regression tasks in machine learning. The core idea behind KNNs is to classify a data point based on the categories of its nearest neighbors. It is an instance-based learning method, meaning it does not create an explicit model during training but rather memorizes the training dataset. When a new data point needs to be classified, the KNN algorithm searches the entire training set to find the K training examples closest to the new point, as shown in Figure 7. The process begins with the selection of the parameter K, which determines the number of nearest neighbors to consider. The most common distance metric used in KNNs is the Euclidean distance, which measures the straight-line distance between two points in a multidimensional space. For each new data point, the algorithm calculates the distance to all other points in the training dataset. It then selects the K points that are closest to the new data point. The majority class among these K neighbors is assigned as the class for the new data point. In the case of regression, the algorithm typically averages the values of the K nearest neighbors to predict the output for the new point. In our algorithm, we calculated the Euclidean distances from new data points to existing points or functions and used majority voting to classify the data as either estrus or non-estrus based on the closest match. Specifically, we used a K value of 3, which meant we looked at the three closest points to make our classification decision. This approach ensured that the classification was based on a consensus of the nearest data points, which led to more accurate and reliable predictions.

4. Results and Evaluation

In this study, we developed and evaluated a comprehensive approach for estrus detection in sows using advanced computer vision techniques. We employed two distinct YOLOv8 models: one for keypoint detection and the other for segmentation of the vulva. The keypoint detection model was carefully assessed using the Mean Squared Error (MSE) to ensure a high precision in locating critical features. The segmentation model was evaluated through the Intersection over Union (IoU), mean Average Precision at 50% overlap (mAP50), and mean Average Precision at 50–95% overlap (mAP50-95), which provided a thorough assessment of its performance in accurately segmenting the vulva.
Our results were evaluated on a dataset of 2437 unseen images, which comprised 1226 images of sows in estrus and the remaining images represented non-estrus states. The classification model, evaluated through a detailed confusion matrix, exhibited high accuracy and consistency in differentiating between the estrus and non-estrus states. These findings underscored the effectiveness and reliability of our methodology and offered a significant advancement in automating and optimizing estrus detection processes in agricultural settings.

4.1. Mean Squared Error (MSE) Analysis

To validate the accuracy of our keypoint predictions, we calculated the Mean Squared Error (MSE) and Root Mean Squared Error (RMSE) between the ground truth keypoints and the predicted keypoints for two specific measurements: the labia distance and the distance between the clitoris and the perineum. For a detailed comparison of these metrics, refer to Table 1. This table shows the evaluation metrics for the distances between the keypoints, as shown in Figure 8. These metrics helped quantify the performance of our model in detecting and measuring the spatial relationships between keypoints.
We conducted the evaluation on an unseen dataset of 2437 images, with a resolution of 640 × 480 pixels. The metrics considered were the average error, MSE, and RMSE for two keypoint pairs:
  • Keypoint 1 to Keypoint 3 (vertical distance):
    Average error: The average error in the distances between Keypoint 1 and Keypoint 3 was 7.81 pixels. This value represents the mean discrepancy between the predicted and actual distances.
    Mean Squared Error (MSE): The MSE for the distances between Keypoint 1 and Keypoint 3 was 142.70 pixels2. This metric measures the average of the squares of the errors, providing an indication of the magnitude of the error.
    Root Mean Squared Error (RMSE): The RMSE for Keypoint 1 to Keypoint 3 was 11.95 pixels. The RMSE is the square root of the MSE and offers a direct measure of the average magnitude of the error in the same units as the original data.
  • Keypoint 2 to Keypoint 4 (horizontal distance):
    Average error: The average error in the distances between Keypoint 2 and Keypoint 4 was 5.43 pixels. This value indicates the mean discrepancy between predicted and actual distances.
    Mean Squared Error (MSE): The MSE for the distances between Keypoint 2 and Keypoint 4 was 62.73 pixels2. This metric reflects the average of the squared differences between the predicted and actual values.
    Root Mean Squared Error (RMSE): The RMSE for Keypoint 2 to Keypoint 4 was 7.92 pixels. As with the previous pair, the RMSE provides a measure of the average magnitude of the error, expressed in the same units as the distance.
The evaluation results suggest that our model accurately predicted the distances between the keypoints, as evidenced by the relatively low RMSE values. Specifically, the RMSE for the distance between Keypoint 2 and Keypoint 4 was significantly lower compared with the RMSE for Keypoint 1 and Keypoint 3. This discrepancy was likely because, according to the study by [7], the distance between the clitoris and the perineum is generally about twice as long as the distance between the labia.
The MSE values illustrate the magnitude of the deviations in squared units, highlighting the influence of larger errors. In contrast, the RMSE provides a more intuitive measure of the error by translating the squared errors into the original units of measurement. By examining both the MSE and RMSE, we could better understand the overall accuracy of the keypoint detection system and pinpoint areas for improvement. While the MSE reveals the error magnitude in squared units, the RMSE offers a clearer view of the average error size, making it easier to interpret and compare with the original data.

4.2. Quantitative Analysis and Performance Comparison

The performance of the YOLOv8 segmentation model was evaluated using several metrics to ensure its effectiveness in accurately segmenting the sows’ vulvas. Table 2 shows the detailed comparison between the YOLOv8 segmentation model we used in this study and our U-Net model from the previous study. The Intersection over Union (IoU) score was 0.725, indicating a high degree of overlap between the predicted segmentation and the ground truth. Additionally, the mean Average Precision at 50% overlap (mAP50) was 0.804, demonstrating the model’s strong ability to correctly identify and segment the vulvas at this threshold. The mean Average Precision at 50–95% overlap (mAP50-95) was 0.678, reflecting robust performance across a range of IoU thresholds. These results suggest that YOLOv8 provided substantial improvements in segmentation accuracy compared with the U-Net model. These results are excellent, suggesting that YOLOv8 provided substantial improvements in segmentation accuracy compared with the U-Net model, as shown in Figure 9, making it a highly effective tool for this application.

4.3. Estrus–Not-Estrus Classification Model Evaluation

To evaluate the performance of the classification model, we analyzed its output through a confusion matrix. The dataset comprised a total of 2437 images, with 1226 labeled as positive and the remainder as negative. Based on the evaluation results, the model achieved a true positive rate of 94.53% and a true negative rate of 96.11%. The confusion matrix in Figure 10 is presented in two formats: one that shows the raw counts of the images and the other depicts the values as percentages. These confusion matrix heatmaps, displayed side by side, allowed for a detailed assessment of the model’s accuracy and performance, with labels that indicate both the predicted and actual classes. This dual-format representation provided a clear and comprehensive overview of the model’s effectiveness in distinguishing between the estrus and non-estrus states.
The results in Figure 11 illustrate the effectiveness and precision of our method for detecting the estrus cycle in sows. Despite both images being captured from roughly the same camera distance, our model successfully differentiated between sows in estrus and those not in estrus, indicating that the camera distance no longer influenced the model’s detection capability.
In addition to the confusion matrix, we summarized the evaluation metrics for the estrus detection model in Table 3. This table presents the key performance indicators: accuracy (95.2%), precision (96.0%), recall (94.5%), and F1-score (95.2%). These metrics provide a comprehensive view of the model’s effectiveness, complementing the visual representation of the confusion matrix and offering insight into the model’s reliability and overall performance.

5. Conclusions and Future Work

The development and implementation of our comprehensive methodology for estrus detection in sows represents a significant advancement in agricultural technology. By leveraging non-contact computer vision techniques to monitor changes in vulva size, our approach enhances the precision and efficiency of estrus detection, ultimately improving reproductive health and breeding outcomes.
Our six-step methodology, incorporating careful image annotation, advanced YOLOv8-based keypoint detection, and segmentation, alongside robust camera calibration through monocular depth estimation, ensures a high level of accuracy. The proposed classification method, which distinguishes between estrus and non-estrus states based on the K-nearest neighbors model, offers a reliable framework for automated detection.
The effectiveness of our approach was validated through multiple evaluation stages, including comparisons of different models and analyses of key performance metrics. The improvements over previous models highlight the potential of our method to provide more accurate and efficient estrus detection.
YOLOv8 was proved to be highly effective for both keypoint detection and vulva segmentation, where it demonstrated superior performance compared with previous U-Net segmentation models. This effectiveness underscored the model’s precision in spatial measurements and its ability to accurately delineate vulva contours, which is crucial for precise estrus detection. Our estrus classification model showed strong performance in distinguishing between estrus and non-estrus states. The high level of accuracy and consistency reflected the robustness of our automated detection system.
Looking ahead, future work will focus on utilizing thermal imaging to estimate estrus based on vulva temperature, with consideration given to the camera distance. This approach could offer additional insights and further enhance the precision of estrus detection, contributing to more advanced and efficient agricultural practices.
Overall, our methodology significantly advances estrus detection in agricultural practices by automating and optimizing the process through computer vision techniques. This advancement reduces human error and enhances the reliability of reproductive health management in sows, paving the way for more advanced and efficient agricultural practices with potential benefits for breeding outcomes and livestock health.

Author Contributions

Conceptualization, I.A.; methodology, I.A.; software, I.A.; validation, I.A.; formal analysis, I.A.; investigation, I.A.; resources, A.L.R.; data curation, I.A. and M.A.; writing—original draft preparation, I.A.; writing—review and editing, I.A. and M.A.; visualization, I.A.; supervision, A.L.R.; project administration, A.L.R.; funding acquisition, A.L.R. All authors read and agreed to the published version of this manuscript.

Funding

This research received no external funding.

Data Availability Statement

Restrictions apply to the availability of these data. Data were obtained from Sivananthan lab and are available from authors with permission from Sivananthan lab.

Acknowledgments

The authors thank Sivananthan Laboratories for providing the dataset used in this study.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Singh, B.; Mal, G.; Gautam, S.K.; Mukesh, M. Advances in Animal Biotechnology; Springer: Berlin/Heidelberg, Germany, 2019. [Google Scholar]
  2. Belstra, I.M.V. International Corporation, Flowers North Carolina State University, Todd See North Carolina State University, Singleton Purdue University Detection of Estrus or Heat. Pork Information Gateway, Type: Factsheets. 31 July 2007, PIG 08-01-01. Available online: https://porkgateway.org/resource/estrus-or-heat-detection/ (accessed on 15 September 2024).
  3. Ford, S.; Reynolds, L.; Magness, R. Blood flow to the uterine and ovarian vascular beds of gilts during the estrous cycle or early pregnancy. Biol. Reprod. 1982, 27, 878–885. [Google Scholar] [CrossRef] [PubMed]
  4. Scolari, S.C.; Clark, S.G.; Knox, R.V.; Tamassia, M.A. Vulvar skin temperature changes significantly during estrus in swine as determined by digital infrared thermography. J. Swine Health Prod. 2011, 19, 151–155. [Google Scholar] [CrossRef] [PubMed]
  5. Yeste, M.; Estrada, E.; Pinart, E.; Bonet, S.; Miró, J.; Rodríguez-Gil, J.E. The improving effect of reduced glutathione on boar sperm cryotolerance is related with the intrinsic ejaculate freezability. Cryobiology 2014, 68, 251–261. [Google Scholar] [CrossRef] [PubMed]
  6. Kraeling, R.R.; Webel, S.K. Current strategies for reproductive management of gilts and sows in North America. J. Anim. Sci. Biotechnol. 2015, 6, 3. [Google Scholar] [CrossRef] [PubMed]
  7. De la Cruz-Vigo, P.; Rodriguez-Boñal, A.; Rodriguez-Bonilla, A.; Córdova-Izquierdo, A.; Pérez Garnelo, S.S.; Gómez-Fidalgo, E.; Martín-Lluch, M.; Sánchez-Sánchez, R. Morphometric changes on the vulva from proestrus to oestrus of nulliparous and multiparous HYPERPROLIFIC sows. Reprod. Domest. Anim. 2022, 57, 94–97. [Google Scholar] [CrossRef] [PubMed]
  8. Yue, X.; Qi, K.; Na, X.; Zhang, Y.; Liu, Y.; Liu, C. Improved YOLOv8-Seg network for instance segmentation of healthy and diseased tomato plants in the growth stage. Agriculture 2023, 13, 1643. [Google Scholar] [CrossRef]
  9. Terven, J.; Córdova-Esparza, D.M.; Romero-González, J.A. A comprehensive review of yolo architectures in computer vision: From yolov1 to yolov8 and yolo-nas. Mach. Learn. Knowl. Extr. 2023, 5, 1680–1716. [Google Scholar] [CrossRef]
  10. Almadani, I.; Ramos, B.; Abuhussein, M.; Robinson, A.L. Advanced Swine Management: Infrared Imaging for Precise Localization of Reproductive Organs in Livestock Monitoring. Digital 2024, 4, 446–460. [Google Scholar] [CrossRef]
  11. Barbole, D.K.; Jadhav, P.M.; Patil, S. A review on fruit detection and segmentation techniques in agricultural field. In Second International Conference on Image Processing and Capsule Networks: ICIPCN 2021 2; Springer: Berlin/Heidelberg, Germany, 2022; pp. 269–288. [Google Scholar]
  12. Qiao, Y.; Truman, M.; Sukkarieh, S. Cattle segmentation and contour extraction based on Mask R-CNN for precision livestock farming. Comput. Electron. Agric. 2019, 165, 104958. [Google Scholar] [CrossRef]
  13. Feng, D.; Harakeh, A.; Waslander, S.L.; Dietmayer, K. A review and comparative study on probabilistic object detection in autonomous driving. IEEE Trans. Intell. Transp. Syst. 2021, 23, 9961–9980. [Google Scholar] [CrossRef]
  14. Latif, J.; Xiao, C.; Imran, A.; Tu, S. Medical imaging using machine learning and deep learning algorithms: A review. In Proceedings of the 2019 2nd International Conference on Computing, Mathematics and Engineering Technologies (iCoMET), Sukkur, Pakistan, 30–31 January 2019; pp. 1–5. [Google Scholar]
  15. Almadani, M.; Elhayek, A.; Malik, J.; Stricker, D. Graph-Based Hand-Object Meshes and Poses Reconstruction with Multi-Modal Input. IEEE Access 2021, 9, 136438–136447. [Google Scholar] [CrossRef]
  16. Almadani, M.; Waheed, U.b.; Masood, M.; Chen, Y. Dictionary Learning with Convolutional Structure for Seismic Data Denoising and Interpolation. Geophysics 2021, 86, 1–102. [Google Scholar] [CrossRef]
  17. Chauhan, R.; Ghanshala, K.K.; Joshi, R. Convolutional neural network (CNN) for image detection and recognition. In Proceedings of the 2018 First International Conference on Secure Cyber Computing and Communication (ICSCCC), Jalandhar, India, 15–17 December 2018; pp. 278–282. [Google Scholar]
  18. Havugimana, F.; Moinudin, K.A.; Yeasin, M. Deep learning framework for modeling cognitive load from small and noisy eeg data. IEEE Trans. Cogn. Dev. Syst. 2023, 16, 1006–1015. [Google Scholar] [CrossRef]
  19. Muhammed, S.; Upadhya, J.; Poudel, S.; Hasan, M.; Donthula, K.; Vargas, J.; Ranganathan, J.; Poudel, K. Improved Classification of Alzheimer’s Disease with Convolutional Neural Networks. In Proceedings of the 2023 IEEE Signal Processing in Medicine and Biology Symposium (SPMB), Philadelphia, PA, USA, 2 December 2023; pp. 1–7. [Google Scholar]
  20. Hasan, M.N.; Hamdan, S.; Poudel, S.; Vargas, J.; Poudel, K. Prediction of length-of-stay at intensive care unit (icu) using machine learning based on mimic-iii database. In Proceedings of the 2023 IEEE Conference on Artificial Intelligence (CAI), Santa Clara, CA, USA, 5–6 June 2023; pp. 321–323. [Google Scholar]
  21. Ahmed, M.K.; Yeasin, M. MU-Net: Modified U-Net for Precise Localization and Segmentation of Lumber-Spine Regions from Sagittal Views. TechRxiv 2024, 7. [Google Scholar] [CrossRef]
  22. Abuhussein, M.; Almadani, I.; Robinson, A.L.; Younis, M. Enhancing Obscured Regions in Thermal Imaging: A Novel GAN-Based Approach for Efficient Occlusion Inpainting. J 2024, 7, 218–235. [Google Scholar] [CrossRef]
  23. Almadani, I.; Abuhussein, M.; Robinson, A.L. Sow localization in thermal images using gabor filters. In Proceedings of the Future of Information and Communication Conference, San Francisco, CA, USA, 3–4 March 2022; Springer: Berlin/Heidelberg, Germany, 2022; pp. 617–627. [Google Scholar]
  24. Ahmed, M.K. Measurement and Evaluation of Deep Learning Based 3D Reconstruction; The University of Memphis: Memphis, TN, USA, 2023. [Google Scholar]
  25. Ahmed, M.K. Converting OpenStreetMap (OSM) Data to Functional Road Networks for Downstream Applications. arXiv 2022, arXiv:2211.12996. [Google Scholar]
  26. Sharifuzzaman, M.; Mun, H.S.; Ampode, K.M.B.; Lagua, E.B.; Park, H.R.; Kim, Y.H.; Hasan, M.K.; Yang, C.J. Technological Tools and Artificial Intelligence in Estrus Detection of Sows—A Comprehensive Review. Animals 2024, 14, 471. [Google Scholar] [CrossRef] [PubMed]
  27. Xu, Z.; Sullivan, R.; Zhou, J.; Bromfield, C.; Lim, T.T.; Safranski, T.J.; Yan, Z. Detecting sow vulva size change around estrus using machine vision technology. Smart Agric. Technol. 2023, 3, 100090. [Google Scholar] [CrossRef]
  28. Labrecque, J.; Rivest, J. A real-time sow behavior analysis system to predict an optimal timing for insemination. In Proceedings of the 10th International Livestock Environment Symposium (ILES X), Omaha, NE, USA, 25–27 September 2018; American Society of Agricultural and Biological Engineers: St. Joseph, MI, USA, 2018; p. 1. [Google Scholar]
  29. Zheng, H.; Zhang, H.; Song, S.; Wang, Y.; Liu, T. Automatic detection of sow estrus using a lightweight real-time detector and thermal images. Int. J. Agric. Biol. Eng. 2023, 16, 194–207. [Google Scholar] [CrossRef]
  30. Young, B.; Dewey, C.E.; Friendship, R.M. Management factors associated with farrowing rate in commercial sow herds in Ontario. Can. Vet. J. 2010, 51, 185. [Google Scholar] [PubMed]
Figure 1. An overview of our estrus detection system construction.
Figure 1. An overview of our estrus detection system construction.
Digital 04 00044 g001
Figure 2. Sample of a segmented image and its corresponding mask.
Figure 2. Sample of a segmented image and its corresponding mask.
Digital 04 00044 g002
Figure 3. Defining the four main points and rearranging the bounding box around them.
Figure 3. Defining the four main points and rearranging the bounding box around them.
Digital 04 00044 g003
Figure 4. Finding Euclidean distance between vulva points.
Figure 4. Finding Euclidean distance between vulva points.
Digital 04 00044 g004
Figure 5. Monocular depth estimation.
Figure 5. Monocular depth estimation.
Digital 04 00044 g005
Figure 6. Functions representing estrus and non-estrus states by modeling the relationship between the Euclidean distance of each dimension and the depth distance from the camera.
Figure 6. Functions representing estrus and non-estrus states by modeling the relationship between the Euclidean distance of each dimension and the depth distance from the camera.
Digital 04 00044 g006
Figure 7. K-nearest neighbors in classifying estrus and non-estrus states.
Figure 7. K-nearest neighbors in classifying estrus and non-estrus states.
Digital 04 00044 g007
Figure 8. Ground truth and predicted points.
Figure 8. Ground truth and predicted points.
Digital 04 00044 g008
Figure 9. YOLOv8 segmentation results.
Figure 9. YOLOv8 segmentation results.
Digital 04 00044 g009
Figure 10. Confusion matrices of estrus detection.
Figure 10. Confusion matrices of estrus detection.
Digital 04 00044 g010
Figure 11. Accurate estrus cycle detection.
Figure 11. Accurate estrus cycle detection.
Digital 04 00044 g011
Table 1. Evaluation metrics for keypoint distances.
Table 1. Evaluation metrics for keypoint distances.
MetricKeypoint 1 to Keypoint 3Keypoint 2 to Keypoint 4
Average error7.81 pixels5.43 pixels
Mean Squared Error (MSE)142.70 pixels262.73 pixels2
Root Mean Squared Error (RMSE)11.95 pixels7.92 pixels
Table 2. Comparison of YOLOv8 segmentation and U-Net models.
Table 2. Comparison of YOLOv8 segmentation and U-Net models.
MetricU-NetYOLOv8
Intersection over Union (IoU)0.5860.725
Mean Average Precision at 50% overlap (mAP50)0.6520.804
Mean Average Precision at 50–95% overlap (mAP50-95)0.4890.678
Table 3. Evaluation metrics for estrus detection model.
Table 3. Evaluation metrics for estrus detection model.
MetricValue
Accuracy95.2%
Precision96.0%
Recall94.5%
F1-score95.2%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Almadani, I.; Abuhussein, M.; Robinson, A.L. YOLOv8-Based Estimation of Estrus in Sows Through Reproductive Organ Swelling Analysis Using a Single Camera. Digital 2024, 4, 898-913. https://doi.org/10.3390/digital4040044

AMA Style

Almadani I, Abuhussein M, Robinson AL. YOLOv8-Based Estimation of Estrus in Sows Through Reproductive Organ Swelling Analysis Using a Single Camera. Digital. 2024; 4(4):898-913. https://doi.org/10.3390/digital4040044

Chicago/Turabian Style

Almadani, Iyad, Mohammed Abuhussein, and Aaron L. Robinson. 2024. "YOLOv8-Based Estimation of Estrus in Sows Through Reproductive Organ Swelling Analysis Using a Single Camera" Digital 4, no. 4: 898-913. https://doi.org/10.3390/digital4040044

APA Style

Almadani, I., Abuhussein, M., & Robinson, A. L. (2024). YOLOv8-Based Estimation of Estrus in Sows Through Reproductive Organ Swelling Analysis Using a Single Camera. Digital, 4(4), 898-913. https://doi.org/10.3390/digital4040044

Article Metrics

Back to TopTop