# R21 · Decoder-only adaptation pilot

## Training setup · 2026-12-01

This is an exploratory first training run, not a validated model or a detector. Select 16 public source images from [Khanom's polygon dataset](https://doi.org/10.5281/zenodo.21295927), eight per represented genus, using fixed seed 20261202. Exclude exact filenames and conservative filename families appearing in the corresponding largest named test variant; avoid anonymous `imageNNN` and copy-suffixed filenames. The [selection](/results/r21/training-selection.json) and [training run](/results/r21/training-run.json) record inputs and image hashes. Exact hashes do not overlap with the nine public evaluation images. Filename heuristics do not establish biological-sample independence, and some source images can be near duplicates under different names. Public reuse terms are discussed in R16.

Freeze the MobileSAM image and prompt encoders; train only its mask decoder for two epochs on a single polygon and reference-derived tight box per training image. Original 1600 × 1200 images are resized to 768 × 576; use cached encoder embeddings, area-resized 192 × 192 targets, BCE plus soft Dice, AdamW at 1e-5 and fixed seed. Mean training loss decreased from 0.0632 to 0.0583; a training loss decrease alone does not demonstrate generalization. The adapted checkpoint is temporary at `/tmp/diatom-adapted-decoder-r21.pt`; its SHA-256 is recorded in the run JSON. No automatic detector or classifier was trained.

## Public development comparison

Compare the original and adapted decoder on the six previously inspected R16 targets, using the same reference-derived boxes, and on the three previously inspected L18 neighboring pairs, using the same reference-derived positive and negative points. [View all nine cases](/results/r21/) and [download scores](/results/r21/decoder-comparison.json). As a consistency check, original-model IoUs reproduce the earlier R16 and L18 values.

The six single-target box-prompt IoUs average 0.903 for the original and 0.913 for the adapted decoder. Three targets improve, two decrease, and one is essentially unchanged. On six masks in the three neighbor-pair cases, the average changes from 0.870 to 0.848; four decrease and two increase. These means describe this small, previously examined set only: masks and images may not be independent, labels are public annotations, source conditions differ from the Academy's, and pair polygons do not overlap. Points/boxes are oracle prompts; no system detection, taxonomy or review burden is measured. We cannot infer general improvement or decline from these results.

## Academy development-point comparison

Run the adapted decoder at the same 14 nonexpert crossing marks and recorded focus planes used in R6; compare its masks visually with the original. [Inspect all 14](/results/r21/academy.html); [download masks and comparisons](/results/r21/academy-mask-comparison.json). Median overlap between original and adapted masks is 0.882, but neither mask is ground truth. The sum of other same-plane provisional marks inside the masks changes from 18 to 15; marks are not verified distinct instances and can be counted repeatedly across masks. Both decoders retain all 14 prompt points. Some masks remain merged or cover debris-like areas. These geometric diagnostics do not establish an accuracy gain, improved instance separation or biological identity.

**Decision and next work.** The short two-taxon adaptation produces mixed public results and unvalidated Academy changes; do not promote it over the original decoder. With independently grouped, expert-reviewed local examples, compare frozen, public-adapted and locally adapted models under matched annotation and prompt budgets, including actual overlapping and partial instances, false splits, counting and review time. Explicitly assess domain-specific negative-point behavior and preserve a final blind sample split. For this pilot, use `/tmp/diatom-research-venv/bin/python research/r21_select_adaptation.py`, the authorized range-fetch `research/r21_fetch_adaptation.py`, then `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom /tmp/diatom-research-venv/bin/python research/r21_train_decoder.py`. Evaluate with the same environment and `research/r21_evaluate_decoder.py` or `research/r21_academy_masks.py`.
