# R3 YOLO detector and instance segmentation

Status: initial inference on four development fields. No fine-tuning has been run. The user reports that an earlier YOLO trial used out-of-the-box weights and gave modest but promising results. The model version and exact checkpoint are still unknown.

[Ultralytics documentation](https://docs.ultralytics.com/models/yolo26/) lists YOLO26 detection and instance segmentation checkpoints. Generic checkpoints require diatom examples to learn this object category. Reproduce the earlier out-of-the-box trial when its version is known, then compare it with specialist-guided fine-tuning.

A [published model card](https://huggingface.co/kemalbsoylu/diatom-models) describes a YOLOv8-nano single-class diatom box detector and a separate genus classifier. This provides a potentially cheap transfer experiment for locating candidates. Its model-card performance numbers are from its own evaluation, so the local slides need a separate comparison. The repository labels its weights CC BY-NC-SA 4.0 and reports security-scanner flags on serialized files. Review provenance, licensing and a safe loading procedure before running them. A box detector would still need a strategy for crossings and fragments.

Next compare the user's checkpoint, the published detector if suitable, and a generic YOLO26 fine-tune on the same native-resolution development fields. Track point coverage and double detections as provisional observations. Use expert labels from independent slides before estimating precision or recall. Compare raw plane input with specimen-level focus suggested by L2.

## First local inference

An isolated CPU environment was installed under `/tmp/diatom-research-venv` with Ultralytics 8.4.224 and PyTorch 2.15.0+cpu. The downloaded diatom YOLOv8 detector has SHA-256 `66b9b2a3f57e92e7062638a27c1212612c60776df8686b49e018ea3ac96a82df`. Its pickle globals were inspected and it was loaded with PyTorch's restricted weights-only loader and an explicit class allowlist. It remains in `/tmp/diatom-detector.pt`, which is temporary. The model card specifies noncommercial terms.

Run `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config /tmp/diatom-research-venv/bin/python research/r3_yolo.py --confidence 0.05` after obtaining the checkpoint. Each field used one raw TIFF plane at 768 pixels. The [0.05 confidence plate](../results/r3/yolo-comparison-0.05.jpg) shows predictions and provisional points. The [0.25 plate](../results/r3/yolo-comparison.jpg) shows the initial threshold. On these four selected fields, 0.25 produced four boxes total; 0.05 produced nine. At 0.05, one large box contains six points in GC104889a, illustrating why point coverage alone can exaggerate performance on crossings. Neither threshold was selected on independent validation.

These fields were previously inspected. The user marks are incomplete and nonexpert, so no precision or recall can be computed. The checkpoint's training data and effective specimen scale may differ from these scans. The experiment uses the initial field focal plane and no fine-tuning. Compare overlapping tiles at multiple input scales, focus planes, and the earlier project checkpoint before deciding whether this model is suitable.
# Tiled inference scale diagnostic · 2026-11-30

On the same initial focal planes and four development fields used for the 0.05-confidence full-field baseline, run the same public diatom-trained YOLO detector on nine overlapping 384 × 384 native-pixel tiles per 768 × 768 field. Each tile is resized by the model pipeline to 640 × 640. Translate boxes to field coordinates and apply confidence-ordered, cross-tile IoU non-maximum suppression at 0.5. Tiling changes the field of view, effective object scale and available context at once. It is not a controlled test of scale alone. The original full-field run used `imgsz=768`; both runs use confidence 0.05 and the same checkpoint. [View field comparisons](/results/r3/tiled-yolo.html); [download tile origins, raw boxes and retained boxes](/results/r3/tiled-yolo.json).

The full-field baseline produced 9 boxes and 8 maximum one-to-one assignments to provisional point marks; tiled inference produced 12 retained boxes and 10 assignments. Across fields, full-field versus tiled assignment counts are 1/1, 1/1, 1/4 and 5/4. Equal counts can hide different candidates: in GC104890a the full-field and tile result each cover one of the two marked locations, but they cover different locations. Crowded GC104889a contains several overlapping and oversized tile boxes; boxes may represent repeated detections or several valves. Some tile detections also correspond visually to debris-like material. These assignments do not measure precision or recall: points are nonexpert, incomplete and not a one-to-one biological reference; maximum matching can assign a large box to any one of several contained marks.

This demonstration does not justify adopting tiles. Cross-tile NMS can suppress neighboring valves with overlapping boxes, while fragments along tile edges can survive as duplicates. Compare tiled-only, full-field-only, and a combined proposal set under equal review or false-positive budgets using expert-adjudicated crossing and edge cases. Record tile-boundary truncation, duplicate rate and end-to-end wall time under the same warm-up and hardware conditions. The current timings are exploratory and not a controlled latency benchmark.

Reproduce with `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom /tmp/diatom-research-venv/bin/python research/r3_tiled_yolo.py`; requires the R3 checkpoint at `/tmp/diatom-detector.pt`, existing full-field predictions, and original scans.

## Survey of twelve additional scan files · 2026-12-01

To broaden the qualitative preview beyond the six scans in the existing field review, fix seed 20261201 and select 12 distinct files from the 22 remaining scan-inventory entries at least 1 GB. For each, choose one uniformly random 768 × 768 window within the full image dimensions and the middle indexed Z plane **before inference**. These are random scan windows, not a systematic biological transect; distinct file names do not establish independent biological samples. The script probes the scan's final pyramid tile before reading a window. The selected files and coordinates are [recorded](/results/r3/scan-survey/survey.json) and are now development data, not untouched final-test samples.

Run the same frozen YOLO detector at confidence 0.05 on each full field and on nine overlapping, enlarged 384-pixel tiles with global IoU suppression, as in the earlier tile diagnostic. [View all 12 comparisons](/results/r3/scan-survey/), including fields with no output, and open original lossless window images. The full-field model produced 10 boxes in total; the tiled model produced 11 retained boxes. These are proposal counts only; the selected images have no comprehensive annotations and no reviewer has checked whether any box or apparent miss is a diatom. Some visual cases show different proposed structures, partial objects at boundaries, apparently merged structures, and clutter. Low-confidence boxes and the fixed middle plane complicate review.

Do not estimate recall, precision or superiority from these counts. A middle indexed plane is not necessarily in focus; uniform XY selection can include image margins and unrepresentative areas; tiling changes context and may split or suppress instances. Sample identity across files is unverified. Have an expert independently annotate additional held-out systematic fields without seeing predictions, obtain sample grouping, and compare full and tiled proposals at matched false-positive budgets, including overlooked regions, partial valves and overlap groups. Reserve the remaining not-yet-previewed files and any truly independent samples for a blind evaluation once biological grouping is known.

Reproduce with `YOLO_CONFIG_DIR=/tmp/diatom-yolo-config MPLCONFIGDIR=/tmp/mpl-diatom /tmp/diatom-research-venv/bin/python research/r3_scan_survey.py`. It requires the original scans and the R3 checkpoint at `/tmp/diatom-detector.pt`.

