Joint loss optimization based high similarity identification for milch goats

Cheng Shang, Meili Wang, Jifeng Ning, Qunhui Li, Yu Jiang, Xiaolong WangJournal of Image and Graphics 2022 · DOI

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

Abstract

目的动物个体身份识别一直是智慧畜牧业的主要难题之一,由于动物个体本身与人类在图像识别上需要的数据特征不同以及各个特征作为个体属性之间的关系不明确,对动物个体识别领域的研究较少,针对具有高相似度的奶山羊个体身份识别问题,提出了基于深度学习的高相似度的奶山羊识别方法。方法采集了26只萨能奶山羊的全身图像,利用SSD(single shot MultiBox detection)网络进行数据集预处理,并随机选取1 040幅图像作为训练集,260幅图像作为测试集。其次采用ResNet18(residual neural network)预训练模型并进行迁移学习,最后联合三元组损失函数与交叉熵损失函数进行参数调整。研究表明,采用联合损失函数并结合Adam优化器算法时,可获得较好的识别效果。此外,在实验部分针对奶山羊的特征选取问题上,对奶山羊的羊脸区域与奶山羊的全身区域分别采用了三元组损失函数与孪生网络,验证了对奶山羊的识别仅靠羊脸区域的特征时准确率较低;此外,针对网络的训练,本文不仅通过YOLOv3(you only look once)以及孪生网络(siamese network)验证了奶山羊本身属于高相似度的数据集,而且针对奶山羊数据集分别采用三元组损失函数与交叉熵损失函数作为唯一的损失函数,并验证了该方法的有效性。结果奶山羊识别的最高精准度为93.077%,相较于Triplet-Loss损失函数74.615%的准确率以及CrossEntropy-Loss 89.615%准确率有了较大提升。结论本文提出的基于深度学习的高相似度的奶山羊识别方法不仅具有较高的准确率,而且在奶山羊个体身份识别方面具有极大的应用价值,有助于准确识别羊的身份,为相似度高的动物个体身份识别提供了思路。
BibTeX
@article{shang2022joint,
  author = {Cheng Shang and Meili Wang and Jifeng Ning and Qunhui Li and Yu Jiang and Xiaolong Wang},
  title = {{Joint loss optimization based high similarity identification for milch goats}},
  journal = {Journal of Image and Graphics},
  year = {2022},
  doi = {10.11834/jig.200619},
}
Figure