# R22 · Two-taxon detector fine-tuning pilot

## Training · 2026-12-01

This short development pilot starts from the public diatom YOLOv8 box detector described in R3. Prepare data from the 16 R21 training-selection images: 12 for training and four for validation, with filename-family-based separation where available. Convert **all** COCO annotations for the selected images to a single target-box class; the 16 images contain 20 source annotations. The [data plan](/results/r22/data-plan.json) records filenames, annotation counts and hashes. The original public dataset labels only two taxa; other objects visible in an image may be unlabeled. Training can therefore teach the detector to treat valid but unannotated diatoms as background. Filename-family separation and the prior exact-hash checks do not establish independent biological samples or rule out visually duplicated images. Source reuse terms are noted in R16; the detector's own model card specifies noncommercial terms.

Use the existing checkpoint's loaded weights, freeze the first 10 model layers, and train for three CPU epochs at input size 512, batch 4, AdamW learning rate 1e-4, with mosaic and mixup disabled. Other augmentations and scheduler settings retain Ultralytics defaults. The framework chose its best checkpoint using the four-image validation set. The [training run](/results/r22/training-run.json) records configuration, source and output hashes and temporary path. The first convolution's weights remain identical to the original checkpoint, while 93 of 298 shared floating-point state tensors differ after training; this confirms changes occurred but says nothing about their benefit. The adapted checkpoint lives in `/tmp/diatom-r22/pilot/weights/best.pt` and is not a durable or production model.

## Development comparisons

Compare original and adapted detectors at confidence 0.05 and inference size 768 on the six public single-target images and three neighbor pairs previously examined in R16/R18. For each image, match distinct predicted boxes to the selected public reference bounding boxes at IoU ≥ 0.5, maximizing the number of matches. Reference-based assignment is for evaluation only; other detections are not automatically false positives because annotations are not exhaustive. [Inspect the public comparison](/results/r22/) and [download predictions](/results/r22/detector-comparison.json).

On these nine selected images and 12 reference targets, the original detector matched 8 and the adapted detector 7; the six singles changed from 6 to 5, while the three pairs remained at 1/2, 0/2 and 1/2. The original produced 19 boxes and the adapted model 15. These counts do not estimate recall or precision and do not demonstrate that adaptation is worse or better in general: the images were inspected previously, source sample independence is unknown, the evaluation set is tiny and potentially related, and the original detector's training-data overlap is not verified. None of the reference pairs are truly overlapping polygons.

On the four Academy practice fields, the original detector produced nine boxes with eight one-to-one provisional point assignments; the adapted model produced ten boxes with eight assignments. The matched points need not be the same, marks are incomplete and nonexpert, and large or incorrect boxes can contain marks. [View the Academy comparison](/results/r22/academy.html). These are not accuracy metrics, and the adapted checkpoint should not be promoted on this evidence.

**Next.** Obtain independently grouped, expert-reviewed Academy training and validation examples, including all count-eligible instances, overlaps, partials and explicit unsure labels. Compare frozen and adapted models at equal false-positive or reviewer-time budgets on a locked sample-held-out test set; track unlabelled target handling, confidence calibration, complete-pair recovery and end-to-end ID. Separate single-plane and multi-plane training only after compatible local labels exist. Reproduce with `python3 research/r22_prepare_detector.py` then `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom /tmp/diatom-research-venv/bin/python research/r22_train_detector.py` and `research/r22_evaluate_detector.py`, using the temporary inputs and checkpoints documented in R16/R21.
