# R6 Prompted segmentation

Status: first MobileSAM development experiment ready for review. [Result page](../results/r6/) includes all seven box-prompt outputs and a two-click touching-object example. This tests a lightweight general-purpose model, not the µSAM and SAM 3 models proposed for R6. [MobileSAM implementation](https://github.com/ChaoningZhang/MobileSAM) · [Ultralytics prompt API](https://docs.ultralytics.com/models/mobile-sam/)

Seven objects were selected from the assistant's earlier provisional traces. A tight rectangular prompt was computed from each trace's extrema with a 5-pixel margin, and a single grayscale TIFF plane was repeated to three channels at 768 × 768. MobileSAM was run once per box on CPU with no diatom-specific training. All returned one mask. IoU against the same provisional traces ranged from 0.69 to 0.96. Those outlines defined the boxes and have not been expert-verified. The selected specimens, prompt construction, and subjective traces make this an illustrative conditional test, not independent segmentation accuracy. No automatic localization was tested.

The same model received separate point prompts at user-marked positions (249,307) and (230,363) on GC108240a field 6, plane 4. It produced two visibly separate masks for the neighboring candidates. The two masks have a mutual IoU of about 0.014. This measures mask overlap, not correctness. The two-point example was selected for visibility and the marks are provisional. It does not establish general performance on crossings or obscured specimens.

To avoid relying on that favorable pair, MobileSAM was subsequently run once per click for all 14 marks flagged as touching or crossing in the practice export, using the focus plane recorded with each click. The [full visual audit](../results/r6/marked-crossings.jpg) shows every output, including failures. Several clicks in the dense GC108240a group return masks covering multiple adjacent valves, while some sparse or isolated candidates receive distinct masks. One clicked region in GC104889a yields a broad debris-like mask. These results show why a single point is insufficient in crowded scenes. The labels and marks remain provisional; this is a complete audit of this small selected set, not a quantitative accuracy assessment.

Reproduce the 14-mask audit with `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom PYTHONDONTWRITEBYTECODE=1 /tmp/diatom-research-venv/bin/python research/r6_marked_crossings.py`. Each binary mask and its coordinates are saved in the results directory. The preview crops are centered on clicks and may exclude the rest of a long mask, so inspect the full-size binary masks when adjudicating.

The checkpoint SHA-256 is `6dbb90523a35330fedd7f1d3dfc66f995213d81b29a5ca8108dbcdd4e37d6c2f`, retrieved from the public Ultralytics assets release and loaded using a weights-only loader. The temporary environment uses Ultralytics 8.4.224 and CPU PyTorch 2.15.0. Model calls reported roughly 0.34–0.39 seconds on this host for the selected box examples; these numbers include one-time initialization in the first call and do not include review time or UI overhead. Reproduce with `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom PYTHONDONTWRITEBYTECODE=1 /tmp/diatom-research-venv/bin/python research/r6_mobile_sam.py` and the analogous `research/r6_crossing.py`. Both require `/tmp/mobile_sam.pt`.

Next compare single-click masks with YOLO-proposed boxes and actual analyst-drawn boxes on the same independently reviewed crossing and partial-valve fields. Time correction and count prompt actions. Include non-diatom clicks and overlapping masks, and avoid using reference contours to construct prompts in the evaluation. Run a microscopy-adapted model if this interaction is valuable.
