A Two-Stage YOLOv8n+ GRU Framework for Multi-Label Cow Behavior Recognition with Temporal Stability
Authors
Shah Rafatur Rahman
Abstract
Cow behavior recognition from videos is of great importance for smart monitoring of dairy farms. However, it is difficult to do so because cows overlap, there are too many cows, and some behaviors occur in tandem, such as rumination while standing or lying. In this work, we propose a two-stage vision framework for the CBVD-5 dataset, which is a large-scale multilabel farm video benchmark dataset with five behavior classes. Real-world challenges such as overhead fixed cameras, day-night lighting variation, and heavy inter-cow occlusion. First of all, we use YOLOv8n with a 1.5ms/frame inference speed suitable for edge deployment and use it to localize cows in each frame. Second, we are predicting behaviors based on the cropped parts of cows with the help of a hierarchical multi-label setup, that is, a four-way activity classifier (standing/lying/feeding/drinking) and a separate rumination detector. We compare the framewise baseline by a temporal model to construct the short track sequences (maxT=6, IoU=0.3), and a GRU is used to improve the temporal consistency. YOLOv8n Precision: 0.874 Recall: 0.826 mAP@50: 0.910 Validation On the test set, 5-label micro-F1-scores are changed from 0.8232 to 0.8367 by temporal modeling, while macro-F1-scores are changed from 0.7365 to 0.7510. More importantly, it makes the prediction flicker much smaller (mean flicker 0.1678 to 0.0816) and the run length much longer (4.51 to 5.09). The greatest increases in class gains are for drinking and rumination, which are more difficult in actual farm scenes. Overall, the proposed pipeline has both good accuracy and better stability, which is good for farm real-time monitoring.