Spatiotemporal Modeling and Intelligent Recognition of Sow Estrus Behavior for Precision Livestock Farming

Kaidong Lei, Bugao Li, Hua Yang, Hao Wang, D. Y. Wang, Benhai XiongAnimals 2025 · DOI

TL;DR

This paper tackles the challenge of accurately detecting sow estrus behavior in precision livestock farming using video analysis. They developed and compared three deep learning models (CNN+LSTM, 3D-CNN, and CNN+TCN), finding that the CNN+TCN model offers the best balance of accuracy and efficiency for this complex, multi-stage behavior. The research also resulted in an intelligent system for real-time monitoring and decision support on smart pig farms.

What Problem Does This Paper Address?

Precision livestock farming aims to optimize animal husbandry through technology, and for pig farms, accurately identifying when a sow is in estrus is crucial for efficient breeding and maximizing reproductive success. Traditional methods, like manual observation or physical tests, are labor-intensive, subjective, and prone to errors. Sow estrus behavior is complex, characterized by subtle, multi-stage changes, varying durations, and individual differences, making it difficult for static image analysis or manual checks to keep up. Existing intelligent systems often lack practical deployment capabilities and user interaction features. This paper addresses the need for a robust, automated, and deployable system for accurate sow estrus behavior recognition, focusing on the spatiotemporal dynamics of these behaviors.

Methods

The core of this research lies in evaluating three deep learning architectures for video-based behavior recognition:

  • CNN + LSTM: This model combines a 2D Convolutional Neural Network (CNN) for spatial feature extraction from individual frames with a Long Short-Term Memory (LSTM) network to model temporal dependencies across sequences of frames. It separates spatial and temporal processing.
  • 3D-CNN: This approach uses 3D convolutional layers to directly process video clips, enabling it to simultaneously learn spatial and temporal features within the video volume. This is an end-to-end approach for spatiotemporal feature extraction.
  • CNN + TCN: This model integrates a CNN for spatial feature extraction with a Temporal Convolutional Network (TCN). TCNs utilize dilated convolutions, allowing them to capture both short-term and long-term dependencies efficiently, making them well-suited for sequential data with complex temporal patterns.

The authors also implemented a data preprocessing pipeline involving a sliding window strategy for segmenting video clips into uniform-length sequences. Data augmentation techniques were used to address class imbalance and improve generalization. A unified training and evaluation strategy was employed across all models, using standard metrics like accuracy, precision, recall, F1-score, confusion matrices, and ROC-AUC curves.

Datasets

The study utilized video data collected from three large-scale sow breeding farms in China (Shandong, Chongqing, and Shanxi) between July 2019 and December 2020, and again from December 2024 to August 2025. The experimental subjects were post-weaning sows with 2 to 3 parities. A total of 105 groups of sow behavior data were collected. The dataset was annotated for four key estrus-related behaviors: SOB (Exploratory behaviors like bar-biting), SOC (Active contact with a bionic boar), SOS (Standing reflex, a mating receptivity indicator), and SOW (Head-swinging movements indicating restlessness). The data was split into training (60%), validation (20%), and test (20%) sets, with strict maintenance of category proportions to avoid bias.

Key Insights and Ideas

  • Spatiotemporal Dynamics are Crucial: The paper strongly emphasizes that sow estrus behavior is not just about what a sow looks like at a single moment, but how its behavior evolves over time. This highlights the necessity of models that can capture both spatial appearance and temporal progression.
  • CNN+TCN Outperforms for Complex Sequences: The CNN+TCN model demonstrated superior performance, particularly for behaviors with stage-specific and continuous patterns. This suggests that TCNs' ability to model long-range dependencies with dilated convolutions is highly effective for these types of sequential behaviors.
  • 3D-CNN Excels at Short, Dynamic Actions: The 3D-CNN model showed promise for recognizing short-term, dynamic behaviors like "SOC" (active contact), indicating its strength in capturing rapid, localized movements.
  • CNN+LSTM is Robust for Static Behaviors: The CNN+LSTM model proved effective for longer-duration, more static behaviors like "SOB" and "SOS," showcasing its ability to handle sustained patterns.
  • Integrated System for Practicality: Beyond model development, the creation of an intelligent system with a visual interface, real-time feedback, and user interaction is a significant step towards practical deployment in real-world farming environments.

