Ir para o conteúdo
ModelListadosExterno
Baixar

KHLR

A DenseNet121-Transformer Architecture with Constrained Synthetic Line Generation

TipoText modelVersãoCnota

Fonte do modelo

Tipo
Text model
Tamanho do arquivo
54,3 MB
Versão
vmodel
Atualizado
23 de out. de 2026
Downloads
0
Fonte
Hugging Face

Descrição da fonte

KHLR: Kurdish Handwritten Line Recognition

A DenseNet121-Transformer Architecture with Constrained Synthetic Line Generation

This repository contains the source code, trained models, and vocabularies for Kurdish handwritten line recognition, with cross-dataset generalization to Arabic (KHATT) and Urdu (PUCIT) handwritten datasets.


Repository Structure

KHLR/
├── Kurdish-HLR-Model/      # Best Kurdish model (safetensors + config)
├── Arabic-HLR-Model/         # Fine-tuned on KHATT Arabic dataset
├── Urdu-HLR-Model/           # Fine-tuned on PUCIT Urdu dataset
├── Scripts/
│   ├── train.py                # Main training script
│   ├── synthetic_line_generator.py  # Recipe-based synthetic line generation
│   └── inference.py            # Single image / batch inference
├── Sample/
│   ├── sample_image.tif        # Example handwritten line image
│   └── sample_image.txt        # Corresponding ground truth
├── requirements.txt
└── README.md

Architecture

ComponentDetails
CNN BackboneDenseNet-121 (ImageNet pre-trained)
Encoder3 Transformer encoder layers
Decoder3 Transformer decoder layers
Attention Heads8
Hidden Size256
Feed-Forward Dim1024
Total Parameters~12.8M

Performance

Kurdish (DASTNUS)

ConfigurationCERWERCRR (%)
+AA+SKHL+FHL-500.05930.308394.07
+AA+SKHL+FHL-50 + 8-gram LM0.05340.274694.66

Cross-Dataset Generalization

DatasetLanguageCERWERCRR (%)
KHATTArabic0.11350.415688.65
PUCITUrdu0.09320.279990.68

Installation

git clone https://huggingface.co/karez/KHLR
cd KHLR
pip install -r requirements.txt

Quick Start

Inference

# Single image (using .pth checkpoint)
python Scripts/inference.py \
    --image Sample/sample_image.tif \
    --model_path Kurdish-HLR-Model/model.safetensors \
    --vocab_path Kurdish-HLR-Model/vocab.json

# Directory of images
python Scripts/inference.py \
    --image_dir ./test_images \
    --model_path Kurdish-HLR-Model/model.safetensors \
    --vocab_path Kurdish-HLR-Model/vocab.json

Training

# Basic training (unique handwritten lines only)
python Scripts/train.py \
    --data_dir ./data/DASTNUS \
    --vocab_path Kurdish-HLR-Model/vocab.json

# Full training with synthetic lines + writer mixing (best configuration)
python Scripts/train.py \
    --data_dir ./data/DASTNUS \
    --vocab_path Kurdish-HLR-Model/vocab.json \
    --use_synthetic \
    --synthetic_dir ./data/Synthetic-Lines \
    --use_writer_mixing \
    --fixed_lines_dir ./data/Fixed-Lines \
    --num_writers 50

Synthetic Line Generation

python Scripts/synthetic_line_generator.py \
    --unique_words_dir ./data/Unique-Words \
    --person_names_dir ./data/Person-Names \
    --output_dir ./data/Synthetic-Lines \
    --training_writers ./writers/Training.txt \
    --validation_writers ./writers/Validation.txt \
    --testing_writers ./writers/Testing.txt

Models

ModelLanguageVocabularyFormat
Kurdish-HLR-ModelKurdish (Sorani)114 tokenssafetensors
Arabic-HLR-ModelArabic192 tokens (unified)safetensors
Urdu-HLR-ModelUrdu192 tokens (unified)safetensors

The Arabic and Urdu models use a triple unified vocabulary (Kurdish + Arabic + Urdu) enabling cross-script transfer learning.

Dataset

