Skip to content

das-projects/deepOCR

Repository files navigation

DeepOCR

Paper Conference

CI testing

Description

This is an Optical Character Recognition Library with the ability to train and deploy Deep Neural Network models to a Streamlit Web application. The base library in written using PyTorch and PyTorch-Lightning, while the dashboard was developed using the Streamlit library.

How to run

First, install dependencies

# clone deepOCR   
git clone https://github.com/das-projects/deepOCR

# install deepOCR   
cd deepOCR 
pip install -e .  
sudo apt-get install fonts-freefont-ttf -y 

Streamlit Webapp

Next, try out the streamlit dashboard for a demonstration

# demo folder
cd deepOCR
# run demo
streamlit run demo/app.py    

Python code API

This project is setup as a package which means you can now easily import any file into any other file:

# Download an example image
wget https://eforms.com/download/2019/01/Cash-Payment-Receipt-Template.pdf
import matplotlib.pyplot as plt

from deepocr.io import DocumentFile
from deepocr.models import ocr_predictor

# Load the pdf file
doc = DocumentFile.from_pdf("Cash-Payment-Receipt-Template.pdf").as_images()
print(f"Number of pages: {len(doc)}")

# Use the predictor object to detect and recognize text
predictor = ocr_predictor(pretrained=True)

# show the predictor output!
result = predictor(doc)
result.show(doc)

# Use synthesize method to regenerate the image in a desired format 
synthetic_pages = result.synthesize()
plt.imshow(synthetic_pages[0]); plt.axis('off'); plt.show()

Models architecture reference

Text Detection

Text Recognition

Citation

@article{Arijit Das, Raphael Kronberg
  title={deep OCR: Optical Character Recognition with Deep Learning},
  author={Arijit Das, Raphael Kronberg},
  journal={https://github.com/das-projects/deepOCR},
  year={2022}
}

About

Optical Character Recognition using Deep Learning

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages