Abstract:
In modern animal husbandry, the automated identification of periparturient behaviors in sheep plays a pivotal role in promptly detecting potential health risks and production abnormalities. This capability is crucial for safeguarding ovine welfare, reducing neonatal lamb mortality, and improving reproductive efficiency. However, accurate behavior recognition during the periparturient period presents significant challenges due to the high similarity of certain behavioral traits and environmental interferences, such as complex illumination variations and cluttered backgrounds in sheep farming environments.To address these challenges, this study proposes an advanced recognition method that integrates an enhanced YOLOv8n-Pose keypoint detection model with a backpropagation (BP) neural network. Specifically, to improve the precision of keypoint detection, an additional P2 detection layer was incorporated into the network architecture. This modification significantly strengthens the model’s ability to capture fine-grained, small-scale features, thereby enhancing its capability to accurately localize anatomical keypoints even in complex behavioral scenarios. The addition of this detection layer ensures a higher degree of spatial resolution, which is particularly advantageous in recognizing subtle movement variations in periparturient sheep.Furthermore, to mitigate feature representation challenges in dynamic environments, a Multi-scale Attention Block (MAB) module was introduced into the framework. By employing a dynamic weighting mechanism, this module enables the model to interactively learn and model both global and local spatial dependencies. Consequently, the model’s robustness and generalization performance are substantially improved, particularly under heterogeneous illumination conditions. The MAB module effectively prioritizes the most discriminative feature regions, reducing the impact of background noise and occlusions commonly observed in practical farming environments.Considering the practical deployment constraints associated with excessive model parameters, an L1-norm-based channel pruning strategy was systematically implemented. This approach effectively optimizes parameter compression and eliminates redundancy in the refined model, striking an optimal balance between computational efficiency and performance retention. By leveraging structured sparsity techniques, the pruning process maintains model integrity while significantly reducing computational overhead, making the system suitable for edge computing applications in real-time livestock monitoring scenarios.Building upon the improved model’s ability to accurately extract 12 keypoint coordinates, a multidimensional behavioral feature dataset was meticulously constructed. This dataset integrates five joint angle parameters, two pairs of keypoint relative distance metrics, and keypoint detection confidence scores, culminating in a comprehensive 32 dimensional feature vector set. These extracted feature representations were then utilized as input to a BP neural network for precise classification of periparturient behaviors. The BP neural network, trained using an adaptive learning strategy, effectively captures complex spatiotemporal dependencies among the extracted features, ensuring high classification accuracy.Extensive experimental evaluations were conducted on a self-developed dataset of periparturient sheep to rigorously assess the performance of the proposed method. The results demonstrated that the enhanced YOLOv8n-Pose model achieved a notable 4.6 percentage point increase in mean average precision (mAP50) and a 6.7 percentage point improvement in mAP50:95 for keypoint detection compared to the baseline architecture. Moreover, the BP neural network exhibited outstanding classification performance, attaining an F1-score of 95.7% in distinguishing critical periparturient behaviors. These empirical findings strongly validate the superior efficacy of keypoint-driven recognition methodologies in addressing the intricate challenges of periparturient behavior identification. Ultimately, this study establishes a robust technical framework for intelligent livestock management systems, paving the way for enhanced automation and precision monitoring in sheep farming.