Newcastle University Develops Real-time, Automated Lameness Detection System for Dairy Cows Using Computer Vision and Deep Learning

Cow lameness caused by diseases such as foot-and-mouth disease has become a global issue for the livestock industry. According to relevant popular science, it not only leads to reduced milk production and reproductive efficiency of dairy cows, but also causes the cows to be culled prematurely.Data from the National Animal Health Monitoring Service Dairy Industry Report shows that 16% of culling in dairy cows is caused by lameness.
Lameness has become one of the major crises facing the dairy industry. Therefore, early monitoring and early prevention have become effective means to solve the problem of lameness in large-scale dairy farming. In the past, the dairy industry generally used manual identification methods, but this method has disadvantages such as low efficiency, high cost, and strong subjectivity. In this context,The dairy industry has an increasing demand for automated detection technology for lameness in dairy cows.
Recently, Shaun Barney and Satnam Dlay from Newcastle University and Andrew Crowe from Fera Science Ltd have jointly developed a fully automated, real-time lameness detection system for multiple dairy cows that can be deployed throughout the farm.The system uses computer vision and deep learning to analyze the posture and gait of each cow within the camera's field of view, with a detection accuracy of 94%-100%.The research results have been published in Nature.

The results have been published in Nature.
Paper link:
https://www.nature.com/articles/s41598-023-31297-1#Sec7
Experimental Dataset
In this experiment, the researchers first recorded the movements of 250 cows on a farm in the UK, obtained 25 videos, and then decomposed each video into 3,600 frames. Secondly, the researchers extracted one frame per second and annotated it. And in order to further improve the generalization ability of the network, they downloaded 500 cow-related pictures from Google and annotated 15 key points for each cow.By combining these image search data with our own annotation data, we obtained a database containing approximately 40,000 annotation information.

In order to evaluate the performance of the algorithm using real data,Three AHDB-certified observers simultaneously scored 25 videos using the AHDB Cow Mobility Scoring System.The system has four rating levels: 0 (no lameness at all), 1 (slightly impaired mobility), 2 (lameness), and 3 (severe lameness). The figure below shows the distribution of ratings by these three observers.

The figure shows that25.2% of cows had a lameness score of 0 (orange), 43.2% had a lameness score of 1 (green), 25.6% had a lameness score of 2 (red), and 6.0% cows had a lameness score of 3 (grey).
Experimental process and results
This study usedCameras and deep convolutional neural networks (Mask-RCNN algorithm, SORT algorithm and CatBoost algorithm) are used to detect the postures of multiple cows.The researchers tracked the key points on the cow's back and head in the video and extracted relevant feature indicators for analysis to detect the degree of lameness.
Posture analysis algorithm
After the researchers developed a part of Mask-RNN (entity segmentation algorithm) on their own,A posture analysis algorithm was constructed to estimate the posture of each cow.The algorithm was trained using 500 images from the Google dataset and images of 189 cows out of 250 cows, while the remaining 61 cows were used for final verification.
at the same time,The algorithm will locate 15 key points with high precision and output the specific coordinates of each point for posture analysis.There are 5 key points on the back and 2 key points on the head.
Tracking Algorithm
In the above steps, from decomposing the video into its component frames to annotating key points of each image and applying Mask-RNN for posture analysis, all are based on a single still image. Therefore, the experiment also needs to analyze the cow's movement over time.The researchers used the SORT algorithm (real-time tracking algorithm), which can detect cow posture over time and obtain indicators such as back regression curve, back area, neck regression curve degree and neck angle.

The top image shows the three cows in the first frame, each marked with a different color. The middle image shows the movement of the cows one second later, and the tracking algorithm has found all the marked cows and successfully marked them with the corresponding colors. Similarly, the bottom image shows the movement of the cows one second later.
Classification Algorithms
After obtaining the posture analysis results output by the posture deep learning model,The researchers used the CatBoost algorithm to score and classify lameness in dairy cows.It is worth noting here that in order to ensure maximum generalization, only the most important posture feature results should be used in the final training model. Therefore, the researchers conducted a series of variable permutation analyses and ultimately concluded that deleting 4 unimportant indicator information can reduce the error without much impact on model performance.

Finally, to test the accuracy of using the CatBoost algorithm,The researchers used triple cross-validation and classification validation methods to verify the model performance.Among them, the triple cross-validation results showed that the algorithm model can carefully classify each cow into different lameness score levels according to the degree of lameness.The average accuracy is 94%±0.05.

In summary, the researchers suggest that compared with existing systems for detecting lameness in dairy cows,This research has the following significant advantages:
* Capable of testing multiple cows simultaneously.
* Cows are classified according to the commonly used AHDB scoring system based on their movement.
* Ability to track and analyze each individual over time.
* Fully automated, no impact on milking, feeding and other production.
at last,The researchers also raised several challenges:
- The system was much less accurate in distinguishing between lameness scores of 0 and 1 than it was in distinguishing between other scores.In the future, the research team will focus on improving the ability to detect small feature differences.To accurately distinguish between non-lame cows and cows with slight mobility problems.
- The system requires edge devices (such as cameras, mobile devices, or tablets) to send the results to the server for processing, thereby achieving real-time observation.How to reduce performance fluctuations caused by network changes?This will become the focus of future research.
- The system is easily affected by external environmental conditions. For example, when the floor and the cow's hoof are similar in color, the recognition accuracy of the Mask-RCNN algorithm will decrease.Adding more generalized ability training will also become a focus of future work in this research.
Good! AI drives the digitalization of the livestock industry
At present,It is an indisputable fact that the wind of AI has blown into the livestock industry.Focusing on foreign countries, in addition to the scientific research results introduced in this article, due to the high scale of animal husbandry and good digital foundation,AI has achieved a lot of results.For example, Connecterra, a Dutch agricultural technology company, has developed the Intelligent Dairy Farmer's Assistant (IDA) system, which uses wearable devices on cows' necks to monitor the health of cows in real time. According to an American rancher,The application of IDA helped improve the productivity of 10%.
Turning our attention back to China,On the one hand, there are many examples of AI being used in the livestock industry in recent years.As early as a few years ago, Alibaba started the smart pig farming business, and Huawei also launched the "Little Shepherd" product based on NB-IoT in cooperation with China Telecom and Yinchuan Aotu. However, on the other hand, we also need to see that the coverage of AI applications in domestic animal husbandry is still not very wide. In this regard, the CEO of Shenmu Technology once said bluntly,"When many domestic farmers talk about artificial intelligence, their understanding of it is still limited to the most traditional facial recognition and voice recognition."
Therefore, in this context, how can AI play a more positive role in promoting the digitalization of animal husbandry?It will undoubtedly become one of the topics that need to be focused on in the fields of AI and animal husbandry.Of course, for related domestic fields, this road is still long and arduous.