高级检索+

基于改进YOLOv11n的猪舍残余饲料检测方法

Feed Residue Detection in Pig Farms Using Improved YOLOv11n

  • 摘要: 饲料残余状态检测对猪只健康评估和节粮饲喂调控均有重要意义。针对猪舍料槽残余饲料检测中存在的细粒度分类难、类间相似度高等问题,该研究提出一种基于改进YOLOv11n的残余饲料检测模型SWF-YOLO(SCSA weight fusion yolo),以实现料槽饲料残余状态的端到端检测。在骨干网络中引入空间通道协同注意力(spatial and channel synergistic attention,SCSA)机制增强细粒度特征提取能力;在颈部网络采用Weight Fusion加权特征融合策略优化多尺度信息整合;在骨干网络末端嵌入位置敏感注意力(C2 position-sensitive attention,C2PSA)模块提升关键区域特征捕捉能力,并采用遗传算法对模型训练超参数进行优化。采集的7748个样本构建数据集,将余料状态划分为无余料、少量余料、中量余料、大量余料4个类别。SWF-YOLO模型的平均精度均值、精确率、召回率、F1值分别达到93.78%、84.21%、89.40%、86.73%。与基线模型YOLOv11n相比,SWF-YOLO的mAP50、召回率、F1值分别提升2.19、4.95、2.19个百分点。与Faster-RCNN、YOLOv8n、YOLOv9t、YOLOv10n、YOLOv12n相比,SWF-YOLO表现出最优的综合检测性能。易混淆的少量余料与中量余料类别间混淆率从基线模型的12.3%降至5.1%。该模型在复杂猪舍环境下实现了余料状态的高精度检测,为精准饲喂管理、饲料浪费控制和猪群健康预警提供技术支撑,可为智能养殖装备的研发与应用提供参考。

     

    Abstract: Feed residue state in troughs is a key indicator for optimizing feed conversion, reducing waste, and giving early warnings of health abnormalities. In commercial pig production, feed costs account for 60%–70% of total expenses, which makes accurate monitoring essential. However, accurate residue detection remains challenging. Residue levels show high inter-class visual similarity, and boundaries between adjacent categories are subtle. Environmental factors add further interference, including uneven illumination, suspended feed dust, and trough reflection. Existing deep learning models lack the fine-grained feature extraction needed to separate visually similar states such as small and medium residue. This study developed SWF-YOLO (Spatial and Channel Synergistic Attention Weight Fusion YOLO), an improved YOLOv11n model for end-to-end classification of four residue states. Three innovations were integrated into the baseline. The C2f modules in the backbone were replaced with C2f-SCSA modules for fine-grained feature extraction. A weight-fusion strategy replaced neck concatenation for adaptive multi-scale fusion. A C2PSA module was added to capture long-range spatial dependencies. A dataset of 7,748 annotated samples was constructed from 308 growing pigs across 52 pens. A genetic algorithm then optimized 16 hyperparameters over 300 iterations. SWF-YOLO achieved a mean average precision at an IoU threshold of 0.5 (mAP50) of 93.78% on the test set. Its precision was 84.21%, recall was 89.40%, and F1-score was 86.73%. Compared with the YOLOv11n baseline, it improved mAP50, recall, and F1-score by 2.19, 4.95, and 2.19 percentage points, respectively. The model also became more compact. Parameters were reduced by 26.74% to 1.89 M, the computational cost was 3.51 GFLOPs, and the inference speed reached 50.2 frames per second. These figures meet the requirements of real-time edge deployment. Ablation experiments clarified the role of each component. The SCSA module contributed the largest precision gain of 6.26 percentage points. The weight-fusion strategy achieved the greatest efficiency improvement, reducing computational cost by 16.14%. The full three-module combination yielded the best balance between accuracy and efficiency. Fine-grained discrimination also improved markedly. The confusion rate between the easily misclassified small- and medium-residue categories dropped from 12.3% in the baseline to 5.1%, a 58.54% reduction. After genetic algorithm optimization, class-specific F1-scores reached 94.91%, 88.19%, 84.56%, and 80.23% for the no-, small-, medium-, and large-residue categories, respectively. In comparative experiments, SWF-YOLO outperformed Faster R-CNN, YOLOv8n, YOLOv9t, YOLOv10n, and YOLOv12n. The mAP50 improvements were 2.54, 2.53, 1.95, 2.56, and 2.80 percentage points, respectively. These results confirm its advantage over both two-stage and mainstream one-stage detectors. They also indicate that SWF-YOLO maintains a favorable accuracy and efficiency trade-off, making it well suited for resource-constrained edge devices in commercial pig farms. Grad-CAM visualization further showed that the SCSA mechanism directed attention more precisely toward critical trough regions than the SE, CBAM, ECA, SGA, and CA attention modules. SWF-YOLO addresses the fine-grained classification challenges of pig trough feed residue detection. It synergistically integrates spatial and channel attention, adaptive weighted feature fusion, and position-sensitive attention. The model achieves state-of-the-art accuracy while remaining lightweight. It supports feed-waste control and early health warning in precision livestock farming. These findings provide a practical reference for developing vision-based intelligent monitoring equipment in commercial pig production.

     

/

返回文章
返回