A machine learning pipeline for automated insect monitoring

Aditya Jain, Fagner Cunha, Michael James Bunsen, Léonard Pasi, Anna Viklund, Maxim Larrivée, David RolnickarXiv 2024 · DOI

Introduction

The global decline in insect populations, often referred to as the "insect apocalypse," represents a significant threat to biodiversity and essential ecosystem services like pollination. Insects comprise nearly half of all known living species, yet monitoring their populations at scale remains a major challenge for ecologists. Traditional manual collection and identification are labor-intensive, require rare taxonomic expertise, and cannot scale to meet the needs of global biodiversity tracking. While camera traps have transformed the study of large mammals, their application to entomology is hindered by the "data bottleneck": a single night's trapping can generate thousands of images containing a complex mix of insects and debris. This paper presents an open-source, end-to-end machine learning pipeline designed to automate the detection, classification, and tracking of insects from raw camera trap imagery.

Methods

The proposed system utilizes a modular four-stage pipeline to transform raw trap photos into high-quality ecological data.

The four-stage automated monitoring pipeline: detection, binary classification, species identification, and tracking.
  1. Insect Detection: To overcome the lack of annotated bounding box data, the researchers employed a "weak annotation" strategy. The Segment Anything Model (SAM) was used to automatically extract approximately 4,000 insect "crops" from trap images. These were then synthetically pasted onto empty background images to create a training set of 5,000 images, bypassing the need for manual labeling.
  2. Moth/Non-Moth Classification: A binary ResNet-50 classifier filters out non-moth arthropods (e.g., beetles, spiders) and debris, ensuring the subsequent species-level analysis focuses on the target group.
  3. Fine-Grained Species Identification: Addressing the challenge of identifying 160,000 global moth species, the authors developed regional models (e.g., for Quebec/Vermont or UK/Denmark). They utilized zero-shot transfer learning, training models on high-quality citizen science photos from iNaturalist and GBIF, then applying them to lower-quality, top-down camera trap images.
  4. Tracking: To prevent double-counting individuals, a tracking algorithm based on linear sum assignment was implemented. It considers Intersection over Union (IoU), size ratios, distance between centers, and visual feature similarity to link detections across frames.

Datasets

The pipeline was developed and validated using several key data sources:

  • GBIF & iNaturalist: Approximately 350,000 annotated images served as the primary training data for species identification.
  • Darwin Core Archive (DwC-A): Used for taxonomic cleaning and metadata management.
  • Partner Trap Data: Real-world, unlabeled imagery from North America, Europe, and Central America.
  • Expert-Annotated Test Set: A gold-standard set of 1,000 insect crops used for rigorous performance validation.

Key Results

The pipeline demonstrates high efficacy in real-world ecological monitoring scenarios. The moth/non-moth classifier achieved a filtering accuracy of 95.10% on expert-annotated imagery. For species-level identification in the Quebec/Vermont region, the model reached 86.14% accuracy on held-out GBIF data and 77.81% on expert-labeled trap images.

Example of the pipeline's output, showing automated detection and species-level classification on a real trap image.

To ensure practical utility, the team optimized the detector using a MobileNetV3 backbone, which runs six times faster on standard CPUs than heavier alternatives, making the system accessible to researchers without high-end GPU clusters. The framework is currently deployed in field sites across five countries.

Discussion and Limitations

A core innovation of this work is the use of synthetic data and strong data augmentation (e.g., RandAugment) to bridge the "domain gap" between high-quality citizen science photography and grainy, UV-lit trap images. By employing regional checklists, the system significantly reduces the label space, enhancing local accuracy.

However, several challenges remain. The tracking module currently lacks a ground-truth dataset for quantitative evaluation. Furthermore, the "long-tail" distribution of insect species means rare moths are underrepresented in training data, potentially biasing models toward common species. Future work will focus on expanding the framework to other insect orders and refining tracking metrics.

Summary updated

BibTeX
@misc{jain2024machine,
  author = {Aditya Jain and Fagner Cunha and Michael James Bunsen and Léonard Pasi and Anna Viklund and Maxim Larrivée and David Rolnick},
  title = {{A machine learning pipeline for automated insect monitoring}},
  year = {2024},
  eprint = {2406.13031},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.13031},
}
Figure