欢迎您访问《智慧农业(中英文)》官方网站! English

Smart Agriculture ›› 2024, Vol. 6 ›› Issue (5): 153-163.doi: 10.12133/j.smartag.SA202406014

• 技术方法 • 上一篇    

基于改进DeepLabCut模型的奶牛滑蹄检测方法

年悦, 赵凯旋, 姬江涛()   

  1. 河南科技大学 农业装备工程学院,河南 洛阳 471000,中国
  • 收稿日期:2024-06-14 出版日期:2024-09-30
  • 基金项目:
    国家重点研发计划项目(2023YFD2000702); 河南省国际科技合作项目(232102521006); 河南省高校科技创新人才项目(24HASTIT052)
  • 作者简介:
    年 悦,研究方向为智慧养殖、信息感知等。E-mail:
  • 通信作者:
    姬江涛,博士,教授,研究方向为智能农业设备和信息技术。E-mail:

Cow Hoof Slippage Detecting Method Based on Enhanced DeepLabCut Model

NIAN Yue, ZHAO Kaixuan, JI Jiangtao()   

  1. College of Agricultural Equipment Engineering, Henan University of Science and Technology, Luoyang 471000, China
  • Received:2024-06-14 Online:2024-09-30
  • Foundation items:National Key Research and Development Program(2023YFD2000702); Henan Province International Science and Technology Cooperation Project(232102521006); Henan Province University Science and Technology Innovation Talent Project(24HASTIT052)
  • About author:
    NIAN Yue, E-mail:
  • Corresponding author:
    JI Jiangtao, E-mail:

摘要:

【目的/意义】 为解决奶牛在行走过程中出现滑蹄姿态无法自动识别检测的问题,基于深度学习的方法对奶牛身体关键点进行定位分析,实现对奶牛滑蹄姿态的自动检测。 【方法】 选取奶牛四蹄及头部作为奶牛身体关键点,基于DeepLabCut(DLC)对奶牛四蹄及头部关键点进行定位,首先选取ResNet系列、MobileNet-V2系列、EfficientNet系列等10个网络模型替换DLC的主干网络,最终选取准确率最高的ResNet-50作为DLC的主干网络,随后选择轻量级的卷积块注意力模块(Convolutional Block Attention Module, CBAM)嵌入ResNet-50的网络结构中,完成对ResNet-50网络模型的改进。通过改进后的模型得到奶牛身体关键点坐标,绘制奶牛四蹄及头部运动曲线。利用奶牛身体关键点运动曲线进行分析,提取奶牛滑蹄姿态的特征参数Feature1、奶牛滑蹄距离的特征参数Feature2。基于决策树对提取的奶牛滑蹄姿态特征参数进行模型的训练和验证。利用提取的奶牛滑蹄特征参数对奶牛的滑蹄距离进行计算,同时人工对奶牛滑蹄距离进行标定,与预测的滑蹄距离进行比较。 【结果和讨论】 改进后的ResNet-50网络相较于ResNet-50在验证集的定位准确率提高了9.7%,相较于YOLOv8s-pose的定位精准度提高了1.06 pixels,与手动标识的身体关键点之间的均方根误差(Root Mean Square Error, RMSE)仅为2.99 pixels。采用10折交叉验证对奶牛滑蹄检测模型的效果进行评估,结果表明,该模型的平均准确率、精确度、召回率和F1分数分别为90.42%,0.943,0.949和0.941。基于特征参数Feature2计算的奶牛滑蹄距离与人工标定奶牛滑蹄距离的RMSE仅为1.363 pixels。 【结论】 融合CBAM模块改进的ResNet-50网络模型对奶牛身体关键点定位的准确率较高,基于滑蹄判断特征参数Feature1和滑蹄距离检测特征参数Feature2建立的奶牛滑蹄判断模型和奶牛滑蹄距离预测模型与人工检测的结果相比,都有较小的误差,这表明该方法有较好的准确性,可以为奶牛滑蹄自动检测工作提供技术支持。

关键词: 深度学习, 奶牛滑蹄, ResNet-50, 决策树, CBAM注意力机制, 决策树

Abstract:

