Downloads · 30 days
0
mhalimi3008/pashtoOCR
pashtoOCR is a image-to-text model from mhalimi3008. Use it when you need a caption or text from an image. The card lists the license as mit.
Line-level Pashto OCR (CRNN: VGG-style CNN + 2-layer BiLSTM + CTC, ~12M params).
Downloads · 30 days
0
Access
Public
Updated Aug 7, 2026
Repo size
290 MB
Likes
3
Public
Click a slice to open those files.
.pt81.8 MB · 39%
From the Hugging Face model README
Line-level Pashto OCR (CRNN: VGG-style CNN + 2-layer BiLSTM + CTC, ~12M params).
crnn.pt - stage-1 weights: printed / on-screen text
(trained on zirak-ai/PashtoOCR).
Printed validation CER = 0.0368 / WER = 0.1210crnn_pashtoOCR.pt - stage-2 weights: fine-tuned on
KPTI (17k real hand-scribed Pashto text lines).
Reads katib-style handwritten manuscripts as well as printed text. KPTI test CER = 0.0563 / WER = 0.2299.charset.json - character vocabulary + preprocessing configGrayscale, dark-text-on-light (auto-invert dark themes), resized to height 48 (aspect preserved), normalized to [-1, 1], then horizontally flipped (RTL script -> left-to-right CTC frames). Decode with greedy CTC (collapse repeats, drop blank id 0).
import json, torch
from huggingface_hub import hf_hub_download
weights = hf_hub_download("mhalimi3008/pashtoOCR", "crnn_pashtoOCR.pt") # or crnn.pt
cfg = json.loads(open(hf_hub_download("mhalimi3008/pashtoOCR", "charset.json")).read())
model = CRNN(len(cfg["charset"]) + 1).eval() # CRNN class from the training notebook
model.load_state_dict(torch.load(weights, map_location="cpu"))
The training notebook (sections 5-6 and 10) contains the full inference code, including projection-profile line segmentation and PDF support.
If you use the handwriting weights in research, cite: Ahmad et al., "KPTI: Katib's Pashto Text Imagebase and Deep Learning Benchmark", ICFHR 2016.