The models were trained using the following subsets of the DASTNUS Kurdish handwritten dataset:

Data SourceTrainingValidationTesting
Unique handwritten lines3,575655649
Synthetic handwritten lines3,762--
Fixed-content lines (50 writers)512--
Total7,849655649

The data used in this research is available upon request for non-commercial scientific research purposes only.

Citation

[Hamad, K. A. and Shareef, S. M. (2026) “Kurdish Handwritten Text Recognition:
A DenseNet121-Transformer Architecture with Constrained Synthetic Line Generation”,
ARO-THE SCIENTIFIC JOURNAL OF KOYA UNIVERSITY, 14(1), pp. 404–415. doi: 10.14500/aro.12820.]

License

This repository is released for non-commercial scientific research purposes only.

Fontes

1 fonte
Hugging FacePrimárioVersão eec87c9d2b7156b404d878569e3149cb3c254ddb
huggingface.co/Karez/KHLR/tree/eec87c9d2b7156b404d878569e3149cb3c254ddb

Verificado 23 de out.

Artefatos de modelo

1 artefato

Arabic-HLR-Model/model.safetensors

safetensors · 54,3 MB · SHA-256 e82440e516fc…011e · Hugging Face

Baixar

Trechos de fonte

2 trechos

--- language: - ckb - ar - ur license: cc-by-nc-4.0 tags: - handwritten-text-recognition - kurdish - arabic - urdu - densenet - transformer - pytorch - safetensors datasets: - DASTNUS - KHATT - PUCIT metrics: - cer - wer pipeline_tag: image-to-text --- # KHLR: Kurdish Handwritten Line Recognition **A DenseNet121-Transformer Architecture with Constrained Synthetic Line Generation** This repository contains the source code, trained models, and vocabularies for Kurdish handwritten line recognition, with cross-dataset generalization to Arabic (KHATT) and Urdu (PUCIT) handwritten datasets. --- ## Repository Structure ``` KHLR/ ├── Kurdish-HLR-Model/ # Best Kurdish model (safetensors + config) ├── Arabic-HLR-Model/ # Fine-tuned on KHATT Arabic dataset ├── Urdu-HLR-Model/ # Fine-tuned on PUCIT Urdu dataset ├── Scripts/ │ ├── train.py # Main training script │ ├── synthetic_line_generator.py # Recipe-based synthetic line generation │ └── inference.py # Single image / batch inference ├── Sample/ │ ├── sample_image.tif # Example handwritten line image │ └── sample_image.txt # Corresponding ground truth ├── requirements.txt └── README.md ``` ## Architecture | Component | Details | |-----------|---------| | CNN Backbone | DenseNet-121 (ImageNet pre-trained) | | Encoder | 3 Transformer encoder layers | | Decoder | 3 Transformer decoder layers | | Attention Heads | 8 | | Hidden Size | 256 | | Feed-Forward Dim | 1024 | | Total Parameters | ~12.8M | ## Performance ### Kurdish (DASTNUS) | Configuration | CER | WER | CRR (%) | |--------------|-----|-----|---------| | +AA+SKHL+FHL-50 | 0.0593 | 0.3083 | 94.07 | | +AA+SKHL+FHL-50 + 8-gram LM | 0.0534 | 0.2746 | 94.66 | ### Cross-Dataset Generalization | Dataset | Language | CER | WER | CRR (%) | |---------|----------|-----|-----|---------| | KHATT | Arabic | 0.1135 | 0.4156 | 88.65 | | PUCIT | Urdu | 0.0932 | 0.2799 | 90.68 | ## Installation ```bash git clone https://huggingface.co/karez/KHLR cd KHLR pip install -r requirements.txt ``` ## Quick Start ### Inference ```bash # Single image (using .pth checkpoint) python Scripts/inference.py \ --image Sample/sample_image.tif \ --model_path Kurdish-HLR-Model/model.safetensors \ --vocab_path Kurdish-HLR-Model/vocab.json # Directory of images python Scripts/inference.py \ --image_dir...

Source context: 0 downloads · 1 likes · Pipeline image-to-text · Repo Karez/KHLR