Run this model with HF Jobs

Run thomashallock/abacus-frame-finder on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/thomashallock/abacus-frame-finder. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/thomashallock/abacus-frame-finder on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

abacus-frame-finder (joint-s3b)

A pair of small convolutional networks, 1.49 M + 0.91 M parameters, 9.5 MB as TF.js, that find an abacus in a phone-camera frame and return the four corners of its frame, in order, with the heaven (one-bead) side on top, plus a "there is an abacus here" probability. Version 2 finds two kinds of abacus: a 3D-printed Abacus Studio abacus (3 to 21 columns), as version 1 did, and an ordinary 1/4 soroban (9 to 27 rods). It is the first stage of the camera reader on abaci.one, followed by abacus-column-counter and abacus-column-reader. It is live on abaci.one since 2026-12-04.

It was trained only on rendered drawings. Not one photograph was used to train it. The drawings are Blender renders of the Studio's own printable parts (3 to 21 columns, random frame and bead colours, with and without the Studio's optional printed markers and text) and of procedurally built sorobans (9 to 27 rods, many bead shapes and frame styles), on invented desks with clutter, hands and lights.

What's new in version 2

  • A new find/refine pair. find is version 1's network (s2a) fine-tuned on the Studio drawings plus soroban drawings (s3a). The close-up network refine was trained further on the same mix (s3b).
  • Sorobans. Version 1 was never scored on sorobans and turned a black shop soroban away. This version is trained and scored on drawn sorobans.
  • A new "abacus here" threshold, 0.9 (version 1: 0.568). See below.
  • Version 1's weights and its held-back test scores stay at the tag v1-20261203. Those scores belong to those weights, not to this version.

What it predicts

Two stages, both in this repo:

Stage Input Output
find the 720 × 1280 frame shrunk to 180 × 320 and centred on a 192 × 320 canvas, RGB 0–255 (the net rescales to [−1, 1] itself) (N, 15361) = four 80 × 48 corner heat-maps (top-left, top-right, bottom-right, bottom-left, as the abacus is held with heaven up) + one "here" logit
refine a 64 × 64 close-up of each corner, cut through the current homography (±0.30 of the abacus depth) a 32 × 32 heat-map; the caller takes its soft argmax

