A custom deep learning OCR system for recognizing Urdu text from images,
featuring CUDA-accelerated training, custom character vocabulary, and training visualization.
Urdu OCR tackles one of the more challenging problems in optical character recognition — recognizing Urdu script, which is written right-to-left with connected characters and context-dependent glyph shapes. This system uses a deep learning approach with CUDA-accelerated training to build a model capable of recognizing Urdu text from image inputs.
The project includes a complete training pipeline, custom character-to-index vocabulary mapping, and training history visualization to monitor model convergence.
┌──────────┐ ┌──────────────────┐ ┌──────────────┐ ┌──────────────┐
│ Input │───▶│ Preprocessing │───▶│ Deep Learning│───▶│ Recognized │
│ Image │ │ & Augmentation │ │ OCR Model │ │ Urdu Text │
└──────────┘ └──────────────────┘ └──────────────┘ └──────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────────┐
│ Dataset │ │ Training History │
│ (.tsv) │ │ Visualization │
└──────────────┘ └──────────────────┘
- Urdu Script Recognition — Handles right-to-left text, connected characters, and context-dependent glyph shapes
- CUDA Acceleration — GPU-accelerated training for faster model convergence (
cuda.pyfor device verification) - Custom Vocabulary — Character-to-index mapping designed specifically for Urdu script
- Training Visualization — Auto-generated training history plots to monitor loss and accuracy curves
- TSV Dataset Format — Uses structured
final_main_dataset.tsvfor image-text pair management - Audio Model Integration — Extended pipeline with audio model training capability
The training pipeline generates visualization of model convergence:
| Component | Technology |
|---|---|
| Language | Python |
| Deep Learning | PyTorch |
| GPU Acceleration | CUDA |
| Data Processing | Pandas |
| Dataset | Custom Urdu script TSV (image-text pairs) |
URDU-OCR/
├── TRAIN.py # Main training script (20KB — full pipeline)
├── cuda.py # CUDA device verification
├── final_main_dataset.tsv # Training dataset (image-text pairs)
├── audio_training_history.png # Training convergence visualization
└── README.md
# Clone the repository
git clone https://github.com/rafay-byte/URDU-OCR.git
cd URDU-OCR
# Verify CUDA availability
python cuda.py
# Train the OCR model
python TRAIN.pyThe training data is stored in final_main_dataset.tsv (~5MB), containing image-text pairs for Urdu script recognition. Each entry maps an image to its corresponding Urdu text transcription.
Contributions, issues, and feature requests are welcome. Feel free to check the issues page or submit a pull request.
This project is provided as-is for educational, research, and development purposes.
