Li Jian, Ma Wenkai, Wei Yanan, Wang Tan
School of Biology and Food Engineering, Fuyang Normal University, Fuyang 236037, China.
Anhui Provincial Key Laboratory of Embryo Development and Reproductive Regulation, Fuyang 236037, China.
Animals (Basel). 2025 Jul 21;15(14):2149. doi: 10.3390/ani15142149.
Accurate pig counting is crucial for precision livestock farming, enabling optimized feeding management and health monitoring. Detection-based counting methods face significant challenges due to mutual occlusion, varying illumination conditions, diverse pen configurations, and substantial variations in pig densities. Previous approaches often struggle with complex agricultural environments where lighting conditions, pig postures, and crowding levels create challenging detection scenarios. To address these limitations, we propose EAPC-YOLO (enhanced adaptive pig counting YOLO), a robust architecture integrating density-aware processing with advanced detection optimizations. The method consists of (1) an enhanced YOLOv8 network incorporating multiple architectural improvements for better feature extraction and object localization. These improvements include DCNv4 deformable convolutions for irregular pig postures, BiFPN bidirectional feature fusion for multi-scale information integration, EfficientViT linear attention for computational efficiency, and PIoU v2 loss for improved overlap handling. (2) A density-aware post-processing module with intelligent NMS strategies that adapt to different crowding scenarios. Experimental results on a comprehensive dataset spanning diverse agricultural scenarios (nighttime, controlled indoor, and natural daylight environments with density variations from 4 to 30 pigs) demonstrate our method achieves 94.2% mAP@0.5 for detection performance and 96.8% counting accuracy, representing 12.3% and 15.7% improvements compared to the strongest baseline, YOLOv11n. This work enables robust, accurate pig counting across challenging agricultural environments, supporting precision livestock management.
精确的猪只计数对于精准畜牧业至关重要,有助于实现优化的饲养管理和健康监测。基于检测的计数方法面临诸多重大挑战,原因包括猪只相互遮挡、光照条件变化、猪圈布局多样以及猪只密度差异巨大。以往的方法在复杂的农业环境中往往难以应对,在这些环境中,光照条件、猪只姿势和拥挤程度会造成具有挑战性的检测场景。为解决这些局限性,我们提出了EAPC - YOLO(增强型自适应猪只计数YOLO),这是一种强大的架构,将密度感知处理与先进的检测优化相结合。该方法包括:(1)一个增强的YOLOv8网络,融入了多项架构改进,以实现更好的特征提取和目标定位。这些改进包括用于处理不规则猪只姿势的DCNv4可变形卷积、用于多尺度信息整合的BiFPN双向特征融合、用于提高计算效率的EfficientViT线性注意力以及用于改进重叠处理的PIoU v2损失。(2)一个具有智能NMS策略的密度感知后处理模块,可适应不同的拥挤场景。在一个涵盖多种农业场景(夜间、可控室内以及自然光环境,猪只密度从4只到30只不等)的综合数据集上的实验结果表明,我们的方法在检测性能方面达到了94.2%的mAP@0.5,计数准确率达到了96.8%,与最强基线YOLOv11n相比,分别提高了12.3%和15.7%。这项工作能够在具有挑战性的农业环境中实现稳健、精确的猪只计数,支持精准畜牧业管理。