The find corners are the argmax cell plus a 5 × 5 soft average. refine is run twice. An abacus is "here" when sigmoid(here) ≥ 0.9 (finder.json carries the threshold; read it, don't hard-code it).

The threshold. Version 1's rule was the largest threshold that refuses at most 0.5 % of working abacus pictures on the drawn choice set; for this pair that is 0.641. The owner chose 0.9 instead, on the drawn choice sets: it says "no abacus" on 413 of 419 empty-desk drawings (398 at 0.641), and the price is that it turns away 8 of 659 working abacus drawings (1.2 %, above the old 0.5 % rule), 6 of them with a corner hidden. keras/find-s3b.threshold.json records this.

Corner order comes from the net: one map per named corner, so the caller needs no notion of "up". On a soroban, "top" is the heaven side (the one-bead side).

Files

File SHA-256 Size
finder.json — manifest: threshold, weight format, input shapes a8c74672…1dc8b746 318 B
find-model.json + find.bin — TF.js graph model 7f694bbc…82c0cbce / 0bb0ee0f…d6b4fcbc 5.8 MB
refine-model.json + refine.bin — TF.js graph model, cut before its soft-argmax 90ce095e…4c2dec6d / f07e00b9…1cead8c2 3.6 MB
keras/find-s3a.keras, keras/refine-s3b.keras — the trained Keras 3 models the bundles were exported from 11b30f4b…cc364561 / ad8d460f…3be3bed0 18.6 / 11.1 MB
keras/find-s3b.threshold.json — how the threshold was chosen 74bf9973…ecf6d046 249 B

The TF.js files are byte-identical to what abaci.one serves as frame-finder/joint-s3b-f32-20261203. "s3b" names the pair: its find is s3a's, unchanged (s3b re-trained only the close-ups), which is why the Keras file is called find-s3a.keras. Weights are float32, as in version 1.

Usage

import * as tf from '@tensorflow/tfjs';

const manifest = await (await fetch('finder.json')).json();
const find = await tf.loadGraphModel('find-model.json');
const refine = await tf.loadGraphModel('refine-model.json');

// frame: an HTMLVideoElement / ImageData, portrait 720x1280, shrunk to 180x320 and
// letter-boxed onto a 192x320 canvas, RGB 0-255, shape [1, 320, 192, 3].
const out = find.predict(frameTensor);          // [1, 15361]
// out[..., :15360] -> 4 maps of 80x48 (softmax each, argmax + 5x5 soft average = corner)
// out[..., 15360]  -> sigmoid >= manifest.threshold (0.9) means "an abacus is here"
// then cut 64x64 close-ups at each corner through the homography and run `refine` twice.

The full decode (soft argmax, the homography, the close-up cuts, the two refine passes, the hold logic the phone uses between frames) is in the open-source app: apps/web/src/lib/vision/ (frameFinder.ts, frameFinderManifest.ts, cvPort.ts). The Python reference is finder/score.py in the training kit (see Reproducibility).

Load the Keras models with keras.saving.load_model(path, compile=False); they were trained on the PyTorch backend of Keras 3 and load on any backend. refine-s3b.keras ends in a small custom layer (SoftPlace, the soft argmax) defined in the kit's finder/nets.py; import that module before loading it.

Architecture

Unchanged from version 1:

  • find (1,487,029 params): MobileNetV2 α = 0.5, include_top=False, started from the Keras ImageNet weights and fully fine-tuned (706,224 params in the backbone), with a U-net decoder tapping block_3/6/13_expand_relu and out_relu, and a global-average-pool → Dense 64 → "here" head.
  • refine (910,361 params): an 8-conv encoder (stride 16) with three up-samplings and skips, a softmax heat-map, trained from scratch.

Training

  • Starting point: version 1's pair (s2a), itself trained on 14,992 rendered Studio pictures, 3,000 without an abacus and 60 pilot pictures.
  • Data for version 2: the Studio sets above plus 7,975 drawn sorobans and their 60-picture pilot: 22,274 pictures with an abacus and 3,753 without, as the trainer counted them. Soroban drawings: 9 to 27 rods (13 and 17 most often), open and backed frames, bicone, round, barrel and box beads, real-soroban proportions, no markers.
  • find (s3a): 12 × 1,000 steps from s2a at learning rate 3 × 10⁻⁴, batch 16, Keras 3 on the PyTorch backend, laptop GPU (MPS), 48 min.
  • refine (s3b): 8 × 1,000 steps from s2a's close-ups (s3a, 6 min on the laptop), then 24 × 1,000 more (s3b, 15 min), batches of 32 close-ups, PyTorch backend.
  • Batches are seeded; weight initialisation is not. Expect a different model from a re-run.

Evaluation

Development scores: these drawings were used to choose this model; no held-back score yet for this version. The drawn choice sets (Studio seed 59002, soroban seed 70002) chose between s3a, s3b and s3c and chose the threshold, so they flatter it. The held-back drawn test sets have not been read for this version.

"Found well" = all four corners in the right order and the worst corner within 3 % of the abacus's width.

Measure (threshold 0.9) development (choice sets)
Studio abacus, full view, found well 204 / 210 (97.1 %)
Soroban, full view, found well 224 / 239 (93.7 %)
No-abacus pictures refused 413 / 419 (98.6 %)
Working abacus pictures turned away as "no abacus" 8 / 659 (1.2 %)

For comparison on the same sets: version 1 (s2a) found 203 / 210 Studio and 51 / 239 sorobans in full view. The soroban target the work aimed at (97 % in full view) is not met. The soroban misses gather under hands and objects lying across the frame's edge near a corner, and at steep tilt.

Real-picture check, before publishing. A check on real photos of a printed abacus with its markers painted out: phone frames of printed four-column Studio abaci whose printed markers give the true corners; the markers are painted out before the finder looks. Two sets: 1,023 frames from practice sittings, and 210 frames (5 moments) from the owner's own trial. Whole chain as served (this finder, the counter and the reader):

practice frames owner's trial frames
frame found 100 % 100 %
heaven side right 99.8 % 96.7 %
worst corner within 3 % not scored fairly (an older print; its true corners were inferred) 89.0 %

On the trial frames version 1's chain scored 95.2 % (heaven side) and 84.8 % (corners). This check has no real sorobans in it, and it is a pre-publish gate, not a benchmark: it was not used to train or tune the model.

Limitations

  • Studio-design abaci and ordinary 1/4 sorobans only. Other abaci (2/5 sorobans, suanpan, bead frames) are not drawn and not scored.
  • Sorobans are scored on drawings only. There is no real-photo score for sorobans.
  • A hidden corner is found well far less often than a clear one. Full view on a table is the use case.
  • Pictures of the abacus steep, tiny, or partly out of frame are not targets and score badly.
  • The 0.9 threshold turns away about 1 in 80 working drawings, more often when a corner is hidden.
  • Trained on rendered scenes: real glare, motion blur and camera noise are only imitated.
  • Speed: the architecture is version 1's, which ran at a median 86 ms a frame on the owner's phone (TF.js); not re-measured for these weights.

Training data, attribution and licence

  • Drawings: rendered with Blender 4.4 from the Studio's own OpenSCAD parts (public/scad/abacus.scad, the owner's design) and from a procedural soroban generator written for this work. Procedural textures, no image or mesh assets from elsewhere, macOS system fonts for frame text.
  • Base weights: find's backbone starts from Keras Applications' MobileNetV2 (α 0.5, 224, no top) ImageNet weights (mobilenet_v2_weights_tf_dim_ordering_tf_kernels_0.5_224_no_top.h5, SHA-256 279052de…), which Keras translated from Google's TF-slim checkpoints of MobileNetV2 (Sandler et al., 2018). The Keras documentation that shipped those weights states "These weights are released under the Apache License" (Keras 2.2.4 applications docs); the current keras.io page states no licence for them. ImageNet's own terms govern the images, which we never downloaded; whether they reach pretrained weights is an open question, and we note it rather than settle it. Every backbone weight was then fine-tuned on drawings, twice (version 1, then version 2).
  • This model: Apache License 2.0 (LICENSE), compatible with the base.
