| --- |
| license: mit |
| task_categories: |
| - image-classification |
| tags: |
| - racing |
| - telemetry |
| - gear-detection |
| - motorsport |
| - digit-recognition |
| - onboard-camera |
| pretty_name: Racing Gear Digits |
| size_categories: |
| - 1K<n<10K |
| configs: |
| - config_name: default |
| data_files: |
| - split: train |
| path: data/train-* |
| - split: validation |
| path: data/validation-* |
| dataset_info: |
| features: |
| - name: image |
| dtype: image |
| - name: label |
| dtype: int64 |
| - name: source |
| dtype: string |
| splits: |
| - name: train |
| num_bytes: 3041614 |
| num_examples: 5470 |
| - name: validation |
| num_bytes: 525445 |
| num_examples: 946 |
| download_size: 3435199 |
| dataset_size: 3567059 |
| --- |
| |
| # Racing Gear Digits |
|
|
| Image classification dataset for detecting gear numbers (0-9) from racing onboard camera telemetry overlays, supplemented with MNIST digits for robustness. |
|
|
| Similar in spirit to MNIST but for a specific real-world application: reading the gear indicator from racing car onboard video feeds in real-time. |
|
|
| ## Dataset |
|
|
| - **5,964 training** / **1,003 validation** images |
| - **32×32 grayscale** PNG images |
| - **10 classes** (digits 0-9) |
| - **Source column** distinguishes `racing-original`, `paul-ricard-alpine`, `sebring-tobi-lap6`, `racing_aug` (augmented), and `mnist` |
| - **Proper stratified split** — 15% of each racing source held out for validation |
| - **Augmented minority classes** — racing digits with <200 training samples augmented via random shifts, brightness/contrast jitter, and Gaussian noise |
|
|
| ### Racing sources |
|
|
| | Source | Gears | Style | |
| |--------|-------|-------| |
| | TDS Racing IMSA Sebring 2026 (original) | 1-6 | White digit on gray RPM gauge face | |
| | Sebring Q Tobi Lap 6 | 1-6 | White digit on dark semi-transparent overlay | |
| | Paul Ricard Alpine LMPh | 1-7 | White digit on dark circle | |
| | MNIST supplement | 0-9 | Handwritten digits (generalization) | |
|
|
| ### Train distribution |
|
|
| | Digit | Racing (orig) | Sebring | Paul Ricard | Aug | MNIST | Total | |
| |-------|--------------|---------|-------------|-----|-------|-------| |
| | 0 | 0 | 0 | 0 | 0 | 196 | 196 | |
| | 1 | 864 | 36 | 35 | 0 | 196 | 1,167 | |
| | 2 | 1,344 | 74 | 105 | 0 | 196 | 1,719 | |
| | 3 | 364 | 99 | 162 | 0 | 196 | 821 | |
| | 4 | 37 | 68 | 4 | 91 | 196 | 396 | |
| | 5 | 107 | 138 | 49 | 0 | 196 | 490 | |
| | 6 | 106 | 79 | 35 | 0 | 196 | 416 | |
| | 7 | 19 | 0 | 45 | 137 | 196 | 397 | |
| | 8 | 0 | 0 | 0 | 0 | 196 | 196 | |
| | 9 | 0 | 0 | 0 | 0 | 196 | 196 | |
|
|
| ## Adding new video sources |
|
|
| 1. **Extract** gear crops from a video: |
| ```bash |
| uv run python scripts/extract.py <video_path> <source_name> <x> <y> <w> <h> |
| ``` |
| This creates `raw/<source>/unlabeled/` frames and a `composites/<source>/unlabeled.png` contact sheet. |
|
|
| 2. **Label** by reading the contact sheet and creating `labels/<source>.csv`: |
| ```csv |
| start,end,label |
| 0,14,5 |
| 15,39,6 |
| ``` |
| Each row maps a frame range (inclusive, 0-indexed) to a gear digit. |
|
|
| 3. **Build** the dataset: |
| ```bash |
| uv run python scripts/build_dataset.py |
| ``` |
| This reads all `raw/` sources and `labels/` CSVs, does stratified train/val splitting, augments minority classes, and writes the parquet files. |
|
|
| ## Augmentations (racing_aug) |
| |
| For racing classes with fewer than 200 training samples, synthetic samples are generated: |
| |
| - **Random translation** — up to ±3px shift in x/y |
| - **Brightness jitter** — 0.7–1.3× |
| - **Contrast jitter** — 0.8–1.2× |
| - **Gaussian noise** — σ=8, 30% probability |
| |
| ## Usage |
| |
| ```python |
| from datasets import load_dataset |
|
|
| ds = load_dataset("tobil/racing-gears") |
| |
| # Filter to real racing images only |
| racing = ds["train"].filter(lambda x: x["source"] not in ("mnist", "racing_aug")) |
|
|
| # Standard training loop |
| for example in ds["train"]: |
| image = example["image"] # PIL Image, 32x32 grayscale |
| label = example["label"] # int 0-9 |
| source = example["source"] # source identifier |
| ``` |
| |
| ## Context |
|
|
| Built for the [mpv racing telemetry plugin](https://github.com/tobi/mpv-telemetry) which reads baked-in telemetry from racing onboard videos using mpv's `screenshot-raw` API and renders a live overlay with throttle/brake traces, gear indicator, and steering position. |
|
|
| The gear digit is detected using a small CNN (ONNX) called via LuaJIT FFI from mpv's Lua scripting environment at 30fps. |
|
|