An automated approach for counting ants in densely populated images and gaining insight into ant foraging behavior
Manual tallies of ant activity, often spanning tens of thousands of frames per experiment, are slow, error-prone, and rarely scalable. We introduce a hardware-agnostic computer-vision workflow that pairs state-of-the-art detectors (YOLOv11n/m and RT-DETR-L) with Slicing-Aided Hyper Inference (SAHI) to automate ant detection and counting in realistic laboratory and field imagery. The pipeline was evaluated across seven contrasting imaging setups through three key studies. First, we demonstrated that robust mean average precision (50.6-88.2%) can be achieved with as few as 64 annotated images across diverse backgrounds, while expanding the dataset to 1,024 images increases performance to 95.4%, establishing practical labor budgets for system deployment. Second, we showed that SAHI fine-tuning transforms dense-colony detection in scenes with over 1,200 ants per image from undetectable to highly functional, achieving 81% mean average precision. Third, we applied high-frequency counting to monitor a virus-challenged colony, revealing daily traffic patterns and inch-level movement hotspots that would be difficult to detect through manual observation. While RT-DETR-L delivers the highest overall accuracy, a YOLO variant that is 15 times smaller performs within a few percentage points and enables deployment on compact, energy-efficient edge devices like the Raspberry Pi. All models, images, and code are openly released, providing a turnkey framework that scales from petri-dish assays to distributed camera networks and is readily transferable to other small, densely packed organisms and behavior-rich systems (e.g., aphid colonies, social-bee foraging). By removing a long-standing counting bottleneck, the workflow enables large-scale behavioral ecology, pest-control optimization, and environmental surveillance at a fraction of previous labor costs. • Effective ant counting systems can be built cheaply with minimal manual effort. • Breaking images into smaller patches dramatically improves counting in dense ant colonies. • Automated counting reveals long-term foraging patterns that are difficult to capture through manual observation.
Authors
- Chin‐Cheng Scotty Yang (ORCID: https://orcid.org/0000-0003-0967-5170)
- Chunpeng James Chen
- Mautushi Das
- F. H. Liu (ORCID: https://orcid.org/0000-0002-2261-6899)
- Charly Hartle
Institutions
- Virginia Tech (US)
Publication Details
- Journal
- Ecological Informatics
- Published
- 2025-08-28
- DOI
- https://doi.org/10.1016/j.ecoinf.2025.103391
- Primary Topic
- Insect and Arachnid Ecology and Behavior
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- U.S. Department of Agriculture
- College of Agriculture and Life Sciences, Virginia Polytechnic Institute and State University