This repository contains code for 2 projects:
- Arabic Calligraphy Style Recognition (ACSR) : Detect the style of the arabic calligraphy, this work is deeply inspired by the work of ARBML, a demo is available here : HuggingFace space
- Arabic Calligraaphy OCR : recognize the text of the arabic calligraphy
Import the calliar repository into your project, by executing the bash script as follows :
bash get_calliar.sh
The script initialises the git submodules, updates it. Then extracts the dataset.
To get images for individual characters, you can use the following command :
cd scripts
python3 prepare_calliar.py --level words
Fonts: Aref Ruqaa - Iran Nastaliq https://paperswithcode.com/dataset/rufa https://mhmoodlan.github.io/blog/arabic-font-classification To get the data, execute the bash script as follows :
cd data
get_rufa_dataset.sh
Fonts: (40)
Execute the bash script as follows :
cd data
bash get_adab_dataset.sh
First
$ cd scripts/trocr
Then, one of the following tasks can be executed for (chars, words, sentences) :
$ python3 train.py --level chars --test_size 0.1 --num_beams 4 --limit_eval 256 --per_device_train_batch_size 32 --per_device_eval_batch_size 16 --gradient_accumulation_steps 2
$ python3 train.py --level words --test_size 0.1 --num_beams 4 --limit_eval 256 --per_device_train_batch_size 32 --per_device_eval_batch_size 16 --gradient_accumulation_steps 2
$ python3 train.py --level sentences --test_size 0.1 --num_beams 4 --limit_eval 256 --per_device_train_batch_size 32 --per_device_eval_batch_size 16 --gradient_accumulation_steps 2