v1.0.0 | Model Active

Handwritten digit recognition
powered by a CNN.

Open Canvas

Draw a digit directly in your browser.

Upload Image

Test the model with an existing image.

Network Architecture

This application utilizes a custom Convolutional Neural Network built with TensorFlow. The architecture is specifically optimized for edge-inference and low latency.

The input matrix passes through multiple Conv2D and MaxPooling2D layers to extract spatial hierarchies—edges, curves, and loops—before being flattened and classified into one of the 10 digit classes.

# Model definition in Keras
model.add(Conv2D(32, (3,3), activation='relu'))
model.add(MaxPooling2D((2,2)))
model.add(Flatten())
model.add(Dropout(0.2))
model.add(Dense(128, activation='relu'))
model.add(Dense(10, activation='softmax'))

Data Preprocessing Pipeline

Visual representation of tensor transformations

Bridging the gap between canvas and tensor.

The original dataset consists of white digits centered on a black background, strictly bounded to a 28x28 pixel grid. Because users draw black ink on a white HTML canvas of variable size, the client-side code must aggressively preprocess the input to prevent model hallucination.

  • 1

    Grayscale & Inversion

    Converts the RGB canvas data to a single-channel grayscale array, and inverts the colors to match the dataset (white stroke, black background).

  • 2

    Bounding Box Extraction

    Crops empty whitespace around the user's drawing so the digit occupies the maximum relative area.

  • 3

    Downsampling & Normalization

    Resizes the cropped image strictly to a 28x28 matrix and normalizes pixel intensities to float values between 0.0 and 1.0.

Model Evaluation

View Source Dataset →
0k
Training Set
10k
Validation Set
0.04
Loss (Cross-Entropy)
98.5%
Test Accuracy

Understanding Model Limitations

While the model achieves exceptional accuracy, analyzing the confusion matrix reveals distinct edge cases. The highest rate of false positives occurs between visually similar digits.

For instance, heavily slanted 1s are occasionally misclassified as 7s, and loosely drawn 3s can be confused with 5s. Dropout regularization was implemented to reduce overfitting on the distinct handwriting styles present in the dataset.

Confusion matrix heatmap on test validation

Run Locally

# Clone the repository
git clone https://github.com/yourusername/digit-recognizer.git

# Navigate into the directory & install dependencies
cd digit-recognizer
pip install -r requirements.txt

# Start the local development server
python app.py
Copied!

Technology Stack

TensorFlow / Keras
Model Training
Python
Backend Logic
Tailwind CSS
Styling & UI
GSAP
Scroll Animations