摘要:
为提高复杂环境下奶牛发情行为识别精度和速度,提出了一种基于改进YOLO v3模型的奶牛发情行为识别方法。针对YOLO v3模型原锚点框尺寸不适用于奶牛数据集的问题,对奶牛数据集进行聚类,并对获得的新锚点框尺寸进行优化;针对因数据集中奶牛个体偏大等原因而导致模型识别准确率低的问题,引入DenseBlock结构对YOLO v3模型原特征提取网络进行改进,提高了模型识别性能;将YOLO v3模型原边界框损失函数使用均方差(MSE)作为损失函数度量改为使用FIoU和两框中心距离Dc度量,提出了新的边界框损失函数,使其具有尺度不变性。从96段具有发情爬跨行为的视频片段中各选取50帧图像,根据发情爬跨行为在活动区出现位置的不确定性和活动区光照变化的特点,对图像进行水平翻转、±15°旋转、随机亮度增强(降低)等数据增强操作,用增强后的数据构建训练集和验证集,对改进后的模型进行训练,并依据F1、mAP、准确率P和召回率R指标进行模型优选。在测试集上的试验表明,本文方法模型的识别准确率为99.15%,召回率为97.62%,且处理速度达到31 f/s,能够满足复杂养殖环境、全天候条件下奶牛发情行为的准确、实时识别。
Abstract:
Aiming to improve the detection accuracy and speed of estrus behavior of dairy cows in a complex scene,a method of recognizing estrus behavior of dairy cows based on improved YOLO v3 model was proposed.To solve the problem of the cows ’ size was inconsistent with the size of the object in the COCO dataset,which caused the original anchors were not applicable,new anchors were obtained by clustering new data sets and optimized by using linear expansion.As cows with a big size,the small difference between individuals and associations between behaviors,which was difficult to distinguish,a DenseBlock structure was introduced to the feature extraction network of YOLO v3 model to improve its detection performance on the large objects.Considered that the original bounding box loss function of YOLO v3 model was not invariant to the object scale,the FloU and the center distance Dc of two boxes were used as the measuring method,and a new bounding box loss function was proposed to make it scaleinvariant.Totally 50 images were extracted each from 96 video mounting behavior clips of dairy cows,according to the uncertainty position of cows’ mounting behavior in the active area and the character of the light changing of the active area,horizontally flipped,rotated ±15° and random brightness enhancement(decrease) were applied on them for data augmentation.The augmented data was divided into three parts as training sets,validation sets,and test sets,training sets and validation sets were used to train the improved model and the best training model was chosen as dairy cow estrus behavior recognition model with the indicators F1,mAP,accuracy rate P,and recall rate R.The experiment on test sets showed that the accuracy rate of the model was 99.15%,the recall rate was 97.62%,and the processing speed reached 31 f/s,which could accurately and real-time identify cows’ estrus behavior in a complex breeding environment under all weather.The research could also provide a reference for other large livestock behavior recognition.