Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
imagewidth (px)
300
9.09k
label
class label
0 classes
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
End of preview. Expand in Data Studio

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Evaluation Harness

The standard evaluation tooling for the IBBI-bio bark & ambrosia beetle detection benchmark. Two scripts:

Script What it does
evaluate.py Scores a single model on the three test splits (iid_test, inat_test, semantic_ood)
aggregate.py Rolls many model evaluations up into few-shot learning curves and target-species analysis tables

The benchmark has 51 few-shot training conditions × 3 seeds. To answer the research questions the benchmark was designed for (how does data quantity affect detection, photography robustness, species generalization, and per-band target performance?) you'll usually run evaluate.py once per trained model and then aggregate.py once across all the resulting summary files.

Install

pip install -r requirements.txt

Quick start — single model

python evaluate.py \
    --benchmark-dir   ./bark-ambrosia-beetle-benchmark \
    --predictions-dir ./my_predictions \
    --output-dir      ./eval_results \
    --model-name      my_model_v1

--predictions-dir should contain one COCO-results JSON per split:

<predictions-dir>/
    iid_test_predictions.json
    inat_test_predictions.json
    semantic_ood_predictions.json

Each file is a JSON list of detections:

[
    {
        "image_id":    42,
        "category_id": 7,
        "bbox":        [120.5, 80.0, 220.0, 180.0],
        "score":       0.87
    },
    ...
]
  • image_id: integer matching the id field in the benchmark's COCO file for that split (NOT the source_image_uuid string).
  • category_id: integer matching the benchmark's global category ID (1..175). On OOD splits, predictions will use trainable category IDs because the model wasn't trained on OOD species — that is correct.
  • bbox: [x, y, width, height] in absolute pixel coordinates, COCO order.
  • score: confidence in [0, 1].

Output

Four files per evaluation run, prefixed with --model-name:

File Purpose
<model>_summary.json All metrics, machine-readable, full hierarchy
<model>_summary.csv Long-format flat table for easy comparison across models
<model>_per_species.csv Per-species AP for diagnosing weak categories
<model>_report.txt Human-readable summary, same as printed to stdout

What gets measured

