Abstract:Mastitis is a disease that affects the health of dairy cows. Timely detection of mastitis can improve the efficiency of mastitis treatment and reduce the economic loss of dairy industry. Aiming at the problem of low accuracy of thermal infrared technology in detection of cow mastitis, an improved YOLO v3-tiny algorithm was proposed to construct a model for automatic detection of key parts of dairy cows, and a model for automatic detection of key parts of dairy cows was constructed. The improved YOLO v3-tiny algorithm was based on the traditional YOLO v3-tiny. Firstly, the residual network was added between the convolutional layer and the pooling layer to increase the depth of network, so as to carry out deep level feature extraction, high-precision detection and classification. Secondly, the attention module of squeeze and exception (SE) was added to the key position of the network to strengthen the effective features and enhance the performance ability of the feature map. Finally, the performance of the activation function ReLU, Leaky ReLU and Swish was compared. It was found that the activation function Swish was better than the activation function ReLU and Leaky ReLU, so the activation functions in the convolutional layer of the backbone of the network model were changed to the Swish activation functions. The detection results of the improved model for key parts of dairy cows had the accuracy value of 94.8%, the recall rate value of 97.5%, the average detection accuracy value of 97.9%, and the F1 value of 96.1%. Compared with the results of traditional model, the accuracy value of the improved detection model was increased by 9.9 percentage points, the recall rate was increased by 1.7 percentage points, the average accurate detection accuracy value was increased by 2.2 percentage points, and the F1 value was increased by 6.2 percentage points, performance indicators were better than the traditional YOLO v3-tiny model, and it had little effect on the detection speed, which met the requirements of real-time detection. It showed that the algorithm can detect the key parts of dairy cows. And the target detection algorithm was used to conduct a dairy cow mastitis detection test. The obtained temperature difference was compared with a temperature threshold to determine the incidence of dairy cow mastitis, and the somatic cell count method was used to verify it. The results showed that the accuracy rate of dairy cow mastitis detection could reach 77.3%. It was proved that the method can achieve precise positioning of key parts of dairy cows and can be applied to detect dairy cow mastitis.