Part 1: Before ICAERUS
1. Why Do We Need to Count Sheep?
Counting sheep is a fundamental part of livestock management, yet the task is anything but straightforward. For centuries, shepherds have relied on hands-on techniques, passing down strategies from one generation to the next to ensure accurate counts:
- Black Sheep Method: Shepherds sometimes introduce a known number of black sheep into a predominantly white flock, then count only the black sheep as a sample. If one black sheep is missing, it often indicates that white sheep may also be missing, making it easier to gauge the flock’s overall size and status.
- Stone-Counting Method: Another classic method involves placing one stone in a pocket for each group of 50 sheep counted, allowing the shepherd to track large numbers without recounting or losing track.
The size of sheep flocks varies significantly depending on geographical location and farming objectives. While detailed data on farm and flock structures may be limited, some insights are available at the national level in France:
- 71% of meat sheep are raised in flocks of over 150 ewes.
- 30% of sheep are part of flocks that exceed 500 ewes.
That’s a lot of woolly heads to count and and that’s not even counting their lambs! Some farms divide their flocks into smaller groups, while others combine flocks from different farms to graze together in the mountains. So, when we talk about “counting sheep,” we’re usually talking about hundreds, sometimes even thousands of them.
Figure 1: Distribution of Livestock and farms with meat ewes according to flock size in France (Idele 2024)[1]
To sum up, counting sheep means tallying from hundreds to thousands of nearly identical, constantly moving animals —a task that requires both patience and precision. In practice, counting requires animals to be funneled into a sheep handling system (set of fences to form pens and corridors) that enables one-by-one counting. This process is time-consuming and relies on expensive handling systems, which means that full counts are rarely performed due to the logistical effort involved.
2. Are There Any Tools Available Right Now?
Sheep farmers and herders have limited tools at their disposal to streamline sheep counting. One available option is the use of electronic identification (eID) in sheep ear tags, which is even mandatory in some European countries for identifying and tracking sheep. In theory, a fixed or mobile antenna can read these eIDs, providing farmers with both a headcount and an individual record of each animal. Great! No?
However, in practice, achieving 100% accuracy with this system can be challenging. For reliable results, each animal must be scanned individually to avoid occlusion (when one animal blocks another) and misreads, which means farmers still need handling systems similar to those used in manual methods. While eIDs offer greater accuracy than traditional approaches, the complexity of implementing them has limited their adoption among European farmers.
Could Computer Vision Offer a Solution?
Given the advancements in computer vision and AI, one might expect to find an effective sheep-counting system based on this technology. Notably, “sheep” is one of the labeled categories in popular datasets used to train models like YOLO, a well-known computer vision model for object detection. Let’s explore how it performs in practice.
Video 1: Demonstration of YOLOv8 applied to sheep detection from an aerial view Video 2: Demonstration of YOLOv8 applied to sheep detection from a first-person view.
The results of our sheep detection model are promising when filmed from a person’s point of view. This perspective benefits from the availability of public datasets, which predominantly feature sheep captured at this angle. However, while the person-view perspective aids detection, it introduces challenges in tracking due to significant occlusion between sheep, making it difficult to distinguish individual animals in close proximity.
On the other hand, detection performance declines when switching to aerial, low-altitude views. This highlights a critical gap in the model’s adaptability and suggests that substantial advancements are necessary before computer vision technology can reliably support on-farm applications.
However, a related system for counting pigs has been introduced in North America (Ro-main : automatic pig counter). This development suggests potential for similar technology to be adapted for sheep, although it has yet to be implemented on the market.
3. What Have Researchers Done So Far?
Let’s explore some recent research efforts aimed at addressing these gaps. For electronic IDs (eIDs), studies are experimenting with a new generation of eIDs based on Ultra High Frequency (UHF), which may be better suited for efficient sheep tracking. However, eID advancements aren’t the main focus of this post.
Turning to computer vision, researchers are increasingly interested in combining drone imagery with computer vision to automate animal monitoring. This idea builds on the long-standing aerial survey techniques used by wildlife scientists to monitor species, such as endangered mammals on the African savannah. In these surveys, drones or planes fly over large areas to capture images, which are then processed by detection models to locate and count animals. Animal scientists are now exploring this method using drones—now more affordable—and computer vision algorithms to automate the process (ref). While there have been promising proof-of-concept studies, scaling this approach has proven difficult. Most efforts thus far have focused on detecting and counting cattle, with relatively little research on sheep or other small ruminants (ref). Could more dedicated work and effort eventually produce an accurate sheep-counting solution?
In our view, it’s a bit more complicated. Trying to directly apply methods used in wildlife aerial surveys may be overly ambitious. Expectations for computer vision solutions in agricultural settings are extremely high: for a flock of 1,000 ewes, even a 1% error rate means missing 10 sheep—a significant discrepancy for a farmer. Sheep are also highly social and tend to cluster and move together, which complicates aerial counting. During a survey, sophisticated techniques would be needed to avoid double-counting due to animals’ movements between different points of image collection in the flight. Additionally, sheep often graze on rangelands with dense vegetation, creating further occlusions that can make accurate detection difficult.
Let’s be realistic! Computer vision rarely reaches detection accuracy above 95%, and it often struggles across different environments. Even with 100% accuracy, a sheep standing under a tree would still go unnoticed. So instead of aiming for perfection in such complex, fully automated setups, maybe it’s time to adjust our goals and rethink how we approach counting to get the best possible results.
Now, let’s dive into what the ICAERUS project has in store for sheep farmers!
Part 2: With ICAERUS
1. Doing less! Doing it better!
After two years of drone deployment on farms, we’ve been able to create a new, more practical framework for using computer vision and drones in animal counting. The key was to define a realistic threshold: How can we genuinely make life easier for sheep farmers by using drones and computer vision in a way that’s actually deployable?
Instead of aiming for a fully automated animal count—which can often be impractical or run afoul of aviation regulations—we focus on timing and location to maximize counting accuracy. In many farm systems, sheep naturally pass through large gates when moving between pastures or returning to their night pens, which protect them from predators. Our solution involves using the drone as a stationary camera, recording video as sheep move through these “count-friendly” areas. These “count-friendly” zones function as corridors or funnels, ensuring that all the animals must pass through during a brief time frame. By targeting these specific moments, we can offer an efficient and achievable solution for animal counting.
Now, for farmers, this isn’t a magic solution that works everywhere, but it’s a significant improvement over traditional manual counting or eID-based methods, which require funneling animals one by one to count them.
You might wonder: What’s innovative about this?
The ICAERUS approach embodies the idea of “Doing less! Doing it better!” By narrowing the focus of our solutions, we anticipate achieving much higher counting accuracy than what’s typically seen in classic aerial surveys. We’ve also co-designed this solution with various farmers through on-farm deployments and demonstrations, taking a close look at drone regulations along the way. By aligning the opportunities offered by computer vision with the realities of the field, we strongly believe this innovation can scale under real conditions (achieving high TRL), particularly in accordance with European regulations.
So, is a drone absolutely necessary in this framework? Not entirely! Our computer vision solution could also work with a simple camera. That’s the beauty of it—if a farmer only needs to monitor a few counting areas, a standard camera will suffice. However, if the goal is to count across various locations, simply pop a drone in your backpack, launch it whenever needed, and start counting with the app on the remote controller or your smartphone. If some sheep go missing, use the drone as your eye in the sky to help locate them.
Video 3: Demonstration of animal counting
Looking ahead, our next steps involve further refining these counting scenarios to provide advice on how to optimize animal handling. We aim to suggest handling techniques and their potential impact on counting accuracy. Ultimately, it will be up to the farmers to decide whether to count under more or less stringent conditions based on their accuracy needs.
2. Fine-tuning available AI models for sheep counting
The limitations of current AI models in sheep-counting applications underscore the importance of retraining and fine-tuning these systems to meet the unique challenges of sheep farming. While powerful models like YOLO have proven effective across various use cases, they are typically trained on generalized datasets that often fail to capture the subtleties of sheep appearances—especially from unconventional angles, such as top-down views—or the diverse environments in which sheep are found. Even low-altitude drone footage, which attempts to bridge the gap between ground-level and aerial perspectives, presents distinct challenges that these models are not yet fully optimized to address.
However, we’re not starting from scratch. By building on existing technologies, our approach involves fine-tuning detection models to accurately identify sheep in images, followed by applying available tracking algorithms to recognize the same sheep across consecutive frames in a video. Once tracking is established, counting sheep becomes a straightforward task (as demonstrated in Video 3).
Fine-tuning of detection models
Our method focuses on fine-tuning pre-existing models like YOLO for sheep detection. Fine-tuning involves adjusting a pre-trained model by exposing it to new, specific datasets—such as drone footage of sheep—enabling the model to specialize in this particular task without requiring extensive retraining. This approach significantly reduces development time while improving performance. However, the success of fine-tuning hinges on the availability of high-quality, targeted datasets.
Leveraging Existing Aerial Image Datasets
We started by reviewing publicly available datasets, such as those available in the Roboflow platform, which include pre-annotated aerial images of sheep and livestock. These datasets serve as a valuable starting point for pre-training models, helping them recognize sheep in a variety of farm settings and environmental conditions.
Capturing images from a Pilot Farm
To address gaps in existing datasets, we’ve gathered tailored data from pilot sheep farms. This involves capturing images and by flying drones at low altitudes (5 to 10 meters) during different times of the day. We’ve ensured a diverse range of lighting and movement conditions. Each image is then progressively annotated to label individual sheep, providing the detailed data needed for training. But it’s a long on-going process!
Fine-tuning of AI models for sheep detection
Using the collected data, we fine-tuned a sheep detection model built on the pre-trained YOLOv8 architecture. This approach utilized sheep images captured from drone flights to tailor the model for accurate detection in real-world sheep farming scenarios. For those interested in a deeper dive into the implementation, feel free to explore our ICAERUS GitHub repository. As of now, our best-performing detection model achieves the following metrics:
- Precision: 0.87
- Recall: 0.80
- mAP50-95: 0.57
While these results are promising, there is still room for improvement, which we will discuss in the subsequent sections.
Implementation of models for animal tracking and counting
Building on the detection model, we implemented a tracking and counting pipeline using the Supervision Library. The chosen tracking algorithm was ByteTrack, which has proven to be efficient in handling dynamic livestock monitoring scenarios. As for the detection models scripts, the tracking algorithm is also available on the ICAERUS GitHub repository.
The counting pipeline seems very promising but there are still challenges to overcome.
Our challenges to overcome
Density and performance of tracking
Tracking performance depends on the density of the number of animals on the video and the number of frames per second. Indeed, a greater number of animals on the image makes detection by the algorithm more difficult.
Figure 3: Example of the complexity of images.
For example, a small flock of sheep, like the one on the left in Figure 3, where individuals are clearly separated, will be easier to count for the algorithm than a large flock, like the one on the right in Figure 3, where individuals move as a group and are very close to each other.
Moreover, more frames per second make it easier to ByteTrack algorithm to follow each individual and so a better tracking will be performed on videos of 30 fps than 5 fps.
As animal scientists first and foremost, we approach AI as a powerful tool, not a magical solution. We recognize that the complexities of livestock management can’t be fully resolved by technology alone. That’s why our focus extends beyond model optimization to practical applications in real-world scenarios.
We plan to test various funneling conditions to identify the optimal setups for accurate counting. By analyzing factors such as sheep density, movement patterns, and environmental conditions, we aim to recommend the best scenarios for reliable operation.
In cases where difficult scenarios are unavoidable—such as high-density herding and very high speed—we’ll raise awareness about the potential impact on accuracy. This way, farmers and practitioners can make informed decisions, leveraging AI insights while understanding its limitations.
Variance collection to improve sheep detection
While the model performs well in many scenarios, there are still a few challenges that need to be addressed for better accuracy and reliability through a better and targeted data collection:
1. Detection of Colored Sheep
The model struggles to accurately detect sheep with non-standard colors, such as black, brown, or spotted sheep (see the black sheep in video 3). This issue likely stems from an insufficient variety of sheep colors in the original training dataset, leading the model to be more attuned to standard white sheep.
2. Misclassification of Dogs and Humans
There are instances where the model incorrectly classifies dogs and humans as sheep. This often happens when the AI system encounters similar shapes or sizes, causing confusion in distinguishing between livestock and other animals or people.
To resolve these issues, our next steps involve:
- Expanding the Training Dataset: We will gather a more diverse range of sheep images, including different colors, sizes, and breeds, to ensure the model can accurately detect sheep in various forms.
- Improving Differentiation: We will incorporate more images of humans and dogs into the dataset to help the model better differentiate between these and sheep.
Since both precision and recall heavily rely on the diversity and quality of the training data, these adjustments will be key to enhancing the model’s overall performance and ensuring more accurate sheep detection across different farm environments.
3. Sheep and sheep farmers need you!
Farmers need your help to make sheep counting easier, more accurate, and efficient. Developing these AI-based solutions is not something that can be done in isolation—it requires collaboration and shared expertise across the farming, tech, and research communities. By working together, we can build smarter, more adaptable systems that truly serve the needs of farmers.
We are committed to this cause and have made our models on ICAERUS GitHub repository, and our datasets available on zenodo platform for the datasets, so you can use, improve, and tailor them to your own needs. But this is just the beginning. We urge others in the community—whether you’re a researcher, a farmer or a digital solution providers —to contribute your data, insights, and experiences. By sharing your knowledge and resources, you help improve the technology and make it more accessible to everyone.
Alone, it’s a slow process, especially with data annotation. While we’re committed to making progress, we’re confident that together, we can achieve faster, more impactful results. By working as one, we’ll create solutions that are not only more effective but adaptable to a wider range of environments, bringing easier sheep counting to farmers around the world—not in five years, but tomorrow.
Let’s join forces and make it happen!
[1] Idele (2024). The key data – French sheep 2024 Milk and meat production. https://idele.fr/detail-article/the-key-data-french-sheep-2024-milk-and-meat-production