Datasets:
File size: 4,247 Bytes
4878037 f501fe8 8ff72dc f501fe8 8ff72dc f501fe8 8ff72dc 4878037 8ff72dc 018a43f 8ff72dc 018a43f 4878037 f501fe8 b96b8b4 f501fe8 b96b8b4 f501fe8 b96b8b4 f501fe8 b96b8b4 f501fe8 b96b8b4 f501fe8 b96b8b4 f501fe8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | ---
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.
|