Image Classification
Keras
tfjs
tensorflowjs
synthetic-data
blender
abacus
soroban
browser
on-device
abaci-one
Eval Results (legacy)
Run this model with HF Jobs
Run thomashallock/abacus-column-reader 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-column-reader. 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-column-reader 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.
Instructions to use thomashallock/abacus-column-reader with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use thomashallock/abacus-column-reader with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://thomashallock/abacus-column-reader") - Notebooks
- Google Colab
- Kaggle
v2: column reader drawn-slots-sor2 (Studio + soroban): TF.js bundle, soroban-cut.json, Keras source, card
aee8f40 verified |
Download README.md from thomashallock/abacus-column-reader: direct link, hf CLI and curl.
- Browser
- Download file 15.5 kB
-
https://huggingface.co/thomashallock/abacus-column-reader/resolve/main/README.md
- Command line
-
hf download hf://thomashallock/abacus-column-reader/README.md
-
curl -L -o README.md https://huggingface.co/thomashallock/abacus-column-reader/resolve/main/README.md
15.5 kB
| license: apache-2.0 | |
| pipeline_tag: image-classification | |
| tags: | |
| - tfjs | |
| - tensorflowjs | |
| - keras | |
| - synthetic-data | |
| - blender | |
| - abacus | |
| - soroban | |
| - browser | |
| - on-device | |
| - abaci-one | |
| model-index: | |
| - name: abacus-column-reader (drawn-slots-sor2) | |
| results: | |
| - task: | |
| type: image-classification | |
| name: Digit (0-9) of one abacus column or soroban rod, with refusal | |
| dataset: | |
| name: Drawn Studio abaci and sorobans, no column covered, exact corners (development scores - these drawings were used to choose this model; no held-back score yet for this version) | |
| type: synthetic-abacus-renders-development | |
| metrics: | |
| - type: accuracy | |
| name: Soroban, per-rod digit accuracy (development) | |
| value: 95.0 | |
| - type: accuracy | |
| name: Soroban, whole numbers read right (development) | |
| value: 69.8 | |
| - type: accuracy | |
| name: Studio abacus, whole numbers read right (development) | |
| value: 92.4 | |
| # abacus-column-reader (drawn-slots-sor2) | |
| A **332 k-parameter, 1.3 MB TF.js** convolutional network that reads one column of an abacus from a | |
| 64 × 128 grey picture: is the heaven bead set, how many earth beads are set, and — folded into the same two | |
| outputs — *is this a readable abacus column at all*. **Version 2 reads a soroban as well as the | |
| 3D-printed [Abacus Studio](https://abaci.one/create/abacus) abacus.** It is the last stage of the camera | |
| reader on [abaci.one](https://abaci.one), after | |
| [abacus-frame-finder](https://huggingface.co/thomashallock/abacus-frame-finder) and | |
| [abacus-column-counter](https://huggingface.co/thomashallock/abacus-column-counter), and it is what turns | |
| a phone pointed at a child's abacus into the number they have set. It is live on abaci.one since | |
| 2026-12-04. | |
| **Trained only on rendered drawings; no photograph was ever a training example.** Real pictures were | |
| used, earlier in its lineage, to *choose* its recipe, and to *check* it before publishing. The Privacy | |
| section says exactly how. | |
| ## What's new in version 2 | |
| - **It reads sorobans.** Version 1 (gate B) was taught Studio abaci only. This version was taught on 57,921 | |
| drawn soroban rods as well, cut the way the phone cuts them (`soroban-cut.json`, below). | |
| - **The Studio is not measurably worse** for it (development scores below). | |
| - Version 1's weights, its held-back test scores and its real-picture scores stay at the tag | |
| [`v1-20261203`](https://huggingface.co/thomashallock/abacus-column-reader/tree/v1-20261203). Those | |
| scores belong to those weights, not to this version. | |
| ## What it predicts | |
| | | | | |
| |---|---| | |
| | Input | `(N, 128, 64, 1)` float32, grey / 255. The app's cut: a 72 × 384 px window centred on the column's slot after the frame is straightened at 300 / 61.5 px per mm wide and 400 / 86.5 tall (+1 mm pad), JPEG 80, grey, area-resampled to 64 × 128. | | |
| | `output_0` | `(N, 1)` — probability the heaven bead is set | | |
| | `output_1` | `(N, 5)` — softmax over 0 … 4 earth beads set | | |
| | Digit | `5 · [heaven ≥ 0.5] + argmax(earth)` | | |
| | Confidence | `sqrt(|heaven − 0.5| · 2 · max(earth))` — in [0, 1] | | |
| | Accept | the app takes a frame only when **every column's confidence ≥ 0.5**, three frames in a row agreeing | | |
| **The gate.** A separate head *g* = P(this is a readable abacus column) is trained on the frozen reader's | |
| features and folded into the outputs: `heaven' = 0.5 + (heaven − 0.5)·g²`, `earth' = earth·g² + (1 − g²)/5`. | |
| A column that is covered by a hand, or is not an abacus column at all, comes out with heaven ≈ 0.5 and a | |
| flat earth distribution, so its confidence is near 0 and the app refuses it — with no change to the app. | |
| The digits are the base reader's; the gate only withholds them. | |
| ### The soroban cut (`soroban-cut.json`) | |
| The reader cuts a soroban exactly as it cuts a Studio abacus, so the app needs no second cutter. It does | |
| this with a stand-in outline: | |
| 1. The finder gives the soroban frame's four corners, and the counter gives the number of rods and where | |
| each rod is seen. | |
| 2. The app stretches the found outline sideways until the Studio's column positions for that count fall | |
| on the soroban's rods. | |
| 3. A soroban's beads sit lower than the top of its frame, so on a slanted view the bead row also shifts | |
| up or down in the picture, and the phone cannot measure by how much. So the stand-in outline is made | |
| taller than the frame's opening: from 12 % of the opening's depth above its top edge to 17 % below its | |
| bottom edge. That is `"depth": [-0.12, 1.17]`, in shares of the found outline's depth. This span covers | |
| where the rods' ends land on 98 % of the training drawings (the 1st to 99th percentile). | |
| 4. Each rod is then cut from the stand-in outline like a Studio column. | |
| The reader was taught on cuts at exactly this span, so the file belongs to these weights: read it, don't | |
| hard-code it. A reader folder without the file means the span 0 to 1. The first soroban reader (live for | |
| 32 minutes on 2026-12-04, never published) used 0 to 1, and on slanted views it cut the heaven bead off, | |
| so a 5 read as 0. | |
| ## Files | |
| | File | SHA-256 | Size | | |
| |---|---|---| | |
| | `soroban-cut.json` — the soroban cut's depth span, `{"version": 1, "depth": [-0.12, 1.17]}` | `dd4c5c6e…96b8dbba` | 39 B | | |
| | `model.json` + `group1-shard1of1.bin` — TF.js graph model | `15505f64…578e9172` / `f16ece17…6016049c` | 1.3 MB | | |
| | `keras/column-reader-sor2.keras` — the trained Keras 3 model it was exported from | `3034206e…155a84b3` | 1.4 MB | | |
| | `keras/recipe.json` — the gate head's training record (counts, epochs, drawn validation) | `a83fca5a…76a30909` | 429 B | | |
| The TF.js files are byte-identical to what abaci.one serves as `column-classifier/drawn-slots-sor2-cnn-20261203`. | |
| ## Usage | |
| ```js | |
| import * as tf from '@tensorflow/tfjs'; | |
| const model = await tf.loadGraphModel('model.json'); | |
| const sorobanCut = await (await fetch('soroban-cut.json')).json(); // { version: 1, depth: [v0, v1] } | |
| // column: a 64x128 grey crop as [1, 128, 64, 1], values 0-1 | |
| const [heaven, earth] = model.predict(column); // [1,1], [1,5] | |
| const h = (await heaven.data())[0], e = Array.from(await earth.data()); | |
| const digit = (h >= 0.5 ? 5 : 0) + e.indexOf(Math.max(...e)); | |
| const confidence = Math.sqrt(Math.abs(h - 0.5) * 2 * Math.max(...e)); | |
| if (confidence >= 0.5) console.log('digit', digit); else console.log('not sure'); | |
| ``` | |
| The slot cut, the soroban's stand-in outline and the rest of the pipeline are in the open-source app: | |
| [`apps/web/src/lib/vision/`](https://github.com/antialias/abaci-one/tree/main/apps/web/src/lib/vision) | |
| (`columnClassifier.ts`, `slotCut.ts`, `sorobanCut.ts`, `cvPort.ts`); the floor and frame count are in | |
| `src/types/vision.ts`. | |
| **A trap in the Keras file.** Run in Keras on a batch of exactly 5 cuts (the same as the number of earth | |
| classes), the folded gate is applied wrongly: each row's share of "unsure" lands on one earth class of | |
| every row. Any other batch size is right, and the browser reads one cut at a time. Avoid batches of 5, or | |
| check against single cuts. | |
| ## Architecture | |
| Unchanged from version 1. Base reader: four blocks of Conv 3 × 3 (16 / 32 / 64 / 64, no bias) → BatchNorm | |
| → ReLU → MaxPool 2, dropout 0.25, flatten (2,048), Dense 64, dropout 0.4, then two Dense-64 branches to the | |
| heaven (1) and earth (5) heads: 200,598 parameters. Gate: Dense 64 → dropout → Dense 1 (sigmoid) on the | |
| frozen flatten, 131,201 parameters, folded in as above. 331,799 in all. | |
| ## Training | |
| Four steps, all on rendered column cuts: | |
| 1. **Root** (`d-v1slice-s42`, 2026-11-29): the base architecture from a blank start on 5,808 drawn | |
| columns of the 4-column printed design (tan frame, dark beads), seed 42. | |
| 2. **Studio base** (`base-slots-s42`, 2026-12-03, version 1's base): warm-started from the root and | |
| trained 30 epochs (lr 3 × 10⁻⁴, 94 min, laptop CPU) on 131,000 drawn columns from four renderers: the | |
| printed design in random frame and bead colours (29,408), its original look (29,408), rods of a general | |
| procedural abacus generator (5,336), and slot cuts of Studio prints with 3–21 columns (66,677). | |
| 3. **Soroban base** (`sorV-base-s42`, 2026-12-03): warm-started from the Studio base and trained 20 epochs | |
| (lr 2 × 10⁻⁴, 87 min, laptop CPU) on all of the above plus **57,921 clear soroban rods**, cut with the | |
| stand-in outline over the −0.12 to 1.17 depth span, with corners shaken like the counter's training. | |
| Validation on drawn pictures. | |
| 4. **Gate** (`sorVgated-s42`): the gate head trained 20 epochs on 182,261 drawn abacus columns (version 1's | |
| plus clear soroban rods) against 23,428 drawn not-abacus pictures (version 1's: desk renders cut as if | |
| they were columns, general-generator desks, Studio slots at least four-ninths covered by a hand or object; | |
| plus soroban rods at least four-ninths covered). Drawn validation: abacus called abacus 98.5 %, | |
| not-abacus called abacus 2.1 %. | |
| TensorFlow 2.19 on several CPU threads: the same command and seed has given readers a point apart. | |
| **Score any re-trained reader before trusting it.** | |
| ## Evaluation | |
| **Development scores: these drawings were used to choose this model; no held-back score yet for this | |
| version.** The soroban numbers below chose the depth span (0 to 1 against −0.12 to 1.17), and the Studio | |
| numbers were read to make sure the Studio did not get worse. The held-back drawn test sets have not been read | |
| for this version. | |
| The target this reader is built towards is ≥ 99 % of whole numbers right with ≤ 1 wrong number accepted in | |
| 300. **It is not met** on either kind; the model is in the app because it reads sorobans far better than | |
| version 1 did, at no measurable cost on the Studio. | |
| "Clear" = no column covered. "Wrong accepted" = a wrong whole number with every column at confidence ≥ 0.5. | |
| | Set (clear pictures) | Corners | Whole numbers right | Wrong accepted | | |
| |---|---|---|---| | |
| | Soroban drawings never trained on (874) | exact | **610 (69.8 %)**; per rod 95.0 % | 68 | | |
| | Soroban drawings never trained on (874) | shaken like the finder's | 536 (61.3 %) | 52 | | |
| | Soroban choice drawings (165), end to end | finder + counter | 117 (70.9 %) | 11 | | |
| | Studio drawings never trained on (1,298) | exact | 1,200 (92.4 %) | 24 | | |
| | Studio choice drawings (171) | exact | 155 (90.6 %) | 4 | | |
| With the first soroban cut (span 0 to 1) the same soroban sets gave 534 / 874 (exact corners) and 101 / 165 | |
| (end to end). Version 1 on the same Studio sets: 1,210 / 1,298 (26 wrong) and 157 / 171 (6 wrong). Version 1 | |
| read 23.3 % of the never-trained-on soroban whole numbers (exact corners). | |
| **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. The printed markers give the true corners, | |
| and "the right number" is this same reader's reading cut at those true corners; the markers are then painted | |
| out and the whole served chain (finder, counter, this reader) reads the frame. Two sets: 1,023 frames from | |
| practice sittings, and 210 frames (5 moments) from the owner's own trial. | |
| | | practice frames | owner's trial frames | | |
| |---|---|---| | |
| | same number as the true-corner reading | 96.6 % | 84.0 % | | |
| | a different number, confidently | 0.5 % | 5.8 % | | |
| (Version 1's chain: 97.5 % / 0.9 % and 77.2 % / 8.9 %.) The trial's wrong numbers are beads caught | |
| mid-move, where the true-corner reading is itself unreliable. There are no real sorobans in this check, and | |
| it is a pre-publish gate, not a benchmark: nothing was trained or tuned on it. | |
| ## Limitations | |
| - Studio-design abaci and ordinary 1/4 sorobans only. Other abaci are not read. | |
| - Below the target on both kinds: on clear soroban drawings about 3 in 10 whole numbers are refused or | |
| wrong; on the Studio about 1 in 13. | |
| - Sorobans are scored on drawings only. There is no real-photo score for sorobans, and the depth span was | |
| set from drawings; the phone cannot measure a real soroban's bead-row shift. | |
| - Heaven beads caught mid-travel (the drawings count a bead as set from 60 % of its travel) and columns | |
| under about 20 px wide are the usual misses. | |
| - The gate refuses covered columns, not every kind of nonsense: it was trained against desks, hands and | |
| objects, nothing else. | |
| - Real-picture checks exist for printed four-column Studio abaci, one camera. Behaviour on other real | |
| abaci is not measured. | |
| ## Training data, attribution and licence | |
| Every training example is a render: Blender 4.4 scenes built from the Studio's own OpenSCAD parts | |
| ([`public/scad/abacus.scad`](https://github.com/antialias/abaci-one/blob/main/apps/web/public/scad/abacus.scad), | |
| the owner's design), from a procedural abacus generator and from a procedural soroban generator, | |
| procedural textures, no third-party image or mesh assets, macOS system fonts for frame text. No pretrained | |
| weights anywhere in the lineage. **Apache License 2.0** (`LICENSE`). | |
| ## Privacy | |
| The camera reader is used by children practising at home; the real pictures we hold show their desks | |
| and hands. **None of the three camera models (the finder, the counter, this reader) was trained on real | |
| pictures, and none of those pictures is published, here or anywhere.** They did touch this reader in these | |
| ways, which we state so nobody mistakes "drawn-only" for "untouched": | |
| 1. **Selection, earlier in the lineage (as in version 1).** The root reader was picked among several | |
| training runs by its score on real January practice columns, as were the renderer, the separate gate | |
| head over an "unsure" target, and the share of general-generator rods in the base's data. Those are | |
| choices among drawn-only candidates, made by looking at real numbers. | |
| 2. **One measured constant.** The renderer's default cut inset (10.7 × 8.5 mm) was measured on the real | |
| printed abacus's stuck-on markers. | |
| 3. **A pre-publish check.** Real frames with their markers painted out were scored once before this | |
| version was published (the table above); only counts and rates leave the owner's machine. | |
| Version 2's own choices (adding sorobans, the depth span, the gate's soroban negatives) were made on | |
| drawings alone. | |
| ## Reproducibility | |
| Generators (`studio2/scripts/gen.py`, `render_wide.py`, `synth/scripts/render.py`, | |
| `general/scripts/gen.py`, `soroban1/scripts/gen.py`; Blender 4.4; seeds in the kit), cutters | |
| (`cut_studio2.py`, `cut_soroban1.py`), `train_slots.py` (warm start, lr, seed 42), `add_abacus_head.py`, | |
| scorers (`score_slots.py`, `score_sor.py`), export to TF.js (`export_graph_models.py reader`, TF 2.19, | |
| converter 4.22) and the Node equivalence check. The original drawn-only recipe, `add_abacus_head.py` and | |
| the export script are public at | |
| [`apps/web/scripts/train-column-classifier/drawn/`](https://github.com/antialias/abaci-one/tree/main/apps/web/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, and this card | |
| will link it. The root's 5,808-column slice was cut by hand and no script rebuilds it byte for byte; a | |
| re-run of the recipe gives a reader within about a point of this one. | |
| ## Citation | |
| ```bibtex | |
| @misc{hallock2026abacusreader, | |
| title={abacus-column-reader: reading the columns of a 3D-printed abacus or a soroban with a network trained only on drawings}, | |
| author={Hallock, Thomas}, | |
| year={2026}, | |
| url={https://huggingface.co/thomashallock/abacus-column-reader} | |
| } | |
| ``` | |