DOI: 10.3390/ani16213449 ISSN: 2076-2615

A Fine-Grained Pig Behavior Recognition Method Based on an Improved YOLOv8n Network

Jialin Gao, Junhao Wang, Ping Jiang, Shaohui Tan

Accurate recognition of pig behavior is important for animal health monitoring and precision livestock farming. However, fine-grained behavior recognition in group-housed pigs is challenging because of individual occlusion, large posture variation, and subtle visual differences among similar behaviors. Here, an improved YOLOv8n-based model, EPP-YOLOv8n, was developed for fine-grained pig behavior recognition. An efficient multi-scale attention module was inserted after the spatial pyramid pooling-fast module (SPPF) to enhance behavior-related feature extraction. A behavior-factorized asymmetric head (BFA-Head) was designed with scale-adaptive mixed convolution to reduce detection-head complexity, while posture- and interaction-assisted supervision was incorporated to guide fine-grained feature learning. A partial-channel mixed convolution module (P5-selective PLC-Mix) was deployed within the Backbone P5 C2f module to reduce redundant computation, followed by task-aware structured pruning with recovery training for further model compression. On a dataset comprising 2713 images and 30,695 annotated instances after training-set augmentation, EPP-YOLOv8n achieved 98.13% precision, 94.50% recall, and 89.07% mean average precision at intersection over union (IoU) thresholds from 0.50 to 0.95 (mAP@0.5:0.95), representing increases of 2.05, 1.52, and 1.64 percentage points, respectively, over YOLOv8n. Parameter count and billion floating-point operations (GFLOPs) were reduced by 14.59% and 9.70%, respectively. These results indicate that the proposed model can improve fine-grained behavior recognition while reducing model complexity, supporting automated behavior monitoring in group-housed pigs.

More from our Archive