Addressing the practical pain points of insect biodiversity monitoring, this paper builds a million-scale, manually annotated, long-tailed insect dataset extracted from camera trap videos and proposes a deep learning classification model adapted to a five-level hierarchical structure. After training with class-balanced weighting, long-tail classes achieve good classification performance even on highly imbalanced data.
Current arthropod population monitoring efforts face multiple real-world constraints: on one hand, monitoring data lack standardization in temporal and spatial dimensions; on the other, professionals with insect taxonomy expertise are in short supply. Traditional insect monitoring relies entirely on manual work, with the whole process being time-consuming and requiring entomology experts for species identification. Techniques such as DNA barcoding can provide definitive identification for species with high intraspecific and low interspecific variation, but such methods involve destructive sampling and cannot capture population abundance information for specific species.
Existing hierarchical classification models generally have adaptability gaps and require extensive targeted modification to fit the special constraints of insect monitoring scenarios, including variable-depth classification hierarchies, highly imbalanced long-tailed datasets, and low-quality field images with occlusion, poor shooting poses, and fluctuating lighting conditions. The field still lacks a general-purpose hierarchical classification solution that can directly adapt to custom hierarchies, accommodate imbalanced partially annotated data, and handle low-quality field images.
Among published hierarchical classification studies, a two-level genus-species hierarchical classification model built for fish samples, although performing better than a non-hierarchical flat classifier on partially occluded images, had a too-shallow hierarchy and did not introduce hierarchical constraints in the loss function; that study manually constructed balanced training, validation, and test subsets from highly imbalanced original museum specimens.
The raw material for the insect image dataset built in this study came from video data collected by FAIR-Device automatic camera traps. The device replaced the lethal trapping unit at the top of traditional Malaise insect traps and used motion triggering to record insects or other arthropods passing through. Raw video collection was carried out in two periods, July-August 2021 and August-September 2023, at 4 grassland sites in Lower Saxony, Germany, yielding 2,541 video records ranging in duration from a few seconds to several hours. For device design details and data samples, see the related work by Chiavassa et al. 2024.
The research team screened 1,801 valid records from the videos, extracted about one million insect images, and completed full manual verification and curation, forming a long-tailed distribution dataset for insect classification tasks. The dataset uses a five-level hierarchical annotation scheme, covering 34 hierarchical classes consistent with biological taxonomy.
The hierarchical insect classification model consists of a feature extraction backbone, 5 level-specific modules, and corresponding level-specific classification heads. The study uses a pretrained ResNet18 as the feature extraction backbone, which is computationally lightweight and stable across various vision tasks; backbone parameters are not frozen during training, and the full model is optimized end-to-end. Each level-specific module contains convolutional and fully connected layers that refine the backbone's output feature maps for the corresponding level, generating a level-specific feature embedding after pooling and flattening. You can use the figure below to fully trace the model's overall forward flow and the layout logic of the sub-structures inside the hierarchical blocks.
During inference, the model reuses the hierarchical state space matrix S introduced during training to score all legal classification states. First, the sigmoid outputs of all level classes are concatenated into a single prediction vector per sample; the score of each legal classification state is then computed via the corresponding row vector of the state space matrix operating on the prediction vector; finally, maximum a posteriori inference selects the legal hierarchical classification result with the highest probability.
On the test set, the model's per-level covered-class accuracy has a minimum of 0.8174, with an overall range of 0.8174 to 0.9882. Matthews correlation coefficient (MCC) results show that from level L1 to L5, the class-distribution uniformity of the model's predictions gradually improves. The most imbalanced level, L2, still achieved an MCC of 0.7198, demonstrating the practical effectiveness of the class-balanced weighting strategy used during training. At the coarsest level L1, overall classification accuracy exceeds 98%, but this metric cannot reflect recognition deficiencies for rare classes: the rare class Arachnida had a recall of only 0.1682, and its samples were often misclassified as Insecta—a phenomenon that also validates the necessity of using MCC as the core evaluation metric.
Per-class image counts alone could explain less than one third of the variance in test F1 scores, with a corresponding of 0.3520. This result shows that when the class-balanced weighting strategy is applied during training, the model can achieve good classification performance on long-tail classes of a highly imbalanced dataset. You can use the scatter plot to directly observe the association trend between per-class image counts and test F1 scores.
The study found that the total pixel count per class explains more of the F1 score variance than per-class image counts alone. This result indicates that when a class simultaneously has a low sample count and low per-sample resolution, the model's feature learning degrades noticeably.
Compared with other hierarchical models and flat models, this hierarchical classification architecture shows clear advantages in three dimensions: rare class classification, distinguishing visually similar classes, and dataset imbalance correction. However, overall model performance is still constrained by training data availability, with poor performance in two scenarios: classes with low resolution combined with low sample counts, and low-sample classes whose individual samples differ too much visually.
Deep learning applications for insect classification in biodiversity monitoring have long faced the high cost and time demands of acquiring expert annotations, while traditional flat classification models struggle to generalize well in large-scale class settings with large granularity differences and highly imbalanced training data. By building a hierarchical dataset extracted from automatic camera trap recordings, combined with a hierarchical image classification model with class-balanced weighting, this study achieves stable classification performance for both head and long-tail classes, effectively distinguishes visually similar classes, and leverages the hierarchical structure to maximize prediction confidence while minimizing the proportion of unclassified samples.