Journal of Agricultural Science and Technology ›› 2025, Vol. 27 ›› Issue (11): 120-130.DOI: 10.13304/j.nykjdb.2024.0393

• INTELLIGENT AGRICULTURE & AGRICULTURAL MACHINERY • Previous Articles    

Research on Group Pig Segmentation Method Based on Improved YOLO v8n-seg

Xingjia WANG1,2(), Jiye ZHENG1,2(), Qingkai SHENG3, Liang YANG4, Xia ZHANG2   

  1. 1.Institute of Agricultural Information and Economics,Shandong Academy of Agricultural Sciences,Jinan 250100,China
    2.School of Physical Science and Information Engineering,Liaocheng University,Shandong Liaocheng 252000,China
    3.Shandong Key Laboratory for Livestock and Poultry Disease Control and Breeding,Institute of Animal Husbandry and Veterinary Medicine,Shandong Academy of Agricultural Sciences,Jinan 250100,China
    4.State Key Laboratory of Animal Nutrition and Feeding,Institute of Animal Science,Chinese Academy of Agricultural Sciences,Beijing 100193,China
  • Received:2024-05-17 Accepted:2024-07-02 Online:2025-11-15 Published:2025-11-17
  • Contact: Jiye ZHENG

基于改进YOLO v8n-seg的群猪分割方法研究

王兴家1,2(), 郑纪业1,2(), 盛清凯3, 杨亮4, 张霞2   

  1. 1.山东省农业科学院农业信息与经济研究所,济南 250100
    2.聊城大学物理科学与信息工程学院,山东 聊城 252000
    3.山东省农业科学院畜牧兽医研究所,山东省畜禽疫病防治与繁育重点实验室,济南 250100
    4.中国农业科学院北京畜牧兽医研究所,畜禽营养与饲养全国重点实验室,北京 100193
  • 通讯作者: 郑纪业
  • 作者简介:王兴家 E-mail:wangxingjia2022@163.com
  • 基金资助:
    山东省重点研发计划项目(2022TZXD0016)

Abstract:

Aiming at the problems of low accuracy of pig image segmentation and insufficient real-time segmentation in complex scenes, an algorithm for segmentation modeling of group pig instances based on improved YOLO v8n-seg was proposed. Based on YOLO v8n-seg, GhostConv was firstly introduced into the C2f module to reduce the computational complexity of the model. Secondly, attention mechanisms such as spatial group-wise enhancement, involution, and multidimensional collaborative attention were added at different locations of the network structure for enhancing the model's for feature extraction and fusion. Finally, wise IoU (WIoU) was chosen as a new loss function to speed up the convergence of the model and improve the overall performance of the detector. The results showed that, compared to the original model, the improved model reduced the number of parameters by 0.39 M. In terms of detection accuracy, the precision was improved by 3.7 percentage point, the recall by 4.8 percent point, the mean average precision of intersection over union threshold value 50% and 50% to 95% by 4.6 and 7.6 percent point, respectively, and the frames-per-second by 5.2, which showed good performance. A large improvement in both accuracy and speed were achieved by improving the YOLO v8n-seg, especially for the problem of reduced segmentation accuracy due to pig adhesion and mild occlusion in group rearing scenarios, the model showed excellent performance and was able to accurately segment individual pigs in a group, which provided a strong support for practical production applications.

Key words: intelligent farming, YOLO v8, pigs, instance segmentation, attention mechanism

摘要:

针对复杂场景中生猪图像分割精确度不高、分割实时性不足等问题,提出一种基于改进YOLO v8n-seg的群猪实例分割模型算法。在YOLO v8n-seg基础上,首先,将GhostConv引入C2f模块中,降低模型的计算复杂度;然后,在网络结构的不同位置添加空间分组增强、内卷、多维协作注意等注意力机制,用于增强模型对特征提取和融合的能力;最后,选用WIoU(wise IoU)作为新的损失函数,以加快模型的收敛速度,并提高检测器的整体性能。结果表明,相较于原始模型,改进后的模型在参数量上减少0.39 M;在检测精度上,精确率提升3.7百分点,召回率提升4.8百分点,交并比阈值为50%和50%~95%的均值平均精度分别提升4.6百分点和7.6百分点,识别速度提高5.2帧·s-1,表现出良好的性能。通过对YOLO v8n-seg进行改进,在精度和速度上均取得了较大提升,特别是针对群养场景中生猪黏连和轻度遮挡导致的分割准确率降低的问题,该模型表现出卓越的性能,能够精准地分割群猪个体,为实际生产应用提供有力支持。

关键词: 智慧养殖, YOLO v8, 猪, 实例分割, 注意力机制

CLC Number: