--- language: - ar license: cc-by-nc-4.0 tags: - handwritten-text-recognition - paragraph-recognition - ar - densenet - transformer - pytorch - safetensors datasets: - KHATT metrics: - cer - wer pipeline_tag: image-to-text --- # KHATT-Arabic: DenseNet121-Transformer Paragraph HTR ## Model Description Arabic handwritten paragraph recognition model evaluated on the KHATT dataset for cross-script generalisation accessed through: https://www.kaggle.com/datasets/iraqyomar/khatt-arabic-hand-written-lines/code. Pre-trained on 12,000 synthetic paragraphs combining KHATT Arabic lines with Kurdish lines from DASTNUS, then fine-tuned on 1,193 reconstructed KHATT paragraphs. Achieves CER of 0.1394, surpassing a reimplemented state-of-the-art baseline under identical conditions. ## Architecture - **CNN Backbone:** DenseNet-121 (pretrained on ImageNet) - **Horizontal Upsample:** Yes - **Encoder:** 3 Transformer encoder layers - **Decoder:** 6 Transformer decoder layers - **Attention Heads:** 8 - **Hidden Size:** 256 - **Feed-Forward Dim:** 2048 - **Vocabulary Size:** 143 - **Parameters:** 22,760,778 ## Performance on KHATT | Metric | Value | |--------|-------| | CER (greedy) | 0.1394 | | WER (greedy) | 0.5075 | ## Input Format - **Image size:** 600 x 1235 pixels - **Preprocessing:** Aspect-ratio-preserving resize, right-aligned on white canvas (RTL) - **Normalization:** ImageNet mean/std ## Training - **Pre-training:** 12,000 synthetic paragraph images with curriculum learning - **Fine-tuning:** Real handwritten paragraphs from KHATT - **Two-stage strategy:** Encoder frozen for first 10 epochs during fine-tuning ## Usage ```python from safetensors.torch import load_file import json # Load model weights state_dict = load_file("model.safetensors") # Load config with open("config.json", "r") as f: config = json.load(f) # Load vocabulary with open("vocab.json", "r") as f: vocab = json.load(f) # Load reverse mapping with open("idx_to_char.json", "r") as f: idx_to_char = json.load(f) ``` ## Citation ``` [Citation to be added upon publication] ``` ## License This model is released under CC-BY-NC-4.0 for non-commercial research purposes only.