unroll / docs /BENCH_FORMAT.md
SharpMeow's picture
One page scroll bar and American English
757768f verified
|
Raw History Blame Contribute Delete
5.54 kB

Ink Bench bundle format, unroll-inkbench/1

Version 1.0. An open format for sharing an ink prediction's comparison with a reference layer on one segment, and the letter candidates found on it. Apache-2.0, so anyone can adopt, extend and implement it. JSON Schema: bench-bundle.schema.json.

A bundle is one UTF-8 JSON object. The page (lib/bench-core.js) and tools/inkbench.py both write it; inkbench validate checks one.

Versioning

schema is unroll-inkbench/<major> or unroll-inkbench/<major>.<minor>. Minor versions only add optional fields; readers of /1 must ignore fields they do not know. A change to any metric definition or to the alignment model is a new major version.

Fields

field type meaning
schema string unroll-inkbench/1
tool object name, version, impl (browser, python, python-cli, node). Not part of the result
created string UTC time, ISO 8601. Not part of the result
scroll string e.g. PHerc0139
segment string winding id, e.g. w046
reference object the layer scored against: layer (ink), label, file, sha256 of the file bytes, grid width and height, pxPerMM, and alignTargetFile / alignTargetSha256 for the layer used to align
prediction object name, sha256 of the input file bytes (for arrays: of the float64 C-order bytes), format (png, tiff, array), source width and height, normalization, invert, and model (name required; url, version, notes optional)
alignment object method (auto, manual, auto+manual, shared, reused), target (ink or ct), tx, ty in reference px, sx, sy, final ncc with the target, coarseNcc, evals
metrics object see below
annotations array letter candidates, see below
credits object data credits and licenses
disclaimer string that scores are agreement with another model's output, not ground truth, and boxes are candidates, not readings

Definitions

Decoding. Gray images are used as is; color uses (299 R + 587 G + 114 B) / 1000. Integer images are divided by their type maximum (255, 65535, 4294967295), except images whose largest value is 1 or less, which are label maps and kept as is (normalization: label). Float TIFF is min-max scaled over finite values; non-finite values become the minimum. invert replaces v with 1 - v.

Resampling. While the prediction is more than twice the reference grid in either direction it is 2x2 mean pooled (odd last row or column dropped). For reference pixel x (0-based) the source coordinate is u = (((x + 0.5 - W/2) - tx) / sx + W/2) * (w_pred / W) - 0.5, the same for y. Sampling is bilinear; pixels with u outside [0, w_pred - 1] are not covered and are left out of every metric.

Pearson r over covered pixels. pearsonMatchedBlur: the largest r after blurring the reference with a Gaussian of sigma in {0, 0.5, ..., 6} reference px (kernel radius ceil(3 sigma), edge clamped, separable); blurSigmaPx is that sigma and blurSigmaUM the same in µm.

Thresholded. Reference positive where ref >= thresholds.ref, prediction positive where pred >= thresholds.pred. IoU = |A and B| / |A or B|, Dice = 2 |A and B| / (|A| + |B|), precision = |A and B| / |B| (1 when B is empty), recall = |A and B| / |A|.

Curve. For t = j / 50, j from 50 down to 0, precision and recall of pred >= t against the thresholded reference (pr, high t first). ap = sum over that order of (recall_j - recall_previous) * precision_j, starting from recall 0. bestF1 is the largest F1 on the curve and its threshold.

Rounding. Metrics to 6 decimals, tx and ty to 3, sx and sy to 5, using round half up (JavaScript Math.round). The alignment is rounded before scoring, so a bundle's metrics follow from its own alignment fields.

Alignment (method auto). Pyramid of 2x2 means until the long side is 80 px or less. Coarse search: 25 scales exp(ln 0.6 + (ln 1.6 - ln 0.6) i / 24), every integer shift within a quarter of the coarse size, best normalized cross correlation with at least 30% coverage. Refinement on each level from coarse to full: coordinate pattern search over tx, ty, sx, sy, first + then - step, accepting a step only when NCC improves by more than 1e-9, halving the steps when none does; shift steps start at 1 level px and stop below 0.25 level px (0.02 px on the full grid); scale steps start at 0.02. Implementations must follow this to reproduce auto alignments; any implementation may instead reuse a bundle's alignment (reused).

Annotations

{ "id": "a1", "x": 212.5, "y": 140, "w": 16, "h": 21, "letter": "Ε", "confidence": 0.4,
  "note": "faint, crosses a fiber", "status": "candidate for expert review" }

Boxes are in reference px. letter is one capital Greek letter or ?. status is always exactly candidate for expert review: a bundle never asserts a reading.

Example

examples/bench/w046-ink9um.json compares the public ink_9um run on w046 with the published ink. Its neighbors are baselines on the same winding.

Data terms

A bundle carries hashes and numbers, not images, so it can be shared freely under the code license. The reference layers it points to are Vesuvius Challenge open data under CC BY-NC 4.0; keep the credits when you publish figures.