Sign in
EcologyMethods in Ecology and Evolution
Peer-reviewed journal article

A General Method for Detection and Segmentation of Terrestrial Arthropods in Images

Asger SvenningiD, G MougeotiD, Jamie AlisoniD, Daphne ChevalieriD, Nisa Chavez MolinaiD, Song‐Quan OngiD, Kim BjergeiD, Juli CarrilloiD, Toke T. HøyeiD, Quentin GeissmanniD

Abstract

To better understand the status and trends of insects and other arthropods, emerging technologies like image recognition are developing rapidly. This is creating a strong demand for efficient and accurate algorithms for detection and localization of arthropods in images. Existing models have modest performance and do not generalise well to variation in scale, appearance and density of specimens, or imaging conditions. Consequently, each new application often requires manual labeling of training data and model training, which limits the uptake of image-based tools and technologies. Here, we introduce flatbug, which is a powerful and general model to count and outline insects and other terrestrial arthropods in images. The training dataset is large and diverse and represent 23 different lab- and field-based imaging systems. The best flatbug model achieves an average F 1 = 94.2% on our validation dataset. Crucially, we show that flatbug has great out-of-the-box performance and generalises well to novel contexts. When images from a given dataset are left out of model training, the performance of flatbug is only reduced by on average 7.1% for the dataset in question. By using truly stratified cross-validation, we set a precedent for robust evaluation of deep learning model performance and generalization. We also take steps towards scale- and size-agnostic arthropod detection, by developing an integrated tiling framework for inference and training. Additionally, flatbug s implementation of YOLOv8 for instance segmentation enables downstream background removal and body size estimation. The generaliseability of flatbug stems from the diversity of contexts represented in the flatbug dataset, including 113550 arthropods annotated across 6131 images. Alongside a fully documented Python package with tutorials for integration and analysis via https://github.com/darsa-group/flat-bug/, the flatbug dataset is available from https://www.doi.org/10.5281/zenodo.14761447. By providing performant models and the accompanying dataset, flatbug offers both a ready-to-use tool and a benchmark for the future. Overall, flatbug represents a significant methodological advance within arthropod image detection, with user-friendly integration for monitoring and research. O_FIG O_LINKSMALLFIG WIDTH=200 HEIGHT=134 SRC="FIGDIR/small/647223v1_ufig1.gif" ALT="Figure 1"> View larger version (80K): org.highwire.dtl.DTLVardef@2d25c0org.highwire.dtl.DTLVardef@9929borg.highwire.dtl.DTLVardef@77ff28org.highwire.dtl.DTLVardef@10bd2f_HPS_FORMAT_FIGEXP M_FIG C_FIG

02 /Specification & Classification

Click any tag to browse matching papers

In-depth summary

✦ Multi-agent verified full-text synthesis

Claude Opus 5.5 · xhigh effort · 7 Nov 2026 · from the full text of version 1 (14 Apr 2025) · CC BY 4.0

flatbug, a YOLOv8 instance-segmentation model with multi-scale tile-pyramid inference and polygon-based deduplication, segments terrestrial arthropods across 23 image subdatasets and transfers to held-out subdatasets with a modest F1 penalty.

Manual counting limits arthropod monitoring; the authors note that existing arthropod detectors target narrow use cases, and SAHI-style tiling over fixed-size models such as YOLOv8 misses intermediate-size instances and deduplicates on bounding boxes. flatbug tiles each image at geometrically spaced scales, deduplicates on segmentation polygons, and comes with a stratified, openly licensed 23-subdataset training set that permits testing on held-out image domains.

