Abstract:
An accurate and timely monitoring is a high demand for the oestrus behavior of dairy cows in modern dairy farming. In this research, a lightweight recognition was proposed to detect the oestrus behavior of cows using the combined YOLO v5n and channel pruning. The high precision of the network was established before that. Firstly, the model was sparsely trained, according to different sparsity rates. The best sparsity effect of the model was obtained at the sparsity rate of 0.005. Then, the channel pruning was utilized to prune the modules, including the CSPDarknet53 backbone feature extraction network, in order to compress the model structure and parameters for the high detection speed. 2 239 images of cows' mounting behavior were also collected, including 1 473 images in the daytime, 88 images in the daytime (backlight), and 160 images in the nighttime. Four occlusion situations were considered, including 1 045 images without occlusion, as well as 397, 184, and 95 images with the slight, moderate, and heavy occlusion, respectively. Three target sizes were also considered, including 46, 1 191, and 484 images with the large, medium, and small targets, respectively. The pruned model was veried on the test set, and then to compare with the Faster R-CNN, SSD, YOLOX-Nano, and YOLOv5-Nano. The test results showed that the mean average precision (mAP) of the model after pruning was 97.70%, the Params were 0.72 M, the Floating Point operations (FLOPs) were 0.68 G, and the detection speed was 50.26 fps. Furthermore, the Params and FLOPs were reduced by 59.32%, and 49.63%, respectively, under the condition of constant mAP, and the detection speed increased by 33.71%, compared with the original model YOLOv5-Nano. Consequently, the pruning operation was effectively improved the performance of the model. The mAP of the model was close to the Faster R-CNN, SSD, YOLOX-Nano, but the Params were reduced by 135.97, 22.89, and 0.18 M, respectively, the FLOPs were reduced by 153.69, 86.73, and 0.14 G, respectively, and the detection speed increased by 36.04, 13.22, and 23.02 fps, respectively. In addition, the detection performance of the model was tested in the complex environments, such as different lighting, different occlusion, multi-scale targets, and new environments. The results showed that the mAP was 99.50% in the nighttime environment, the average mAP was 93.53% under the three occlusion conditions, the average mAP was 98.77% under the medium and small targets, the detection rate was 84.62% in the generalization test, and the false detection rate was 7.69%. To sum up, the improved model can fully meet the high requirements for the accurate and real-time monitoring of cows' oestrus behavior under complex breeding environments and all-weather conditions, due to the lightweight, high precision, robust, and high generalization.