Run this model with HF Jobs
Run thomashallock/abacus-column-counter 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-counter. 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-counter 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-counter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use thomashallock/abacus-column-counter 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-counter") - Notebooks
- Google Colab
- Kaggle
abacus-column-counter (joint-c2)
A 2.95 M-parameter, 11.8 MB TF.js convolutional network that looks at a straightened picture of an abacus and says which kind it is and how many columns it has: a 3D-printed Abacus Studio abacus with 3 to 21 columns, or an ordinary 1/4 soroban with 9, 11, 13, 15, 17, 19, 21, 23 or 27 rods. It also marks where each column or rod is, or says "not sure". It sits between abacus-frame-finder (which gives the frame's four corners) and abacus-column-reader (which reads each column) in the camera reader on abaci.one, live there since 2026-12-04. Before a counter, the app assumed every abacus had the number of columns in the user's settings and cut them at even intervals; with it, the abacus is cut on its real columns.
Trained from scratch, only on rendered drawings. No pretrained weights, no photographs.
What's new in version 2
- A new range: two kinds in one network. Version 1 (c1) counted Studio abaci, 3 to 21 columns. This version (c2) also counts sorobans, and says which kind it saw: the app accepts counts of 3 to 27. A Studio abacus's 9 and a soroban's 9 are different classes.
- The heat-map head now marks soroban rods as they show. The 192-bin heat-map along the width was in version 1 too (for the Studio's slots). On a soroban the bead row sits below the frame's top face, so at a slant the rods do not line up with where they meet the frame; c2 was taught the rods where they are seen. The app fits an evenly spaced row of rods to the peaks and hands it to the reader's soroban cut.
- A wider canvas. The side margin grew from 20 to 32 mm (a soroban's frame runs wider of its rods)
and the width estimate may go up to 760 mm.
counter.jsoncarries the classes, the margin and the ceiling; read it, don't hard-code them. - 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
| Input | (N, 96, 384, 3), RGB 0β255: the frame straightened from its four corners onto a width-normalised canvas with marginXMm (32 mm) side margins and 12 mm top and bottom (the scale is the frame's 86.5 mm depth; the width estimate is clipped to 35β760 mm) |
| Output | (N, 221) logits = 192 heat-map bins (bin b is canvas x = 2b + 0.5 px) + 29 classes: the 28 (kind, count) pairs listed in counter.json, then "can't count" |
| Read-out the app uses | class = argmax of the 29; accept only if its probability β₯ 0.95 and exactly that many heat-map peaks are β₯ 0.5; otherwise "not sure" and the app falls back to the user's setting. The phone also wants two agreeing runs in a row before it commits. |
The column positions are what the reader's cut is centred on, so the heat-map matters as much as the count.
Files
| File | SHA-256 | Size |
|---|---|---|
counter.json β the class list (kind, count), the side margin and the width ceiling |
2792826dβ¦6211b625 |
517 B |
model.json + group1-shard1of1.bin β TF.js graph model |
a4b95320β¦54ec986f / cb59e169β¦2774f0ad |
11.8 MB |
keras/column-counter-c2.keras β the trained Keras 3 model it was exported from |
e2b2d97fβ¦fcb3c15a |
35.7 MB |
The TF.js files are byte-identical to what abaci.one serves as column-counter/joint-c2-f32-20261203.
Usage
import * as tf from '@tensorflow/tfjs';
const spec = await (await fetch('counter.json')).json(); // classes, marginXMm, maxWidthMm
const model = await tf.loadGraphModel('model.json');
// strip: the straightened frame as [1, 96, 384, 3], RGB 0-255 (see the app's columnCounter.ts for the warp)
const out = model.predict(strip); // [1, 221]
const heat = tf.sigmoid(out.slice([0, 0], [1, 192]));
const k = spec.classes.length; // 28
const cls = tf.softmax(out.slice([0, 192], [1, k + 1])); // spec.classes[i] = [kind, count]; index k = can't count
The warp from corners to this canvas, the peak-finding, the rod-row fit and the hold logic are in the
open-source app:
apps/web/src/lib/vision/
(columnCounter.ts, columnCounterNets.ts, columnCountHold.ts, cvPort.ts). The Python reference is
counter/score2.py in the training kit.
Architecture
As version 1, with a wider class head: a five-level convolutional encoder (stride 32), a U-net decoder back to stride 2, a height-averaged one-dimensional heat-map, and a class head over the flattened deep features and the width profile (Dense 256 β 29). Plain Keras layers, 2,950,446 parameters.
Training
- Data: the rendered Studio abaci (3β21 columns) and the rendered sorobans (9β27 rods), with all four corners in the picture; rare classes weighted count^β0.7. Corners shaken to mimic the finder's error, soroban corners 2.5 times as hard (the finder's soroban corners are looser); mirrored and quarter-turned ("can't count") as in version 1.
- Targets: a Studio abacus's slots; a soroban's rods where they are seen, at rod height.
- 50 Γ 400 steps, batch 64, Keras 3 on the PyTorch backend, a desktop GPU, 87 min, from a blank start. Batches are seeded; initialisation is not.
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) decided the design (rods as they show, the margin, the shake) and chose c2 over a longer-trained c2b. The held-back drawn test sets have not been read for this version.
All with corners from this release's frame finder (s3b), full view:
| Measure | development (choice sets) |
|---|---|
| Studio abacus: count right / sure and wrong | 206 / 210 (98.1 %) / 0 (version 1: 207 / 0) |
| Soroban: sure and right, of found frames | 210 / 224 (93.8 %) |
| Soroban: sure and wrong / wrong kind | 0 / 0 |
| Soroban rods, worst rod at p99, exact corners | within a tenth of the rod pitch |
| Soroban rods, worst rod at p99, finder corners | within 0.22 of the pitch |
It is never sure and wrong on either set. On sorobans it falls short of the targets the work set (sure and right on 97 % of found frames, rods within a tenth of the pitch from the finder's corners): it is less often sure, and on hard pictures (a steep dark 27-rod soroban, a ruler over the rods) it places rods worse. The owner chose to ship it as the first two-kind counter.
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, corners from the finder with the markers painted out. 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 | |
|---|---|---|
| count sure and right | 95.5 % | 90.0 % |
| count sure and wrong | 0 % | 0 % |
(Version 1's chain on the same frames: 93.8 % and 86.2 % sure and right, 0 % sure and wrong.) There are no real sorobans in this check, 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 with 9, 11, 13, 15, 17, 19, 21, 23 or 27 rods only. Other rod counts and other abaci are not classes.
- Soroban counts are scored on drawings only; there is no real-photo score for sorobans.
- It needs the frame's corners from a finder; its accuracy with corners worse than the finder's is not measured beyond the shaking used in training.
- On a soroban the phone cannot measure how far the bead row has shifted in depth; the reader's cut covers that (see its card).
- Below about 20 px per column the downstream reader struggles, so very wide abaci far from the camera are not read even when counted.
- Trained on renders; real glare, blur and noise are only imitated.
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
third-party image or mesh assets, macOS system fonts for frame text. No pretrained weights. Apache
License 2.0 (LICENSE).
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 (the finder, this counter, the reader) was trained on real pictures, and none of those pictures is published, here or anywhere. This counter's read-out rule and its choice among 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. Nothing shown in this repo is a photograph.
Reproducibility
Generators (studio2/scripts/gen.py, seeds 59001 / 59002 / 59003; soroban1/scripts/gen.py, seeds
70001 / 70002 / 70003; Blender 4.4), trainer (counter/train2.py c2 50 400, nets2.py), scorer
(counter/score2.py), TF.js export (export_graph_models.py counter, in the app repo's
scripts/train-column-classifier/drawn/;
SavedModel β TF.js graph model, TF 2.19, converter 4.22). 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. Drawings re-render identically from
their seeds; training does not repeat exactly.
Citation
@misc{hallock2026abacuscounter,
title={abacus-column-counter: counting 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-counter}
}
- Downloads last month
- -
Collection including thomashallock/abacus-column-counter
Evaluation results
- Studio abacus, count right (development) on Drawn choice sets, Studio abacus and soroban, corners from abacus-frame-finder (development scores - these drawings were used to choose this model; no held-back score yet for this version)self-reported98.100
- Soroban, sure and right on found frames (development) on Drawn choice sets, Studio abacus and soroban, corners from abacus-frame-finder (development scores - these drawings were used to choose this model; no held-back score yet for this version)self-reported93.800
- Sure and wrong, either kind (development) on Drawn choice sets, Studio abacus and soroban, corners from abacus-frame-finder (development scores - these drawings were used to choose this model; no held-back score yet for this version)self-reported0.000