--- license: agpl-3.0 library_name: pytorch pipeline_tag: keypoint-detection tags: - rubiks-cube - speedcubing - wca - onnx - keypoint-detection - image-classification - skewb - pyraminx --- # CubeCheck models Small networks that check a scrambled cube, 2×2 to 7×7, from one camera view, and (experimental, since v0.3.0) a skewb, a pyraminx and an FTO. They power [check.cubing.in](https://check.cubing.in), where they run in the browser. - **Code, training and evaluation:** [github.com/darshanvss/cubecheck](https://github.com/darshanvss/cubecheck) - **Try it:** [check.cubing.in](https://check.cubing.in) ## Versions Each release is a tag; the code pins the one it was tested with. | Tag | Corners | Sticker reader | Cube sizes | | --- | --- | --- | --- | | **`v0.3.0`** | c7, plus one per puzzle: **skewb-c1**, **pyram-c2**, **fto-c2** | r4, plus one per puzzle: **skewb-r1**, **pyram-r2**, **fto-r2** | 2×2 to 7×7; skewb, pyraminx, FTO (experimental) | | `v0.2.0` | **c7**: trained with painted fingers over corners and across whole edges, and with two-face views | **r4**: one reader for every size | 2×2 to 7×7 | | `v0.1.0` | c2 | r2 | 3×3 | This repository was called `cubecheck-3x3` until v0.2.0; the old name still redirects here. ## Files (v0.2.0) | File | What it does | Parameters | Size | | --- | --- | --- | --- | | `corners/c7/finder.pt` | Whole frame at 256×256 → is there a cube, and roughly where its 7 visible corners are | 2.5 M (small U-Net) | 10 MB | | `corners/c7/refiner.pt` | 256×256 close-up → the 7 corners precisely | 2.5 M (small U-Net) | 10 MB | | `reader/r4/best.pt` | The three visible faces of an N×N cube, straightened to 24 px per sticker → each of the 3N² stickers: one of 6 colours, or covered | 0.72 M (small CNN, a position network, 2 transformer layers) | 2.9 MB | | `onnx/finder.onnx`, `onnx/refiner.onnx` | The corner networks for ONNX Runtime (used by the website) | | 9.9 MB each | | `onnx/reader-N.onnx` (N = 2…7) | The sticker reader for one cube size: the website loads only the size it checks | | 2.9 MB each | | `onnx/meta.json` | Input sizes and the settings the website uses (finder bar 0.5, a second look 2× closer when unsure) | | | | `*_log.json`, `log.json` | Training curves, one entry per epoch | | | The older `corners/c2/` and `reader/r2/` files are kept (the `v0.1.0` tag has its own `onnx/`). The `.pt` files are PyTorch checkpoints holding only weights, settings and scores (they load with `torch.load(..., weights_only=True)`). Use them from Python or to train further, and the ONNX files to run in a browser or anywhere ONNX Runtime runs. ## Files added in v0.3.0: skewb, pyraminx and FTO (experimental) Each puzzle has its own three networks, the same kinds as the cube's, each trained on from the cube's weights. The cube files above are unchanged. | File | What it does | Size | | --- | --- | --- | | `corners/skewb-c1/`, `corners/pyram-c2/`, `corners/fto-c2/` (`finder.pt`, `refiner.pt`) | Find the puzzle and its visible corners: 7 on a skewb, the 4 tips of a pyraminx, 5 on an FTO (the corner nearest the camera and the four around it) | 10 MB each | | `reader/skewb-r1/`, `reader/pyram-r2/`, `reader/fto-r2/` (`best.pt`) | The visible faces, straightened (triangles upright) → each sticker: one of the puzzle's colours (6, 4 or 8), or covered. Features are averaged over each sticker's own outline | 2.8 MB each | | `onnx/skewb/`, `onnx/pyram/`, `onnx/fto/` (`finder.onnx`, `refiner.onnx`, `reader.onnx`, `meta.json`) | The same for ONNX Runtime, as the website loads them. The reader's sticker averaging is exported as a matrix product (ONNX Runtime's WebGPU backend computed the `einsum` wrongly) | about 23 MB a puzzle | ## Use From the GitHub repository: ```sh cd python uv sync --extra models uv run python scripts/download_models.py # into runs/corners/ and runs/reader/ ``` The website downloads the ONNX files at build time (`web/scripts/fetch-models.mjs`). ## Results (v0.2.0) Held-out synthetic renders with harsh random camera effects, single frames, run exactly as the website runs them (`python/scripts/evaluate_nxn.py`), 300 renders per size with scrambles of every length: | | 2×2 | 3×3 | 4×4 | 5×5 | 6×6 | 7×7 | | --- | --- | --- | --- | --- | --- | --- | | True scramble called correct | 98.7% | 99.3% | 100% | 99.0% | 96.3% | 90.3% | | False alarm (the rest say "re-check") | 0% | 0.7% | 0% | 0% | 0.7% | 0.3% | | One slipped move caught | 96.7% | 100% | 100% | 99.0% | 96.7% | 90.7% | | One slipped move missed | 2.0% | 0% | 0% | 0% | 0.3% | 0% | On 1,000 full 3×3 scrambles: true scramble correct 99.9% with no false alarms, one slip caught 99.5%. With two faces and a sliver in view (the cube held toward the scrambler), 86–95% correct with 0.3–2.7% false alarms. The live page waits for several frames to agree. With fingers hiding a whole edge of the cube, c7 puts the two hidden corners about half as far off as the model before it (4–7% of the edge, from 8–11%), and false alarms on a 7×7 held that way fell from 19% to 6%. ### Skewb, pyraminx and FTO (v0.3.0, experimental) Held-out synthetic renders, single frames, the models as the website runs them, each puzzle held the usual way (skewb and FTO a corner toward the camera, pyraminx an edge): | | Skewb | Pyraminx | FTO | | --- | --- | --- | --- | | True scramble called correct | 98.3% | 96.7% | 98.3% | | False alarm | 0.2% | 0% | 0% | | One slipped move caught | 98.4% | 94.7% | 98.1% | Held any way round, most views become "re-check" with a hint to turn the puzzle; false alarms stay at 0.5% (pyraminx) and 0.2% (FTO). These models have seen only a handful of real puzzles. Results on real photos are not published yet. ## Training data Synthetic only: about 127,000 3D renders (1280×720) of 2×2 to 7×7 cubes in randomised rooms, handheld and on tables, with exact labels for the 7 corners and every sticker. Scrambles of every length, views of three faces, of two faces and a sliver, and of exactly two faces, cluttered scenes, and 15,000 frames with no cube. Room backgrounds are CC0 photos from [Poly Haven](https://polyhaven.com). The training images contain no photographs of people. Camera effects and painted fingers are added at training time. See [docs/dataset.md](https://github.com/darshanvss/cubecheck/blob/main/docs/dataset.md). The skewb, pyraminx and FTO models were trained on renders made the same way: 20,000 per puzzle held the usual way, and for the pyraminx and FTO another 20,000 turned any way round, with a few thousand rooms without a puzzle for the corner models. These renders aren't in the published dataset yet. ## Training Each model starts from its parent's weights. c7: from c5b, finder 8 epochs and refiner 20 on one RTX 4090 (about 1.5 hours). r4: from r3 (itself from the 3×3 reader r2), on an Apple M-series laptop, about 2 hours a stage. The puzzle models: corner networks on one rented RTX 3090, readers on the laptop (about 45 minutes each). Cube commands: [docs/training.md](https://github.com/darshanvss/cubecheck/blob/main/docs/training.md). ## Intended use and limitations - Helps a scrambler double-check a scramble. Not an official WCA tool, and not a replacement for the scrambler's own check. - Skewb, pyraminx and FTO are experimental: treat a verdict as a second opinion. See [docs/other-puzzles.md](https://github.com/darshanvss/cubecheck/blob/main/docs/other-puzzles.md). - Standard WCA colour scheme. Stickerless cubes and unusual colour schemes are untested. - Trained on renders: accuracy on real webcams, under strongly coloured light or with heavy motion blur may be lower. - Needs a corner of the cube toward the camera (three faces), or two faces on 3×3 and bigger. 6×6 and 7×7 stickers are small, so the cube has to be close: farther away the check says "re-check". ## Licence [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html), like the code. If you use these weights in a service that people use over a network, share its source with them.