Persian Handwritten Digit Recognition

A CNN classifier for Persian (Farsi) handwritten digits۰۱۲۳۴۵۶۷۸۹ — trained on 80,000 real handwritten digit images.

Accuracy: 99.8% on a held-out test set (200 images per class).

Model

  • Architecture: Conv2D → Conv2D → MaxPool → Dense → Softmax (10 classes)
  • Input: 28×28 grayscale image, normalized to [0, 1]
  • Output: probability distribution over 10 digits (0–9)
  • Framework: TensorFlow / Keras 3 (digit_classifier_handwritten.keras)
  • Training data: Mehdinmz/persian-handwritten-digits

Usage

from huggingface_hub import hf_hub_download
import tensorflow as tf
import numpy as np

path = hf_hub_download("Mehdinmz/persian-handwritten-digit-recognition", "digit_classifier_handwritten.keras")
model = tf.keras.models.load_model(path)

# img: 28x28 grayscale float32 in [0,1]
pred = model.predict(img.reshape(1, 28, 28, 1), verbose=0)
digit = int(np.argmax(pred))  # 0..9 (Persian digit: ۰۱۲۳۴۵۶۷۸۹)

Results

Metric Value
Test accuracy 99.8%
Per-class (200 imgs each) ≥ 99.5% for all classes

Source

Full OCR pipeline (segmentation, CAPTCHA support, training code): github.com/mehdinmz/Persian-CAPTCHA-OCR

License

MIT © 2026 Mohammad Mehdi Namazian

Downloads last month
10
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support