Sheep Facial Recognition (AI)

Project Overview

In this project, my team of 6 undergraduate students worked on developing an advanced facial recognition system using state-of-the-art Convolutional Neural Networks (CNNs) and cascaded network architectures to uniquely identify individual sheep and perform evaluation of their welfare.

Problem

Sheep Traceability
The sheep industry faces growing pressure to improve traceability, as mandated by the Health of Animals Regulations, which require animals to be uniquely identifiable throughout their lives. Traditional RFID ear-tags are time-consuming, resource-intensive, and require manual intervention. As a result, there is increasing interest in leveraging AI to enhance sheep traceability efficiently.

Welfare Assessment
Beyond traceability, Part XII of the Health of Animals Regulations aims to minimize animal suffering during transport. However, current welfare assessments rely on manual inspection, making the process time-consuming, inconsistent, and prone to human error. Inefficiencies in monitoring could negatively impact the industry and contribute to disease spread. A more accurate and automated welfare assessment method is needed.

Goal

The goal of this project is to develop an AI-driven solution that streamlines real-time sheep tracking and reporting while ensuring data integrity, regulatory compliance, and minimal stress on the animals. This system aims to improve efficiency by reducing manual intervention and enabling timely error correction.

Technical Details

We began by analyzing existing solutions for sheep traceability and welfare assessment, identifying gaps our AI-driven system needed to address. Given the problem's complexity, we divided it into two key components: unique sheep identification and welfare assessment.


Sheep facial recognition system showing detected landmarks

Unique Sheep Identification Lifecycle

Sheep facial recognition system showing detected landmarks

Welfare assessment system flowchart

To manage the workload efficiently, we split the project into smaller modules. My primary responsibilities included facial pinpoints detection, face normalization, and landmark feature extraction. We focused on detecting eight key facial landmarks—left eye (LE), right eye (RE), middle nose (MN), left nose corner (LN), right nose corner (RN), middle mouth (MM), left mouth corner (LM), and right mouth corner (RM)—as a proof of concept, though more landmarks would be needed for optimal accuracy.


Sheep facial recognition system showing detected landmarks

CNN architecture for facial landmark detection

For facial landmark localization, I explored cascaded convolutional neural networks (CNNs) to iteratively refine landmark predictions. Cascading introduces redundancy, helping the model improve accuracy in pinpointing facial features. Another proposed approach involved direct regression via ResNet transfer learning. Since ResNet is pretrained on millions of images, it has a strong grasp of both high-level spatial structures and low-level details like edges and textures. By fine-tuning ResNet, we adapted its learned representations to the task of sheep facial landmark detection.


For training and validation, I labeled 160 sheep face images, using data augmentation (random translations, brightness adjustments, scaling, rotation (-25° to 25°), and 10% noise) to expand the dataset to 640 images. Training images helped the model learn, while validation images provided an unbiased evaluation of its performance.


Sheep facial recognition system showing detected landmarks

Example of facial landmark detection on a sheep, showing the 8 key points used for identification

Results

The project achieved promising results in sheep facial landmark detection. Our cascaded CNN approach demonstrated robust performance, with an average landmark detection error of less than 5 pixels on validation images. The ResNet-based model showed slightly lower accuracy on validation compared to training data, indicating good generalization capabilities while still maintaining reasonable performance.

Key achievements include:

  • 95% accuracy in detecting all 8 facial landmarks within a 10-pixel radius
  • Robust performance under varying lighting conditions and head poses
  • Successful identification of individual sheep with 92% accuracy using extracted facial features

These results demonstrate the viability of automated sheep identification through facial recognition, though further improvements could be made by expanding the dataset and incorporating additional facial landmarks.

Demo video showing the sheep facial recognition system in action

Technologies Used

PythonTensorFlowOpenCVNeural NetworksPyTorch