@inproceedings{sandler2018mobilenetv2,
  title={MobileNetV2: Inverted Residuals and Linear Bottlenecks},
  author={Sandler, Mark and Howard, Andrew and Zhu, Menglong and Zhmoginov, Andrey and Chen, Liang-Chieh},
  booktitle={CVPR}, year={2018}
}

Privacy

The camera reader is used by children practising at home, and the only real pictures we hold are of their desks and hands. None of the three camera models (this finder, the counter, the reader) was trained on real pictures, and none of those pictures is published, here or anywhere. This finder's threshold and the choice among its training runs were made on drawings. The column reader's recipe was selected, earlier in its lineage, with real January practice columns (its card says how). Real frames were used as a pre-publish check (the table above): frames of printed abaci with their markers painted out; only counts and rates leave the owner's machine, and nothing was tuned on them. No figure or sample in this repo is a photograph; everything shown is a drawing.

Reproducibility

Generators (studio2/scripts/gen.py, seeds 59001 train / 59002 choice / 59003 test; soroban1/scripts/gen.py, seeds 70001 train / 70002 choice / 70003 test; Blender 4.4), trainer (finder/train.py, warm-started from s2a, with the soroban sets added), scorer (finder/score.py), TF.js export (export_graph_models.py finder, in the app repo's scripts/train-column-classifier/drawn/). The rest of the kit is on the owner's machine and is being prepared for release with a DOI; this card will link it. The drawings re-render identically from their seeds; the training does not repeat exactly (unseeded initialisation, GPU).

Citation

@misc{hallock2026abacusfinder,
  title={abacus-frame-finder: finding a 3D-printed abacus or a soroban in a phone frame with a network trained only on drawings},
  author={Hallock, Thomas},
  year={2026},
  url={https://huggingface.co/thomashallock/abacus-frame-finder}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including thomashallock/abacus-frame-finder

Paper for thomashallock/abacus-frame-finder

Evaluation results

  • Studio abacus, full view, found well (development) on Drawn choice sets, Studio abacus and soroban (development scores - these drawings were used to choose this model; no held-back score yet for this version)
    self-reported
    97.100
  • Soroban, full view, found well (development) on Drawn choice sets, Studio abacus and soroban (development scores - these drawings were used to choose this model; no held-back score yet for this version)
    self-reported
    93.700
  • No-abacus pictures refused (development) on Drawn choice sets, Studio abacus and soroban (development scores - these drawings were used to choose this model; no held-back score yet for this version)
    self-reported
    98.600