Datasets:
Koshur-OCR-Synth
A large-scale synthetic optical character recognition (OCR) dataset for Kashmiri (ks). It consists of clean, high-resolution text-line images rendered programmatically in native Kashmiri Nastaliq and Naskh fonts, each paired with its exact ground-truth Unicode transcription.
Designed for OCR recognition, image-to-text modeling (e.g., TrOCR, PARSeq, Donut), fine-tuning, and benchmarking workflows that need clean, controllable image/label pairs at scale.
Sample Images
Dataset Summary
| Property | Value |
|---|---|
| Language | Kashmiri (ks) |
| Script | Perso-Arabic (Nastaliq / Naskh) |
| Modality | Image → Text (OCR) |
| Source | Synthetic (programmatically font-rendered) |
| Fonts | Gulmarg Nastaleeq, Noto Nastaliq Urdu, Afan Koshur Naksh, Narqalam |
| Total Rows | 285,864 |
| Format | ZIP archive of PNG images and companion TXT labels |
| License | Apache 2.0 |
Dataset Structure
The dataset is packaged as a single ZIP file: Kashmiri_OCR_Nastaliq_Naskh_Dataset.zip (2.72 GB).
Inside the archive, files are organized as flat pairs:
archive/image_XXXX_YYYYY.png: Rendered line image (RGB, height normalized/padding-ready).archive/image_XXXX_YYYYY.txt: Companion UTF-8 text label (exact transcription).
Fonts and Distribution
| Font | Style | Share |
|---|---|---|
| Gulmarg Nastaleeq | Nastaliq | 33.3% |
| Noto Nastaliq Urdu | Nastaliq | 33.3% |
| Afan Koshur Naksh | Naskh | 16.7% |
| Narqalam | Naskh | 16.7% |
Usage
Download and Extract using Python
from huggingface_hub import hf_hub_download
import zipfile, os
zip_path = hf_hub_download(
repo_id="Faizaniqbal/Koshur-OCR-Synth",
filename="Kashmiri_OCR_Nastaliq_Naskh_Dataset.zip",
repo_type="dataset"
)
extract_dir = "./koshur_ocr_synth"
os.makedirs(extract_dir, exist_ok=True)
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_dir)
print(f"Extracted to: {extract_dir}")
Loading in PyTorch
import os
from PIL import Image
from torch.utils.data import Dataset
class KoshurOCRDataset(Dataset):
def __init__(self, data_dir, processor=None):
self.data_dir = os.path.join(data_dir, "archive")
self.basenames = sorted(set(
f.rsplit(".", 1)[0] for f in os.listdir(self.data_dir) if f.endswith(".png")
))
self.processor = processor
def __len__(self):
return len(self.basenames)
def __getitem__(self, idx):
base = self.basenames[idx]
image = Image.open(os.path.join(self.data_dir, f"{base}.png")).convert("RGB")
with open(os.path.join(self.data_dir, f"{base}.txt"), encoding="utf-8") as f:
text = f.read().strip()
if self.processor:
px = self.processor(images=image, return_tensors="pt").pixel_values
return {"pixel_values": px.squeeze(), "text": text}
return {"image": image, "text": text}
Recommended Use Cases
- Fine-tuning OCR/Image-to-Text Models: TrOCR, Donut, BLIP-2, PARSeq, PaliGemma for reading Kashmiri Nastaliq scripts.
- Pretraining Stages: Use as a clean synthetic stage before introducing noisy real-world scans.
- Benchmarking: Evaluate Kashmiri diacritic parsing (
ٲ,ہ,گ,ۆ) and normalization pipelines under controlled conditions.
Limitations
- Synthetic only: Font-rendered performance does not guarantee parity with real scanned documents or handwriting.
- Font Diversity: Four fonts are represented; real-world print has wider stylistic variation.
License
Released under the Apache 2.0 License. Free to use, modify, and distribute for commercial or non-commercial purposes.
- Downloads last month
- 45











