Python Tamil OCR package
Project description
OCR Tamil
Finetuned version of PARSEQ model on Tamil text. This version of OCR is much more robust to tilted text compared to the Tesseract, Paddle OCR and Easy OCR. This model is work in progress, feel free to contribute!!!
Currently supports two languages (English + Tamil). Accuracy of the model can be improved by adjusting the Text detection model as per your requirements. Achieved the accuracy of around >95% (98% NED) in validation set
OUTPUT
Input Image | OCR TAMIL | Tesseract |
---|---|---|
வாழ்கவளமுடன் | க் க்கஸாரகளள௮ஊகஎளமுடன் | |
ரெடிமேட்ஸ் | NO OUTPUT | |
கோபி | NO OUTPUT | |
தாம்பரம் | NO OUTPUT | |
நெடுஞ்சாலைத் | NO OUTPUT |
Obtained Tesseract results using the huggingface space with Tamil as language
How to USE this repo
Tested using Python 3.10 on Windows Machine
Pip
- Using PIP install
pip install ocr_tamil
- Download the model weights from from the GDRIVE and keep it in the local folder to use in step 4
- Use the below code for text recognition at word level
Text Recognition
from ocr_tamil.ocr import OCR
image_path = r"test_images\1.jpg" # insert your own path here (step 2 file location)
model_path = r"parseq_tamil_v6.ckpt" # add the full path of the model(step 2 file location)
ocr = OCR(tamil_model_path=model_path)
texts = ocr.predict(image_path)
with open("output.txt","w",encoding="utf-8") as f:
f.write(texts)
>>>> நெடுஞ்சாலைத்
Text Detect + Recognition
from ocr_tamil.ocr import OCR
image_path = r"test_images\0.jpg" # insert your own path here
model_path = r"parseq_tamil_v6.ckpt" # add the full path of the parseq model
text_detect_model = "craft_mlt_25k.pth" # add the full path of the craft model
ocr = OCR(detect=True,tamil_model_path=model_path,detect_model_path=text_detect_model)
texts = ocr.predict(image_path)
with open("output.txt","w",encoding="utf-8") as f:
f.write(texts)
>>>> கொடைக்கானல் Kodaikanal
Github
-
Clone the repository
-
Pip install the required modules using
pip install -r requirements.txt
-
Download the models weights from the GDRIVE and keep it under model_weights
|___model_weights |_____craft_mlt_25k.pth |_____parseq_tamil_v6.ckpt
-
Run the below code by providing the path
Text Recognition
from ocr_tamil.ocr import OCR
image_path = r"test_images\1.jpg" # insert your own path here
ocr = OCR()
texts = ocr.predict(image_path)
with open("output.txt","w",encoding="utf-8") as f:
f.write(texts)
>>>> நெடுஞ்சாலைத்
Text Detect + Recognition
from ocr_tamil.ocr import OCR
image_path = r"test_images\0.jpg" # insert your own path here
ocr = OCR(detect=True)
texts = ocr.predict(image_path)
with open("output.txt","w",encoding="utf-8") as f:
f.write(texts)
>>>> கொடைக்கானல் Kodaikanal
LIMITATIONS
Unable to read the text if they are present in rotated forms
Thanks to the below contibuters for making awesome Text detection and text recognition models
Text detection - CRAFT TEXT DECTECTION
Text recognition - PARSEQ
@InProceedings{bautista2022parseq,
title={Scene Text Recognition with Permuted Autoregressive Sequence Models},
author={Bautista, Darwin and Atienza, Rowel},
booktitle={European Conference on Computer Vision},
pages={178--196},
month={10},
year={2022},
publisher={Springer Nature Switzerland},
address={Cham},
doi={10.1007/978-3-031-19815-1_11},
url={https://doi.org/10.1007/978-3-031-19815-1_11}
}
@inproceedings{baek2019character,
title={Character Region Awareness for Text Detection},
author={Baek, Youngmin and Lee, Bado and Han, Dongyoon and Yun, Sangdoo and Lee, Hwalsuk},
booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
pages={9365--9374},
year={2019}
}
CITATION
@InProceedings{GnanaPrasath,
title={Tamil OCR},
author={Gnana Prasath D},
month={01},
year={2024},
url={https://github.com/gnana70/tamil_ocr}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ocr_tamil-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ee4167350da6ef00e2dccec8564d729f3c0505f02cfaa7262b05685185d0736 |
|
MD5 | 9b25ffa18238d5c9bb8c4673171e3916 |
|
BLAKE2b-256 | 7e1a3a345c7c4ec30f4c0227a6fac300596e69a6aa9cefc8ef7019bb0769eb8f |