top of page


  • LinkedIn
  • Twitter
  • Facebook
  • YouTube

Farm animal facial recognition

Updated: Oct 26, 2022

Farm animals such as pigs, cows and sheep each have different personalities and behaviour, including how they are able to handle different types of stress or other challenges. As stress is known to reduce growth and productivity while increasing susceptibility to disease, these differences between animals can lead to a variety of welfare outcomes across the farm. Therefore, farmers would like to track their animals at an individual level, keeping an eye on their health and welfare to notice any problems early and provide them with the best care.

Animal welfare is assessed by measuring different indicators that can give insight into the health and emotional status of each animal. These indicators generally include both direct behavioural observations of the animals and the assessment of indirect biomarkers in blood, saliva or faeces. Behaviour observations can include overall changes in posture such as a hunched back or lying down, but also more subtle changes in facial expressions such as a wrinkled nose or flattened ears. While several scoring systems have been developed to standardise and quantify these behaviours, e.g. the Pig Grimace Scale or the Cow Pain Scale, the potential for observer bias or error remains. Additionally, modern farms involve large numbers of animals housed in groups looked after by relatively few farm workers, so real-time manual scoring of all individual animals is not feasible.

The issue of subjectivity is removed by instead measuring biomarkers such as cortisol, immunoglobulin or microbiome profiles that can reflect the underlying pathophysiological responses to stress. These biomarkers not only correlate to stress levels, they are often involved mediating in the downstream effects on animal health, making them particularly useful in predicting health outcomes. However, unlike the non-invasive behaviour analysis, collecting these samples involves handling the individual animals which may also increase their stress, particularly when collecting blood samples, and also represents a significant amount of work for farm workers and researchers.

Because of these issues, researchers have come up with new methods to automate the behaviour analysis using facial recognition and machine learning. Similar to the last blog post where deep learning (DL) was used to decode and understand pathology images, here a type of DL called convoluted neural networks (CNN) is used to analyse video footage of pigs or cows taken by webcams mounted over their pens. The CNN is trained first to recognise individual animals within the video feed based on the shape of their face and ears and any markings on their coat. Identifying who is who already allows the overall behaviour of each animal to be tracked, for example how often they eat or drink, where they go in the pen, and how they interact with each other. The CNN training is then extended to include behavioural markers such as seen in the Pig Grimace Scale, where the posture and facial expressions of the animal give insight into it's emotional state. Once the behavioural assessment is complete, this information is integrated with other known data about each animal such as genetic background, breeding history, symptom history, biomarker status, or microbiome, and the animals are then classified within the CNN into different groups based on their welfare status.

There are still some challenges to be solved with these methods, especially around getting good quality images of the animals in a production farm setting. However, once they are solved, we expect that this technology will be able to provide early alert systems for farmers, letting them know when an animal is not doing well so problems can be solved quickly. A particular strength of the CNNs used in these systems is the ability to integrate a range of different data types when classifying the animals, where different layers within the neural net can address different data or problem types to give a more robust classification. This, in turn, will provide a useful research tool for assessing the effects of different food supplements, housing changes or other interventions on animal health and productivity, allowing us to improve farming practises for more sustainable and ethical food production.

For more info and some other case studies on using different types of machine learning in biology, take a look at our video. Written by Shelley Edmunds

Sign up to get the latest blog posts by email

bottom of page