Downloads · 30 days
18
9% of all-time downloads
shaghxyegh/PersianDigitOCR
PersianDigitOCR is a image classification model from shaghxyegh. Use it when you need a label for an image. It is set up for keras.
Downloads · 30 days
18
9% of all-time downloads
All-time downloads
207
Public
Repo size
23.8 MB
Likes
1
Public
Click a slice to open those files.
.keras23.8 MB · 100%
From the Hugging Face model README
%%writefile README.md
PersianDigitOCR is a deep learning model designed for recognizing handwritten Persian (Farsi) digits (۰-۹) from images. Built by fine-tuning the MobileNetV2 architecture pre-trained on ImageNet, this model achieves a validation accuracy of 99.75% on a subset of the HODA dataset. It is optimized for 96x96 pixel grayscale images and outputs Persian digit characters using Unicode mappings (U+06F0 to U+06F9).
image-classificationimport requests
# Step 1: Download the model from Hugging Face
model_filename = 'PersianDigitOCR.keras'
repo_id = 'shaghxyegh/PersianDigitOCR'
file_url = f"https://huggingface.co/{repo_id}/resolve/main/{model_filename}"
print(f"Downloading model from {file_url}...")
response = requests.get(file_url)
if response.status_code == 200:
with open(model_filename, 'wb') as f:
f.write(response.content)
print(f"Model downloaded successfully as '{model_filename}'")
else:
raise ValueError(f"Failed to download model. Status code: {response.status_code}. Check if the file '{model_filename}' exists in your repo at {file_url}")
# Step 2: Load the model
model = load_model(model_filename)
print("Model loaded successfully!")
Validation Accuracy: 99.75% on 4,000 validation images Training Accuracy: 99.69% (Epoch 30) Context: Trained with batch size 32, 30 epochs, Adam optimizer, and data augmentation (rotation, zoom, shift).