Abstract
Individual animal identification is a critical component of precision livestock farming, yet it remains a significant challenge due to the high visual similarity between individuals of the same breed. This paper presents a deep learning-based approach specifically designed for the identification of Saanen milch goats. By integrating a Single Shot MultiBox Detector (SSD) for image preprocessing and a ResNet18 architecture for feature extraction, the study introduces a joint loss function that combines Triplet Loss and Cross-Entropy Loss. Experimental results on a dataset of 26 goats demonstrate that this joint optimization achieves a peak identification accuracy of 93.077%, significantly outperforming models using only a single loss function. The findings suggest that whole-body features are more effective than facial features for livestock recognition, providing a scalable non-contact solution for smart farming.
Introduction
In modern smart animal husbandry, the ability to track individual animals is essential for monitoring health, behavior, and productivity. Traditional identification methods, such as ear tags, branding, and RFID, are often invasive and prone to loss or damage. While computer vision offers a non-invasive alternative, it faces the "high similarity" problem. For breeds like Saanen milch goats, individuals appear nearly identical to standard algorithms. Previous attempts to apply human-centric facial recognition to livestock have often resulted in low accuracy due to the lack of distinct facial variance in animals. This research addresses these challenges by proposing a robust identification pipeline that leverages deep learning and joint loss optimization.
Methodology
Data Acquisition and Preprocessing
The study utilized a custom dataset of 1,300 high-quality images from 26 Saanen milch goats. To ensure the model focused on the animals rather than environmental noise, a Single Shot MultiBox Detector (SSD) was employed to automatically locate and crop the goats within each frame. The dataset was split into 1,040 training images and 260 testing images. Data augmentation techniques, including rotation, flipping, and brightness adjustment, were applied to improve model robustness across varying lighting conditions and angles.
Feature Extraction and Model Architecture
The researchers selected the ResNet18 (Residual Neural Network) architecture for feature extraction. ResNet18 was chosen for its ability to capture deep features while avoiding the vanishing gradient problem through the use of skip connections. Transfer learning was utilized by initializing the network with weights pre-trained on general visual datasets, allowing the model to converge more quickly on the specific task of goat identification.
Joint Loss Optimization
The core innovation of this research is the implementation of a joint loss function. While Cross-Entropy Loss is effective for general classification, it often struggles to distinguish between highly similar classes. To overcome this, the researchers integrated Triplet Loss, which optimizes the feature space by ensuring that images of the same individual (anchor and positive) are pulled closer together while images of different individuals (negative) are pushed further apart. The combination of these two losses allows the model to learn both broad categorical boundaries and subtle individual nuances.
Results and Discussion
The proposed joint loss method achieved a peak accuracy of 93.077%. Comparative analysis highlighted the superiority of this approach over baseline models:
- Triplet Loss Only: 74.615% accuracy
- Cross-Entropy Loss Only: 89.615% accuracy
- Joint Loss (Proposed): 93.077% accuracy
A key insight from the experiments was the inadequacy of facial features alone. When the model was restricted to goat faces, accuracy dropped significantly compared to whole-body recognition. This suggests that body proportions, coat patterns, and overall morphology provide more reliable identifying data for livestock. Furthermore, the failure of standard architectures like YOLOv3 to achieve high accuracy on this specific task underscores the difficulty of the "high similarity" problem in animal identification.
Conclusion
This research demonstrates that a deep learning approach combining whole-body feature extraction with joint loss optimization can effectively solve the high-similarity identification problem in milch goats. The achieved accuracy of 93.077% marks a significant improvement over traditional single-loss methods. Future work will focus on scaling the system to larger herds and improving performance in unconstrained environments where animals may overlap or huddle. This study provides a valuable framework for the development of non-contact, automated identification systems in precision agriculture.
Summary updated