Key results

  1. ShownLarger YOLOv8 backbones scored somewhat higher on the in-domain validation split. Medium and small were nearly tied, and nano lost the most, especially on its worst-case subdatasets.

    Models were trained for 300 epochs on 5153 images and validated on 978 images from the same 23 subdatasets. AP50: 0.937 (L), 0.932 (M), 0.933 (S), 0.914 (N). AP50-95: 0.872, 0.862, 0.86, 0.821. A few subdatasets drove the gaps between sizes: ATO, BIS and AMA for precision, AMI and BDA for recall. · 3.1 Experiment 1: Backbone size comparison; L Experiment 1: Precision-Recall Curve and…

  2. ShownLeaving one subdataset out of training lowered F1 on that subdataset, mostly through lost recall. The mean change in precision was not significant, but it varied widely between subdatasets.

    There were 23 leave-one-out medium models (50 epochs) plus a full-data control, each scored only on the held-out subdataset: δF1 ≈ −7.1% [−12.1%, −0.4%], δR ≈ −10.3% [−13.9%, −6.6%], δP ≈ 4.5% [−4.8%, 13.7%]. δ is a normalized relative change (the share of possible loss or gain), not a raw difference. Precision fell sharply for BIS and SIT and rose for AMT and CAO. · 2.5.2 Experiment 2: Leave-one-out…; 3.2 Experiment 2: Leave-one-out cross-validation; 2.4 Evaluation

  3. ShownTen more epochs of training on the held-out subdataset alone closed the gap to a full-data control that was also fine-tuned, with a small gain in precision.

    Fine-tuned leave-one-out vs fine-tuned control: δF1 ≈ 0.9% [−1.3%, 6.7%], δR ≈ 0.0% [−2.4%, 4.5%], δP ≈ 5.1% [1.7%, 9.9%]. Intervals are bias-corrected and accelerated bootstrap intervals, with each subdataset weighted by the logarithm of its instance count. · 3.2 Experiment 2: Leave-one-out cross-validation; Figure legends

  4. SuggestedPairwise leave-two-out training showed how the subdatasets help one another. Most form one mutually beneficial cluster. The citizen-science images (ATO), Collembola on soil (CAI) and a moth light-trap set (DPS) sit apart, which points to domain gaps.

    136 + 1 medium models (20 epochs) on 16 of 23 subdatasets, scored by two-way redundancy ρ² on F1. 11 of 16 subdatasets fall in a central synergistic cluster. BIS and PIN form a separate pair that benefit each other. AMI-AMT (the same camera-trap system) has the lowest ρ². In a minimum spanning tree on a PCoA of the redundancy matrix, 10 of 15 edges are negative, and 3 of the 5 positive edges touch ATO, DPS or CAI. · 2.5.3 Experiment 3: Leave-two-out…; 3.3 Experiment 3: Leave-two-out cross-validation; M Experiment 3: Leave-two-out cross-validation…

  5. ClaimedThe authors argue that deduplicating on polygon IoU instead of box IoU separates tightly packed individuals better, and that a two-stage NMS makes it affordable. No ablation or timing is reported to support either point.

    Stage 1 groups predictions into connected components using bounding-box IoU at a 0.05 threshold. Stage 2 runs polygon NMS within each component, which cuts polygon intersections below O(N^2). The only support in the text is one example of disjoint polygons whose boxes overlap (Fig. S7). No comparison with SAHI or standard YOLOv8 NMS is quantified. · 2.3 Inference; 4 Discussion; Figure legends

Methods, data and reproducibility

YOLOv8 segmentation models are trained on tile crops sampled at random zoom levels. At inference, each image is tiled at geometrically spaced scales (1024px tiles, ratio 1.5) and predictions are merged by polygon-IoU non-maximum suppression. Models were scored with polygon-IoU 0.2 matching and bootstrapped F1, across backbone sizes and in leave-one-out and leave-two-out subdataset cross-validation.

  • flatbug dataset: instance-segmentation annotations of terrestrial arthropod images from 23 subdatasets (15 derived from existing data and re-annotated, 8 new) · terrestrial arthropods (multiple taxa) · n = 6131 images (5153 training, 978 validation) · 10.5281/zenodo.14761447
  • Subdatasets picked ad hoc to represent the full set while keeping the number of models manageable, used for leave-two-out cross-validation · terrestrial arthropods (multiple taxa) · n = 16 of 23 subdatasets
  • Example subdatasets: ATO (citizen-science insects on natural backgrounds), CAI (white Collembola on black soil), DPS (light-attracting moth camera trap), AMI/AMT (one camera-trap system) · arthropods (e.g. Collembola, moths)
Methods & tools
flatbug, YOLOv8 (segmentation), SAHI (design inspiration), PyTorch, NumPy, shapely / GEOS, OpenCV (Telea inpainting), CVAT, R 4.4.1 with tidyverse, submitit, SLURM, PCoA and hierarchical clustering
Software & environment
Python 3.11 (PyTorch, NumPy, YOLOv8, shapely), with R 4.4.1 and tidyverse for statistics and figures, on Linux Ubuntu 24.04. flatbug is distributed as an open-source Python package with Python and CLI interfaces. The text gives no lock file, container or other package versions.
Assay conditions & compute
Training ran on NVIDIA H100 hardware on UCloud through DeIC, with jobs managed by submitit and SLURM. Inference is GPU-accelerated with CUDA and supports half precision. No training or inference times or memory use are reported.
Reproducibility gaps
Inference and training runtimes are not reported. The per-subdataset DOIs are in Table S1, which is not reproduced in the text.
Limitations (5)
  • The tile pyramid is highly redundant across scales, so inference costs more than it needs to; the authors name reducing this redundancy as future work. · stated by the authors
  • Coverage is weaker in peripheral domains. Citizen-science images (ATO), Collembola on soil (CAI) and the DPS moth-trap set gained little from the other subdatasets, and the authors say such domains need more similar training data. · stated by the authors
  • The authors suggest, speculatively, that the DPS subdataset is an outlier because of lower image quality on a yellowish screen and less consistent labelling. · stated by the authors
  • The text reports no quantitative comparison with SAHI, standard YOLOv8 inference or other arthropod detectors. The performance claims rest on absolute scores on the authors' own dataset and validation split. · noted in this summary
  • Instances below 32px (square root of polygon area) are dropped from training, evaluation and inference, so accuracy on very small arthropods at native resolution is not measured. · noted in this summary

Who should read:Read this if you need to detect and segment insects or other terrestrial arthropods in camera-trap, lab or field images at varying scales, or want a stratified dataset for testing how detectors generalize across imaging domains.

Reproducibility ledger

Nobody has reported trying to reproduce this paper yet. Did you replicate an experiment or run the code? Your report saves the next lab a week.

Sign in to file a reproducibility report.