For each test split, the harness runs six metric families. Read the inline docstrings in evaluate.py for the full interpretation guide; the short version:

  1. Standard COCO mAP suite — primary on iid_test and inat_test. Near-zero on semantic_ood by construction (model can't predict the OOD category IDs).
  2. Per-species AP — diagnostic, one row per species in the CSV.
  3. Class-agnostic detection — primary on semantic_ood (did the model find any beetle at all, regardless of class?).
  4. Calibration (ECE) — does confidence match accuracy? On OOD, does the model become less confident on unfamiliar species?
  5. Hierarchical taxonomic agreement — when the species ID is wrong, is the prediction at least in the right genus/tribe/subfamily? Broken down by OOD distance band (near_genus, mid_tribe, far_tribe).
  6. OOD by taxonomic distance band (semantic_ood only) — answers "does the model struggle more on species that are taxonomically further from training?". For each band (near_genus, mid_tribe, far_tribe) reports class-agnostic AP/AR, taxonomic agreement, and mean confidence. A steep near_genus → far_tribe decline means the model relies on having seen close relatives. A flat profile means it has learned generic beetle features. The single-number takeaway is summary.ood_band_gap_AP_50 — see below.

Headline metrics

When reporting model performance, the three numbers that should always appear are:

Metric What it measures
iid_test.coco.AP_50_95 In-distribution detection quality (the ceiling)
inat_test.coco.AP_50_95 Photography-environment robustness
semantic_ood.class_agnostic.AR_100 Species-level generalization

Plus four derived cross-split summary metrics in summary of the JSON output:

Metric Interpretation
photography_robustness_gap_AP_50_shared_species Controlled photography gap (averaged over species in BOTH iid_test and inat_test). Smaller = more photography-robust. Preferred over the global gap since it controls for species mix.
species_generalization_gap_AR_100 Smaller = better species generalization
confidence_drop_OOD Positive = model knows what it doesn't know
ood_band_gap_AP_50 Positive = model degrades sharply with taxonomic distance from training (i.e. it works on near_genus but fails on far_tribe). Zero/negative = flat performance across bands = good generalization. Companion signals ood_band_gap_AR_100, ood_band_gap_correct_genus, ood_band_gap_correct_tribe, ood_band_gap_confidence.

Quick start — few-shot aggregation

After evaluating multiple models (typically one per training condition), aggregate them into learning curves:

python aggregate.py \
    --eval-dir       ./eval_results \
    --manifest       ./fewshot_manifest.csv \
    --benchmark-dir  ./bark-ambrosia-beetle-benchmark \
    --output-dir     ./aggregated_results

The manifest CSV maps each evaluated model to its training condition:

model_name,regime,k_or_p,seed
yolov8_gu_k1_s0,global_uniform,1,0
yolov8_gu_k1_s1,global_uniform,1,1
yolov8_gu_k1_s2,global_uniform,1,2
yolov8_gu_k5_s0,global_uniform,5,0
...
yolov8_in_p001_s0,incremental_natural,0.01,0
...
yolov8_iut_k0_s0,incremental_uniform_targets,0,0
...

For k_or_p: use the numerical value (e.g. 1, 5, 0.01, 0.05) except for global_uniform's "all" condition — write all as a string.

Output

File Purpose
learning_curves.csv Mean ± std headline metrics per (regime, k_or_p) — plot mAP vs k from this
target_species_curves.csv For incremental_uniform_targets only: per (k, band) target AP — the band × k grid
target_vs_nontarget.csv Target vs non-target species AP gap at each k
budget_curves.csv Effective unique-image count per condition — x-axis for cross-regime comparisons
aggregated.json Full machine-readable aggregation
report.md Human-readable summary with markdown tables

What questions the aggregation answers

Each of the three training regimes answers a different question. The aggregator produces a learning curve table for each:

global_uniform: How does detection quality scale with annotation budget when every species contributes equally? The curve goes from extreme few-shot (1 image/species) to full data, with each species weighted the same regardless of natural prevalence.

incremental_natural: How does detection quality scale when natural class imbalance is preserved? Each species contributes p% of its own images. This is the curve you get from realistically subsampling your training set uniformly.

incremental_uniform_targets: What is the marginal value of training data for specific species, broken down by taxonomic distance to the rest of the training set? 12 target species (4 each in near_genus, mid_tribe, far_tribe) are starved of data while all other species stay at full data. The per-band AP at each k reveals whether your model relies on close-relative cues (curve collapses on far_tribe faster than near_genus) or genuinely generic beetle features (similar curves across bands).

What this benchmark evaluates — the four research dimensions

The harness was designed around four orthogonal capabilities that a useful detection model must demonstrate. Each is measured by named metrics that appear in <model>_summary.json and the aggregated learning_curves.csv:

1. Data efficiency / few-shot learning

How does detection quality scale with training data quantity?

Measured by training many models on the three few-shot regimes (global_uniform, incremental_natural, incremental_uniform_targets) at multiple k/p values × 3 seeds, evaluating each with evaluate.py, and running aggregate.py to produce learning curves. The k=1 and p=0.01 points characterize the few-shot regime; the k=all / p=1.00 points characterize the data-rich ceiling.

Key output: learning_curves.csv rows for each (regime, k_or_p), every headline metric with mean ± std across seeds.

2. Out-of-distribution generalization

Both species-OOD and environment-OOD are evaluated:

  • Environment-OOD (inat_test): same species as training, but field iNaturalist photography instead of institutional photography. Measured by COCO mAP suite on inat_test plus the controlled photography_robustness_gap_AP_50_shared_species (averaged over species present in BOTH splits, so the gap isn't confounded by species mix).
  • Species-OOD (semantic_ood): species absent from training. Standard mAP is near-zero by construction; the meaningful signals are:
    • class_agnostic.AR_100 — could the model find the beetle at all?
    • hierarchical.correct_genus / correct_tribe — when class was wrong, was it at least taxonomically close?
    • Per-band breakdown (near_genus / mid_tribe / far_tribe) — does the model degrade gracefully as the OOD species moves farther from the training set, or does it cliff-fall?
    • confidence_drop_OOD — did the model become less confident on unfamiliar species? (Positive = good calibration.)

3. Class imbalance tolerance

The benchmark's training distribution is naturally long-tailed (some species have thousands of images, some barely meet the 10-specimen threshold). A useful model performs comparably on rare and abundant species.

Measured by the class_imbalance section per split:

  • Species binned into head (top 25%), medium (middle 50%), and tail (bottom 25%) by training image count.
  • head_AP_50, medium_AP_50, tail_AP_50 — mean AP per tier.
  • head_minus_tail_AP_50 — the gap. Large positive value = rich-class biased model. Near zero = imbalance-robust.
  • AP_50_train_count_correlation — Pearson r between species' test AP and training count. r > 0.6 = AP strongly tracks data quantity (poor imbalance tolerance). r ≈ 0 = imbalance-robust.

In the few-shot aggregation: watching iid_head_minus_tail_AP_50_mean close as k grows tells you that more data fixes the imbalance bias. Watching it stay constant tells you that the imbalance bias is a property of the model architecture and won't be fixed by more data alone.

4. Detection vs. classification ability (separately AND together)

Standard detection mAP combines two failure modes. The decomposition section per split breaks them apart:

  • detection_only_AP_50 — can the model find a beetle at all? (Class- agnostic — ignores the predicted species.)
  • joint_AP_50 — can the model find AND correctly identify it? (Standard COCO mAP.)
  • classification_given_detection_acc — of all predictions that ARE true-positive detections (IoU ≥ 0.5 with a GT box), what fraction got the species right?
  • classification_loss_ratio = 1 − joint_AP_50 / detection_only_AP_50 — what fraction of the model's detection capability is squandered on misclassification.

This decomposition is the diagnostic answer to "where did this model fail?". Two models with the same joint mAP can have completely different remediation paths:

Model detection_only joint loss_ratio Diagnosis
A 0.95 0.40 0.58 Finds beetles fine; classifier is the bottleneck
B 0.45 0.40 0.11 Classifier is fine; detector is the bottleneck

In the few-shot aggregation: watching iid_classification_loss_ratio drop as k grows tells you the classifier saturates with more data. Watching iid_detection_only_AP_50 plateau while loss_ratio keeps dropping tells you the detector is mature but class discrimination still benefits from more samples per class.

Converting from common detection frameworks

Ultralytics YOLO (v8/v11)

from ultralytics import YOLO
import json

model = YOLO("my_model.pt")
preds = []
for img_id, img_path in image_id_to_path.items():
    result = model(img_path, verbose=False)[0]
    for box in result.boxes:
        x1, y1, x2, y2 = box.xyxy[0].tolist()
        preds.append({
            "image_id":    int(img_id),
            "category_id": int(box.cls.item()) + 1,   # YOLO uses 0-indexed
            "bbox":        [x1, y1, x2 - x1, y2 - y1],  # convert to xywh
            "score":       float(box.conf.item()),
        })
json.dump(preds, open("iid_test_predictions.json", "w"))

Detectron2

from detectron2.engine import DefaultPredictor
import json, cv2

predictor = DefaultPredictor(cfg)
preds = []
for img_id, img_path in image_id_to_path.items():
    img = cv2.imread(img_path)
    out = predictor(img)["instances"].to("cpu")
    for i in range(len(out)):
        x1, y1, x2, y2 = out.pred_boxes.tensor[i].tolist()
        preds.append({
            "image_id":    int(img_id),
            "category_id": int(out.pred_classes[i].item()) + 1,
            "bbox":        [x1, y1, x2 - x1, y2 - y1],
            "score":       float(out.scores[i].item()),
        })
json.dump(preds, open("iid_test_predictions.json", "w"))

Hugging Face Transformers (DETR / YOLOS / etc.)

from transformers import AutoImageProcessor, AutoModelForObjectDetection
import torch, json
from PIL import Image

processor = AutoImageProcessor.from_pretrained("my_model")
model = AutoModelForObjectDetection.from_pretrained("my_model")

preds = []
for img_id, img_path in image_id_to_path.items():
    img = Image.open(img_path)
    inputs = processor(images=img, return_tensors="pt")
    with torch.no_grad():
        outputs = model(**inputs)
    results = processor.post_process_object_detection(
        outputs, threshold=0.05,
        target_sizes=torch.tensor([img.size[::-1]])
    )[0]
    for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
        x1, y1, x2, y2 = box.tolist()
        preds.append({
            "image_id":    int(img_id),
            "category_id": int(label.item()) + 1,
            "bbox":        [x1, y1, x2 - x1, y2 - y1],
            "score":       float(score.item()),
        })
json.dump(preds, open("iid_test_predictions.json", "w"))

You will need to build an image_id_to_path mapping by joining the benchmark's COCO images[*] array (which has id and file_name) with the actual image files in detection/images/<split>/. A small helper:

import json
from pathlib import Path

def build_image_lookup(benchmark_dir, split):
    coco = json.load(open(Path(benchmark_dir) / f"detection/annotations_coco/{split}.json"))
    img_dir = Path(benchmark_dir) / "detection/images" / split
    return {img["id"]: img_dir / img["file_name"] for img in coco["images"]}

Category ID mapping

The model needs to predict the global category IDs assigned by the benchmark (1..N), not its own internal IDs. The easiest way to ensure this: when training, build your dataset directly from the benchmark's train.json so the model learns the same ID conventions.

If your model uses its own internal class IDs that differ from the benchmark's, build a mapping at prediction time:

import json
coco = json.load(open("bark-ambrosia-beetle-benchmark/detection/annotations_coco/train.json"))
name_to_global_id = {c["name"]: c["id"] for c in coco["categories"]}
my_internal_to_global = {
    internal_id: name_to_global_id[my_class_names[internal_id]]
    for internal_id in range(len(my_class_names))
}

Programmatic use

Both scripts can be imported as libraries:

from evaluate import run_evaluation
from pathlib import Path

results = run_evaluation(
    benchmark_dir=Path("./bark-ambrosia-beetle-benchmark"),
    predictions_dir=Path("./my_predictions"),
    splits=["iid_test", "inat_test", "semantic_ood"],
    iou=0.5,
    quiet=True,
)
print(results["summary"]["photography_robustness_gap_AP_50_shared_species"])

Reproducibility

Both scripts are deterministic given fixed inputs. Two runs on the same predictions / manifest will produce byte-identical CSV and JSON outputs.

Downloads last month
453