frkhan/bangla-ocr
๐ง๐ฉ 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
๐ฆ Installation
You can run the app in three different ways:
๐ง Option 1: Local Setup
- Clone the repository:
git clone https://github.com/KI-IAN/bangla-ocr-app
cd bangla-ocr-app- Create and activate a virtual environment: A virtual environment isolates the project's dependencies from your system's global Python packages.
# 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 venvNext, activate the environment. The command depends on your operating system:
- On Windows (Command Prompt / PowerShell):
venv\Scripts\activate- On macOS / Linux (bash, zsh, etc.):
source venv/bin/activateYour terminal prompt should now change to show `(venv)` at the beginning.
- Install dependencies: With the virtual environment active, install the required packages.
pip install -r requirements.txt- Launch the app:
python app.pyThe 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
- Build the Docker image:
docker build -t bangla-ocr-app .- Run the container:
docker run -p 12300:7860 bangla-ocr-appOpen your browser and visit: http://localhost:12300
๐งฑ Option 3: Docker Compose
# 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 --buildAccess the app at http://localhost:12300
# 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:
Extracted Text:
"เฆฌเฆพเฆเฆฒเฆพ เฆญเฆพเฆทเฆพ เฆเฆฎเฆพเฆฆเงเฆฐ เฆเฆฐเงเฆฌเฅค"
โฑ๏ธ Time taken: 0.87 seconds๐ File Structure
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:
# 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.
