GraDeT-HTR: A Resource-Efficient Bengali Handwritten Text Recognition System utilizing Grapheme-based Tokenizer and Decoder-only Transformer
This is the official GitHub repository for GraDeT-HTR: A Resource-Efficient Bengali Handwritten Text Recognition System utilizing Grapheme-based Tokenizer and Decoder-only Transformer.
📢 News: This work has been accepted at the 2025 Conference on Empirical Methods in Natural Language Processing (EMNLP) System Demonstrations.
🔗 Resources:
- 📖 Introduction
- ⚙️ Installation
- 🎓 Training
- 🚀 Inference
- 📧 Request Access to Weights/Synthetic Datasets
- 📝 Citation
Follow these steps to set up the project on your local machine:
git clone https://github.com/mahmudulyeamim/GraDeT-HTR.git
cd GraDeT-HTRIt is recommended to create and activate a virtual environment (e.g., venv or Conda) before installing dependencies.
Install the required packages using pip:
pip install -r requirements.txtNavigate to the BN_DRISHTI directory and clone the YOLOv5 repository:
cd BN_DRISHTI
git clone https://github.com/ultralytics/yolov5After cloning, replace the default detect.py file with the custom version provided in this repository:
cp detect.py yolov5/detect.pyYou can now safely delete the detect.py file from the BN_DRISHTI directory:
rm detect.pyDownload the required pre-trained detection model weights into the model_weights directory:
wget -P model_weights https://huggingface.co/crusnic/BN-DRISHTI/resolve/main/models/line_model_best.pt
wget -P model_weights https://huggingface.co/crusnic/BN-DRISHTI/resolve/main/models/word_model_best.ptDetection model weights provided by: BN-DRISHTI
Note: If you don't have wget installed, you can install it using your package manager (e.g., apt-get install wget on Ubuntu, brew install wget on macOS). Alternatively, you can download the files manually from the links above and place them in the BN_DRISHTI/model_weights directory.
You're all set! The installation is complete.
To train the text recognition model, navigate to the GraDeT_HTR directory and run the train.py file. A sample training dataset is provided to help you test whether the model runs correctly.
Quick Test with Sample Dataset:
cd GraDeT_HTR
python train.pyThis will train the model using the provided sample_train dataset, allowing you to verify that everything is set up properly.
Before running inference, create an input_pages directory in the root of the project.
mkdir input_pagesThen copy your input images (.jpg, .png, etc.) or PDF files into this directory. Sample test files are available in the sample_test directory for quick testing.
To perform inference, run the inference.py with the path to your pre-trained text recognition model weights.
For image inputs:
python inference.py --weights path/to/your/text_recognition_model_weights.pthFor PDF inputs: Add the --pdf true flag
python inference.py --weights path/to/your/text_recognition_model_weights.pth --pdf trueThe inference results will be saved in the output_texts directory (created automatically if it doesn't exist).
To request access to our pre-trained text recognition model weights or synthetic datasets, please email mahmudulyeamim@gmail.com with the following information:
- Your name and institutional affiliation
- Intended purpose and use case
- Brief project description
- Confirmation that you will properly acknowledge and cite this work
Access will be granted upon review of your request.
Important: Pre-trained weights and synthetic datasets are provided strictly for academic and research purposes.
If you use GraDeT-HTR in your research, please cite our paper:
@inproceedings{hasan-etal-2025-gradet,
title = {GraDeT-HTR: A Resource-Efficient Bengali Handwritten Text Recognition System Utilizing Grapheme-based Tokenizer and Decoder-only Transformer},
author = {Hasan, Md. Mahmudul and Choudhury, Ahmed Nesar Tahsin and Hasan, Mahmudul and Khan, Md Mosaddek},
booktitle = {Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},
year = {2025},
pages = {696--706},
publisher = {Association for Computational Linguistics},
url = {https://aclanthology.org/2025.emnlp-demos.52/},
doi = {10.18653/v1/2025.emnlp-demos.52}
}Contact: For questions or issues, please open an issue on this repository or contact mahmudulyeamim@gmail.com