Abstract:
With advancements in artificial intelligence, automation, deep learning, and other technologies, modern pig farming moved towards intensive and intelligent development. The integration of machine vision and deep learning technology realized non-invasive individual identification and behavior monitoring, providing an effective tool for refined breeding. The characteristic information generated by pigs during daily activities is crucial for recognizing and analyzing pig behavior. However, due to frequent changes in pig posture, existing pig feature extraction methods are complex and inefficient. To address these issues, this study proposed a pig keypoint detection model, YOLO-ASF-P2, which focuses on key areas of the pig's body to extract feature point information. Additionally, a pig behavior recognition model, CNN-BiGRU, was introduced, which combines temporal information from keypoints to identify pig behavior. First, video and image data of pigs were collected by multi-angle cameras deployed in the pig house, forming a pig feature point detection dataset and a pig behavior recognition dataset. To address the issues of complex calculations, redundant feature information, and poor model robustness associated with traditional pig feature extraction methods, the YOLOv8s-Pose model was improved, resulting in the YOLO-ASF-P2 model. This model utilized the small target feature information of the P2 detection layer and combined the attention scale sequence fusion (ASF) architecture to focus on the key feature points of live pigs. The scale sequence feature fusion module (SSFF) module used Gaussian kernel and nearest neighbor interpolation to align multi-scale feature maps of different downsampling rates (such as P2, P3, P4, and P5 detection layers) to the same resolution as the high-resolution feature map, ensuring comprehensive information extraction. The triple feature encoding (TFE) module captured local fine details of small targets and fused local and global feature information. The channel and position attention mechanism module (CPAM) module captured and refined the spatial positioning information related to small targets, effectively extracted the important feature information contained in the feature map in different channels, and improved the positioning accuracy of the model. The CNN-BiGRU pig behavior recognition model used bidirectional gated recurrent unit (BiGRU) units to capture forward and backward information of sequence data in a bidirectional manner, with the output weighted using the attention mechanism module (AttentionBlock). On the self-built dataset, the average recognition accuracy of the model for the three behaviors of sitting, standing, and lying reached 96%, demonstrating good and stable performance. The detection accuracy of YOLO-ASF-P2 reached 92.5%, the recall rate was 90%, the average precision (AP
50~95) was 68.2%, the parameter volume was only 18.4M, and the performance was 39.6GFLOPs. These results were 1.1%, 2.3%, 1.5%, and 32.9% higher than the original model, respectively, with the model parameter volume reduced by 17.5%. Compared with MMPose, the average precision (AP
50~95) and accuracy of YOLO-ASF-P2 have been improved by 17.4% and 2.9%, respectively, while almost the same level of recall has been maintained, thereby enhancing detection performance. Compared with RTMPose, YOLO-ASF-P2 achieves improvements in accuracy, recall rate, average precision (AP
50~95), and the number of parameters. When compared with YOLOv5s-Pose, the same accuracy is achieved, but the recall rate and average precision (AP
50~95) are improved despite a higher number of parameters. When compared with YOLOv7s-Pose, slightly lower accuracy is observed, but improvements are achieved in the recall rate and average precision (AP
50~95). The proposed model was lighter and showed better recognition performance for pig feature points. The CNN-BiGRU pig behavior model had high average recognition accuracy and stable performance, the parameter volume was 155 kB, and the performance was 27.1 GFLOPs. In summary, the pig behavior recognition method proposed in this paper demonstrated good feasibility and provided a new way for pig behavior recognition. The integration of YOLO-ASF-P2 and CNN-BiGRU models significantly improved the accuracy and robustness of pig feature point detection and behavior recognition, offering valuable tools for the intensive and intelligent development of pig farming.