CoolFace
Apppublic

frkhan/bangla-ocr

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐Ÿ‡ง๐Ÿ‡ฉ Bangla OCR Web App with Gradio & EasyOCR

This project is a lightweight Optical Character Recognition (OCR) web application built using Gradio and EasyOCR. It allows users to upload images containing Bangla or English text and extract it instantly through a simple browser interface. Designed for fast deployment and minimal setup, it runs locally, in Docker, or via Docker Compose.


๐Ÿš€ Features

  • โ€”๐Ÿ“ท Upload or drag-and-drop images for OCR.
  • โ€”๐Ÿ” Extract both Bangla and English text using EasyOCR.
  • โ€”โšก GPU-accelerated for fast inference (if a compatible GPU and CUDA are available).
  • โ€”๐ŸŒ Launch a user-friendly web interface with Gradio.
  • โ€”๐Ÿณ Full support for containerized deployment with Docker and Docker Compose.
  • โ€”๐Ÿงผ Clean UI with dual output: extracted text and processing duration.

๐Ÿ”— Live Demo

  • โ€”Live App: Try it out here: [Bangla OCR Demo App](https://huggingface.co/spaces/frkhan/bangla-ocr)
  • โ€”Project Story: Curious about how this app was built? [Read the full story on Medium](https://frkhan.medium.com/turning-pages-into-pixels-the-making-of-a-bangla-ocr-app-9022bbffcd60) to see the journey from idea to deployment.

๐Ÿงฐ Tech Stack

ToolPurpose
GradioWeb interface for user input
EasyOCRText extraction from images
OpenCVImage processing backend for EasyOCR
NumPyArray manipulation
LangfuseObservability and tracing
DockerContainerized deployment
Docker ComposeService orchestration
PyTorchBackend for EasyOCR

๐Ÿ“ฆ Installation

You can run the app in three different ways:

๐Ÿ”ง Option 1: Local Setup

  1. 1.Clone the repository:
bash
    git clone https://github.com/KI-IAN/bangla-ocr-app
    cd bangla-ocr-app
  1. 1.Create and activate a virtual environment: A virtual environment isolates the project's dependencies from your system's global Python packages.
bash
    # Create the virtual environment (you only need to do this once per project)
    # On some systems, you might need to use `python3` instead of `python`
    python -m venv venv

Next, activate the environment. The command depends on your operating system:

  • โ€”On Windows (Command Prompt / PowerShell):
bash
        venv\Scripts\activate
  • โ€”On macOS / Linux (bash, zsh, etc.):
bash
        source venv/bin/activate

Your terminal prompt should now change to show `(venv)` at the beginning.

  1. 1.Install dependencies: With the virtual environment active, install the required packages.
bash
    pip install -r requirements.txt
  1. 1.Launch the app:
bash
    python app.py

The app will be running at http://127.0.0.1:12300.

(When you're finished, you can leave the virtual environment by simply running the `deactivate` command.)

๐Ÿณ Option 2: Docker

  1. 1.Build the Docker image:
bash
    docker build -t bangla-ocr-app .
  1. 1.Run the container:
bash
    docker run -p 12300:7860 bangla-ocr-app

Open your browser and visit: http://localhost:12300

๐Ÿงฑ Option 3: Docker Compose

bash
# To Run in Live environment. It automatically uses the docker-compose.yml
docker-compose up --build 

# Or If you use the latest docker compose command, use the following

docker compose up --build

Access the app at http://localhost:12300


bash
# To Run in local environment use docker-compose.dev.yml if you want to reflect your code changes without rebuilding docker container
docker-compose -f docker-compose.dev.yml up --build

# Or If you use the latest docker compose command, use the following
docker compose -f docker-compose.dev.yml up --build

Access the app at http://localhost:12300


๐Ÿ–ผ๏ธ Example

Upload an image containing Bangla or English text.

Example Input:

(Note: Replace with a link to an actual example image.)

Example Output:

text
Extracted Text:
"เฆฌเฆพเฆ‚เฆฒเฆพ เฆญเฆพเฆทเฆพ เฆ†เฆฎเฆพเฆฆเง‡เฆฐ เฆ—เฆฐเงเฆฌเฅค"

โฑ๏ธ Time taken: 0.87 seconds

๐Ÿ“ File Structure

text
bangla-ocr-app/
โ”œโ”€โ”€ app.py                  # Main application logic
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ Dockerfile              # Container setup
โ”œโ”€โ”€ docker-compose.yml      # Multi-container orchestration for production
โ”œโ”€โ”€ docker-compose.dev.yml  # Multi-container orchestration for development
โ”œโ”€โ”€ .env                    # Environment variables for Langfuse (Optional)
โ””โ”€โ”€ README.md               # Project documentation

๐ŸŒ Language Support

EasyOCR supports over 80 languages. This app is pre-configured for:

  • โ€”๐Ÿ‡ง๐Ÿ‡ฉ Bangla (bn)
  • โ€”๐Ÿ‡บ๐Ÿ‡ธ English (en)

To add more languages, modify the following line in app.py:

python
# From
reader = easyocr.Reader(['bn', 'en'], gpu=True)

# To (for example, adding Hindi, Arabic, Urdu, Malay, Chinese, and Japanese)
reader = easyocr.Reader(['bn', 'en', 'hi', 'ar', 'ur', 'ms', 'ch_sim', 'ja'], gpu=True)

๐Ÿ“œ License

This project is open-source and distributed under the [MIT License](https://opensource.org/licenses/MIT). Feel free to use, modify, and distribute it with attribution.


๐Ÿค Acknowledgements

  • โ€”[EasyOCR](https://github.com/JaidedAI/EasyOCR) for its powerful and accessible multilingual OCR library.
  • โ€”[Gradio](https://www.gradio.app/) for making it incredibly simple to create machine learning interfaces.
  • โ€”[PyTorch](https://pytorch.org/) for powering the deep learning backend.
  • โ€”[Docker](https://www.docker.com) โ€” Containerization platform for reproducible deployment across environments.
  • โ€”[Hugging Face Spaces](https://huggingface.co/spaces) โ€” Free hosting platform for ML demos with secret management and GPU support.
  • โ€”[Langfuse](https://langfuse.com/) for providing excellent observability tools.
โ€œSmall tools, big impact.โ€ โ€” Letโ€™s make machine learning approachable, one project at a time.