[Objective] The phenomenon of hoof slipping occurs during the walking process of cows, which indicates the deterioration of the farming environment and a decline in the cows' locomotor function. Slippery grounds can lead to injuries in cows, resulting in unnecessary economic losses for farmers. To achieve automatically recognizing and detecting slippery hoof postures during walking, the study focuses on the localization and analysis of key body points of cows based on deep learning methods. Motion curves of the key body points were analyzed, and features were extracted. The effectiveness of the extracted features was verified using a decision tree classification algorithm, with the aim of achieving automatic detection of slippery hoof postures in cows. [Method] An improved localization method for the key body points of cows, specifically the head and four hooves, was proposed based on the DeepLabCut model. Ten networks, including ResNet series, MobileNet-V2 series, and EfficientNet series, were selected to respectively replace the backbone network structure of DeepLabCut for model training. The root mean square error(RMSE), model size, FPS, and other indicators were chosen, and after comprehensive consideration, the optimal backbone network structure was selected as the pre-improved network. A network structure that fused the convolutional block attention module (CBAM) attention mechanism with ResNet-50 was proposed. A lightweight attention module, CBAM, was introduced to improve the ResNet-50 network structure. To enhance the model's generalization ability and robustness, the CBAM attention mechanism was embedded into the first convolution layer and the last convolution layer of the ResNet-50 network structure. Videos of cows with slippery hooves walking in profile were predicted for key body points using the improved DeepLabCut model, and the obtained key point coordinates were used to plot the motion curves of the cows' key body points. Based on the motion curves of the cows' key body points, the feature parameter Feature1 for detecting slippery hooves was extracted, which represented the local peak values of the derivative of the motion curves of the cows' four hooves. The feature parameter Feature2 for predicting slippery hoof distances was extracted, specifically the minimum local peak points of the derivative curve of the hooves, along with the local minimum points to the left and right of these peaks. The effectiveness of the extracted Feature1 feature parameters was verified using a decision tree classification model. Slippery hoof feature parameters Feature1 for each hoof were extracted, and the standard deviation of Feature1 was calculated for each hoof. Ultimately, a set of four standard deviations for each cow was extracted as input parameters for the classification model. The classification performance was evaluated using four common objective metrics, including accuracy, precision, recall, and F1-Score. The prediction accuracy for slippery hoof distances was assessed using RMSE as the evaluation metric. [Results and Discussion] After all ten models reached convergence, the loss values ranked from smallest to largest were found in the EfficientNet series, ResNet series, and MobileNet-V2 series, respectively. Among them, ResNet-50 exhibited the best localization accuracy in both the training set and validation set, with RMSE values of only 2.69 pixels and 3.31 pixels, respectively. The MobileNet series had the fastest inference speed, reaching 48 f/s, while the inference speeds of the ResNet series and MobileNet series were comparable, with ResNet series performing slightly better than MobileNet series. Considering the above factors, ResNet-50 was ultimately selected as the backbone network for further improvements on DeepLabCut. Compared to the original ResNet-50 network, the ResNet-50 network improved by integrating the CBAM module showed a significant enhancement in localization accuracy. The accuracy of the improved network increased by 3.7% in the training set and by 9.7% in the validation set. The RMSE between the predicted body key points and manually labeled points was only 2.99 pixels, with localization results for the right hind hoof, right front hoof, left hind hoof, left front hoof, and head improved by 12.1%, 44.9%, 0.04%, 48.2%, and 39.7%, respectively. To validate the advancement of the improved model, a comparison was made with the mainstream key point localization model, YOLOv8s-pose, which showed that the RMSE was reduced by 1.06 pixels compared to YOLOv8s-pose. This indicated that the ResNet-50 network integrated with the CBAM attention mechanism possessed superior localization accuracy. In the verification of the cow slippery hoof detection classification model, a 10-fold cross-validation was conducted to evaluate the performance of the cow slippery hoof classification model, resulting in average values of accuracy, precision, recall, and F1-Score at 90.42%, 0.943, 0.949, and 0.941, respectively. The error in the calculated slippery hoof distance of the cows, using the slippery hoof distance feature parameter Feature2, compared to the manually calibrated slippery hoof distance was found to be 1.363 pixels. [Conclusion] The ResNet-50 network model improved by integrating the CBAM module showed a high accuracy in the localization of key body points of cows. The cow slippery hoof judgment model and the cow slippery hoof distance prediction model, based on the extracted feature parameters for slippery hoof judgment and slippery hoof distance detection, both exhibited small errors when compared to manual detection results. This indicated that the proposed enhanced deeplabcut model obtained good accuracy and could provide technical support for the automatic detection of slippery hooves in cows.

Key words: deep learning, cow hoof slippage, ResNet50, decision tree, convolutional block attention module, decision tree

中图分类号: