Draw a traffic sign. A from-scratch CNN will name it.
Ten signs, a 19 × 19 grid, and a convolutional network written in NumPy by hand, ported to run here in your browser. Nothing you draw leaves this page.
Drag to paint cells with the selected tool. With a mouse, right-drag always erases. With the keyboard, use the arrow keys to move and Space to paint.
Prediction
Loading the model…
- Confidence
- Similarity to the reference
Probability for each sign
Try a sample
One drawing of each sign from testing_dataset/, images the model never saw during training. Pick one to load and classify it, then edit it.
How it works
The whole pipeline is NumPy and Pillow, no ML framework. The page runs the same steps in JavaScript, and a parity test checks that both give the same answer on all 500 test images.
-
Binarize
Each image becomes a 19 × 19 grid of ink (1) and background (0): pixels darker than 128 count as ink. Your drawing is already in that form.
-
Layer 0: ten fixed kernels
Hand-designed 5 × 5 kernels for lines, diagonals, edges and L-shaped bends slide over the grid with stride 2, then ReLU and 2 × 2 max-pooling: 4 × 4 maps, one per kernel.
-
Layer 1: position features
Four 2 × 2 kernels per map, applied with stride 2 and followed by a max, reduce each map to four numbers: 40 features in all. Each feature is then divided by its largest value in the training set.
-
Fully connected network
40 inputs, 128 hidden ReLU units, 10 outputs and a softmax. Only this part is trained, with dropout of 0.2, for 700 epochs on 1,520 augmented images made from one drawing per sign.
-
Answer
The sign with the highest probability wins; that probability is the confidence. Similarity is the share of ink your drawing and the reference drawing have in common (Jaccard index).
- Course test set
- 93.0% accuracy, as reported in
report.md testing_dataset/- 93.5% (187 of 200), held out from training
- Model size
- 6,538 trained weights and biases