TLDR: Researchers from Cornell University and the University of Liège have developed an open-source, modular computer vision pipeline to automate individual-level pig behavior analysis in group housing. This system uses advanced AI models for object detection, motion-aware tracking, and behavior recognition, achieving 94.2% accuracy in classifying nine pig behaviors and significantly improving identity preservation compared to existing methods. It offers a scalable, objective solution for precision pig farming and welfare assessment.
Understanding animal behavior is vital for ensuring the welfare, health, and productivity of livestock in agricultural settings. Traditionally, this has relied on manual observation, which is often time-consuming, subjective, and difficult to scale for large farms. Recognizing these limitations, a team of researchers from Cornell University and the University of Liège has developed an innovative, modular computer vision pipeline designed to automate individual-level animal behavior analysis, with a particular focus on pigs in group housing environments.
Addressing Farm Challenges with Advanced AI
Deploying computer vision systems in real farm environments comes with unique challenges. These include frequent occlusions from farm infrastructure and other animals, dramatic lighting variations, suboptimal camera angles, and the difficulty of maintaining individual identity in crowded group settings. The new pipeline tackles these issues by integrating several state-of-the-art open-source computer vision techniques.
How the Automated System Works
The pipeline operates through six main stages, processing raw video footage from farm cameras:
1. Video Decoding: Videos are efficiently converted into sequential frames, with optimized sampling to balance detail and computational needs.
2. Object Detection: Using models like OWLv2, the system identifies and localizes individual animals in the initial frames. This ‘zero-shot’ capability means it can detect animals without needing species-specific training.
3. Segmentation and Tracking: The SAMURAI model, an enhancement of SAM2, continuously tracks and segments each animal throughout the video. Its motion-aware memory and Kalman filtering ensure robust tracking even when animals overlap or move dynamically.
4. Object Cropping: Individual animals are automatically cropped from their frames, isolating them from the background to create standardized inputs for further analysis.
5. Feature Extraction: High-dimensional visual features are extracted from these cropped images using models like DINOv2 or CLIP. These features capture rich visual information about the animals’ appearance and behavioral patterns.
6. Behavior Classification: Finally, these extracted features are fed into deep learning models, such as Multi-Layer Perceptrons (MLP) or Long Short-Term Memory (LSTM) networks, to recognize specific behaviors.
Impressive Performance on Pig Behavior
The pipeline was rigorously validated on the Edinburgh Pig Behavior Video Dataset. The results demonstrated significant improvements over existing methods:
- Behavior Recognition: The temporal LSTM model achieved an impressive 94.2% overall accuracy in recognizing nine different pig behaviors, representing a 21.2 percentage point improvement over previous approaches.
- Tracking Capabilities: The system showed robust tracking, maintaining a 93.3% identity preservation score (IDF1) and significantly reducing identity switches, crucial for individual-level monitoring.
- Object Detection: It achieved 89.3% object detection precision, reliably identifying pigs in overhead views.
The modular design proved flexible, allowing researchers to switch models (e.g., from YOLOv12 to OWLv2 for pig detection) to optimize performance for specific tasks, highlighting the importance of empirical validation for each application context.
Also Read:
- Drones and AI Uncover Hidden Threat to California’s Tomato Farms
- Advanced Sensing and AI Uncover Hidden Threat to Tomato Crops
Benefits and Future Directions
This modular approach offers several advantages, including computational efficiency, better error isolation, and adaptability to various environmental conditions. Its open-source nature encourages further development and adaptation by the research community, contributing to precision pig farming and welfare assessment through automated, objective, and continuous analysis.
While promising, the researchers acknowledge limitations, such as the need for high-quality initial frames and the species-specific validation required for new applications. Future work aims to integrate multi-modal data (like audio or environmental sensors), optimize the system for deployment in resource-constrained farm environments, and explore its applicability to other species. This research represents a significant step forward in leveraging advanced computer vision for animal welfare. For more details, you can read the full paper here.