Key Results

The study found that the CNN + TCN model performed best overall, achieving:

  • Validation accuracy exceeding 0.98.
  • F1-score approaching 1.0.
  • Average AUC value of 0.9988.

The 3D-CNN model showed good performance for short-term dynamic behaviors, with:

  • Validation F1-score of 0.91.
  • AUC of 0.770.

The CNN + LSTM model demonstrated robustness for long-duration static behaviors, with:

  • Validation accuracy of 0.99.
  • AUC of 0.9965.

The confusion matrix analysis for the CNN+TCN model showed 100% accuracy for SOB and SOW behaviors, with minor confusion between SOC and SOS. The integrated system achieved a response time within 1 second, with model inference per segment around 100-180 ms, enabling near real-time operation.

Limitations and Future Work

The authors acknowledge several limitations:

  • Limited Experimental Scenarios: The study was conducted in controlled environments, which might affect the model's generalization to more complex, larger-scale farms.
  • Resource Dependency: The current system relies on significant computing resources, potentially limiting its immediate large-scale application in ordinary farming settings.
  • Class Imbalance: While addressed with augmentation, class imbalance can still pose challenges in real-world deployments.

Future work suggested includes:

  • Multimodal Data Fusion: Incorporating other sensor data (infrared, acoustic, physiological) to enhance robustness.
  • Lightweight Deployment: Developing schemes for deployment on edge devices or embedded systems.
  • Integration with Reproductive Management Systems: Connecting the system to broader farm management platforms for a complete closed-loop pipeline.
  • Advanced Architectures: Exploring Transformers or Bi-GRUs for improved contextual representation and attention mechanisms for better key-frame selection.
  • Class Re-weighting: Implementing schemes to mitigate the impact of category imbalance.

Summary updated

Abstract

Accurate recognition of estrus behavior in sows is of great importance for achieving scientific breeding management, improving reproductive efficiency, and reducing labor costs in modern pig farms. However, due to the evident spatiotemporal continuity, stage-specific changes, and ambiguous category boundaries of estrus behaviors, traditional methods based on static images or manual observation suffer from low efficiency and high misjudgment rates in practical applications. To address these issues, this study follows a video-based behavior recognition approach and designs three deep learning model structures: (Convolutional Neural Network combined with Long Short-Term Memory) CNN + LSTM, (Three-Dimensional Convolutional Neural Network) 3D-CNN, and (Convolutional Neural Network combined with Temporal Convolutional Network) CNN + TCN, aiming to achieve high-precision recognition and classification of four key behaviors (SOB, SOC, SOS, SOW) during the estrus process in sows. In terms of data processing, a sliding window strategy was adopted to slice the annotated video sequences, constructing image sequence samples with uniform length. The training, validation, and test sets were divided in a 6:2:2 ratio, ensuring balanced distribution of behavior categories. During model training and evaluation, a systematic comparative analysis was conducted from multiple aspects, including loss function variation (Loss), accuracy, precision, recall, F1-score, confusion matrix, and ROC-AUC curves. Experimental results show that the CNN + TCN model performed best overall, with validation accuracy exceeding 0.98, F1-score approaching 1.0, and an average AUC value of 0.9988, demonstrating excellent recognition accuracy and generalization ability. The 3D-CNN model performed well in recognizing short-term dynamic behaviors (such as SOC), achieving a validation F1-score of 0.91 and an AUC of 0.770, making it suitable for high-frequency, short-duration behavior recognition. The CNN + LSTM model exhibited good robustness in handling long-duration static behaviors (such as SOB and SOS), with a validation accuracy of 0.99 and an AUC of 0.9965. In addition, this study further developed an intelligent recognition system with front-end visualization, result feedback, and user interaction functions, enabling local deployment and real-time application of the model in farming environments, thus providing practical technical support for the digitalization and intelligentization of reproductive management in large-scale pig farms.
BibTeX
@inproceedings{lei2025spatiotemporal,
  author = {Kaidong Lei and Bugao Li and Hua Yang and Hao Wang and D. Y. Wang and Benhai Xiong},
  title = {{Spatiotemporal Modeling and Intelligent Recognition of Sow Estrus Behavior for Precision Livestock Farming}},
  booktitle = {Animals},
  year = {2025},
  doi = {10.3390/ani15192868},
}
Figure