Multitask contrastive learning for individual dairy cow recognition across different behavior classes based on small image sets

The objectives of this study were to (1) evaluate the You Look Only Once (YOLOv7) algorithm for group-level behavior monitoring in freestall cows, (2) propose a multitask contrastive network (MTCN) for individual cow identification from limited reference data and compare its performance to a traditional convolutional neural network, and (3) dewvelop and validate a scalable 2-step computer vision framework integrating behavior detection and individual identification. Twenty-one Holstein cows housed in a single pen were monitored using ceiling-mounted red-green-blue cameras capturing images at 10-s intervals over 30 d. Behavior-labeled datasets (3,120 images) and cow-specific cropped images (1,059 images) were used to train the models, while a separate testing set (1,620 images, 8,490 annotations) was used to evaluate models' performance on unseen data. The MTCN classification performance was compared with a baseline model based on MobileNetV3 architecture. The 2 classification algorithms (YOLOv7 and MTCN) were combined to estimate the total time spent drinking (TTD), eating (TTE), resting (TTR), and standing (TTS) for each cow during 3 daily intervals: 0900 to 1000 h (morning), 1300 to 1400 h (afternoon), and 2000 to 2100 h (night). The YOLOv7 algorithm achieved high group-level classification performance, with global accuracy of 90.5% and Cohen's kappa of 0.859. Resting behavior had the highest metrics (balanced accuracy 99.1%, F1 99.1%), while eating showed the lowest balanced accuracy (88.3%). Individual identification using MTCN reached a global accuracy of 83.6% (Cohen's kappa 0.827), outperforming the baseline model, particularly for challenging resting and drinking postures. Correlations between predicted and observed values for TTD, TTE, TTR, and TTS ranged from 0.78 to 0.93, with mean absolute errors between 0.62 and 6.72 min. Prediction accuracy varied across day periods, with highest performance for TTE and TTD, and lower accuracy for TTR, particularly at night. These results demonstrate that the proposed computer vision framework can reliably classify group behaviors and identify individual cows under diverse postures, enabling continuous, automated monitoring of behavior traits in freestall dairy systems.

Authors

Institutions

Publication Details

Journal
Journal of Dairy Science
Published
2025-11-08
DOI
https://doi.org/10.3168/jds.2025-26731
Primary Topic
Animal Behavior and Welfare Studies
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Multitask contrastive learning for individual dairy cow recognition across different behavior classes based on small image sets

Jacob M. Hooker, Taisir Abdulhafed Abdulrahman, Chanchal Saha, Anderson Antônio Carvalho Alves et al.
Journal of Dairy Science
Animal Behavior and Welfare Studies
article

Multitask contrastive learning for individual dairy cow recognition across different behavior classes based on small image sets

Jacob M. Hooker, Taisir Abdulhafed Abdulrahman, Chanchal Saha, Anderson Antônio Carvalho Alves, Bernardo Medeiros
article en

Abstract

The objectives of this study were to (1) evaluate the You Look Only Once (YOLOv7) algorithm for group-level behavior monitoring in freestall cows, (2) propose a multitask contrastive network (MTCN) for individual cow identification from limited reference data and compare its performance to a traditional convolutional neural network, and (3) dewvelop and validate a scalable 2-step computer vision framework integrating behavior detection and individual identification. Twenty-one Holstein cows housed in a single pen were monitored using ceiling-mounted red-green-blue cameras capturing images at 10-s intervals over 30 d. Behavior-labeled datasets (3,120 images) and cow-specific cropped images (1,059 images) were used to train the models, while a separate testing set (1,620 images, 8,490 annotations) was used to evaluate models' performance on unseen data. The MTCN classification performance was compared with a baseline model based on MobileNetV3 architecture. The 2 classification algorithms (YOLOv7 and MTCN) were combined to estimate the total time spent drinking (TTD), eating (TTE), resting (TTR), and standing (TTS) for each cow during 3 daily intervals: 0900 to 1000 h (morning), 1300 to 1400 h (afternoon), and 2000 to 2100 h (night). The YOLOv7 algorithm achieved high group-level classification performance, with global accuracy of 90.5% and Cohen's kappa of 0.859. Resting behavior had the highest metrics (balanced accuracy 99.1%, F1 99.1%), while eating showed the lowest balanced accuracy (88.3%). Individual identification using MTCN reached a global accuracy of 83.6% (Cohen's kappa 0.827), outperforming the baseline model, particularly for challenging resting and drinking postures. Correlations between predicted and observed values for TTD, TTE, TTR, and TTS ranged from 0.78 to 0.93, with mean absolute errors between 0.62 and 6.72 min. Prediction accuracy varied across day periods, with highest performance for TTE and TTD, and lower accuracy for TTR, particularly at night. These results demonstrate that the proposed computer vision framework can reliably classify group behaviors and identify individual cows under diverse postures, enabling continuous, automated monitoring of behavior traits in freestall dairy systems.

Journal of Dairy ScienceVol. 109(2)
University of Georgia (US)
Openalex Percentile: Top 63%
Animal Behavior and Welfare Studies
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.