You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the order-level classifier runs on detections from real trap imagery, it confidently assigns an insect order to crops that are not animals at all — smudges on the sheet, plant matter, debris, and similar artifacts. This is expected behaviour for a closed-set softmax model rather than a defect in the model or its training: the classifier has 16 classes and no "not an insect" option, so every crop it is handed must be assigned one of them, and neural networks are generally confident on inputs far outside their training distribution.
Opening this to collect options and decide whether it is worth addressing, and where.
Background — why this happens
The order classifier (convnext_tiny_in22k, 16 classes: 14 insect orders plus Araneae and Opiliones) is trained on GBIF occurrence images (the three Darwin Core Archive downloads listed in research/order_level_classifier/README.md). Those are photographs of identified insects: in focus, centred, and framed by a person who chose to photograph an insect. Detections from trap imagery include a much wider range of inputs, including things that are not organisms at all.
Two things worth noting so they are not mistaken for solutions:
The moth / non-moth binary head does not cover this. The training loss is p·L_binary + (1−p)·L_order, where the binary term separates moths from non-moth insects. It does not distinguish an insect from a non-animal crop.
Temperature scaling does not address it either. Following up on Explore cross-model confidence calibration for multi-model prediction selection #75, we fitted temperature for the order model (T = 1.403 on the GBIF val split, T = 1.165 on AMI-Traps; ECE improves in both cases — details in this comment). Temperature is a single global monotonic transform, so it rescales confident-and-correct and confident-but-meaningless predictions identically. Worth flagging too that our calibration evaluation used AMI-Traps crops filtered to those carrying a species-rank GBIF key — that is, confirmed insects — so it does not measure this out-of-distribution tail at all.
Also relevant: a new general-purpose insect detector is being trialled upstream, and it may produce fewer non-animal detections than the current one. That would reduce how often this arises, but probably not remove it, since any detector operating on trap imagery will pass through some non-animal crops.
Options
Listed roughly cheapest to most involved. Not mutually exclusive, and we do not have a preference yet.
Add a reject / background class. Fine-tune with negative crops (non-animal detections mined from trap data, which are plentiful). Likely the most effective option, but it needs labelled negatives and a training run, and it changes the checkpoint and category map, which is a downstream contract for consumers.
Filter upstream of the classifier. A dedicated blank/junk gate, or using the detector's own confidence, so obvious non-animal crops never reach the order model. Leaves the order classifier untouched at the cost of an extra stage.
Handle it downstream only (threshold or flag in the consuming application). Included for completeness, but it looks weak on the evidence: neither the softmax score nor normalised entropy separates these crops, so there is not much signal to threshold on.
Suggested first step
Measure the size of the problem before choosing, since as far as we can tell it has not been quantified. Concretely: assemble an in-distribution set (labelled insect crops) and an out-of-distribution set (non-animal crops from real trap imagery), then compare the order model's score distributions across the two and test whether a post-hoc score (max-logit, energy, Mahalanobis) separates them better than softmax does. If one of them separates cleanly, option 1 becomes a cheap improvement with no retraining.
Happy to run that and post the results here. Comments and corrections very welcome — particularly if any of this has already been looked at and we have missed it.
Refs: #75 (confidence calibration, incl. the order-model temperature results), #60, #25, #26.
Summary
When the order-level classifier runs on detections from real trap imagery, it confidently assigns an insect order to crops that are not animals at all — smudges on the sheet, plant matter, debris, and similar artifacts. This is expected behaviour for a closed-set softmax model rather than a defect in the model or its training: the classifier has 16 classes and no "not an insect" option, so every crop it is handed must be assigned one of them, and neural networks are generally confident on inputs far outside their training distribution.
Opening this to collect options and decide whether it is worth addressing, and where.
Background — why this happens
The order classifier (
convnext_tiny_in22k, 16 classes: 14 insect orders plus Araneae and Opiliones) is trained on GBIF occurrence images (the three Darwin Core Archive downloads listed inresearch/order_level_classifier/README.md). Those are photographs of identified insects: in focus, centred, and framed by a person who chose to photograph an insect. Detections from trap imagery include a much wider range of inputs, including things that are not organisms at all.Two things worth noting so they are not mistaken for solutions:
p·L_binary + (1−p)·L_order, where the binary term separates moths from non-moth insects. It does not distinguish an insect from a non-animal crop.Also relevant: a new general-purpose insect detector is being trialled upstream, and it may produce fewer non-animal detections than the current one. That would reduce how often this arises, but probably not remove it, since any detector operating on trap imagery will pass through some non-animal crops.
Options
Listed roughly cheapest to most involved. Not mutually exclusive, and we do not have a preference yet.
Suggested first step
Measure the size of the problem before choosing, since as far as we can tell it has not been quantified. Concretely: assemble an in-distribution set (labelled insect crops) and an out-of-distribution set (non-animal crops from real trap imagery), then compare the order model's score distributions across the two and test whether a post-hoc score (max-logit, energy, Mahalanobis) separates them better than softmax does. If one of them separates cleanly, option 1 becomes a cheap improvement with no retraining.
Happy to run that and post the results here. Comments and corrections very welcome — particularly if any of this has already been looked at and we have missed it.
Refs: #75 (confidence calibration, incl. the order-model temperature results), #60, #25, #26.