Creating and deploying an OCR in Python

Arsh Anwar
3 min readOct 15, 2022

--

OCR is an abbreviation for Optical Character Recognition. OCR is used for converting images of text into machine-encoded text.

It is a process of converting images of typed, handwritten, or printed text into machine-encoded text, whether from a scanned document, a photo of a document, a scene photo (for example the text on signs and billboards in a landscape photo), or from subtitle text superimposed on an image (for example from a television broadcast).

OCR is used in a variety of applications such as scanning documents, reading text in images, and converting images to text. OCR is also used in the field of document management, where it is used to convert scanned documents into machine-encoded text, which can be searched, indexed, archived, and retrieved.

In Today’s blog, we are going to create an Optical Character Recognizer and going to deploy it as an Interactive Gradio web app using TrueFoundry.

Let’s Start

Key Take Aways

  • We are going to learn about creating an OCR using EasyOCR
  • Creating an Interactive Gradio App
  • Deploying it on TrueFoundry as a Service using TrueFoundry Webapp.

Pre-Requisite

  • Willingness to learn
  • Clone this repo

Installing Requirements

pip install -r requirements.txt

Creating OCR function

Here, we are using EasyOCR’s readtext method.

Creating Gradio App

Test Drive

The app will run on http://localhost:8080/

Now our code is ready, we are going to deploy it using TrueFoundry

Deployment

Logging into TrueFoundry

Heading to Deployment Section

1. Creating a new deployment

2. Select the Service option and Workspace name

3. Fill out the properties and submit

4. Deploying

5. Successful Deployment

6. Final Thoughts

After the deployment will be done, you will be able to use the Gradio App.

The model is deployed here: https://ocr-app-arsh-dev.tfy-ctl-euwe1-develop.develop.truefoundry.tech/

Video

Code

The above code is also present in my Repository

References:

  1. TrueFoundry: https://truefoundry.com/
  2. TrueFoundry App: https://app.truefoundry.com/
  3. TrueFoundry Docs: http://docs.truefoundry.com/
  4. Code: https://github.com/d4rk-lucif3r/OCR-with-gradio-App

--

--

Arsh Anwar

AI/ML expert. Built LuciferML (100k+ downloads). Co-founder @Revca, building smart solutions for a sustainable future.