Extract โข Clean โข Interpret
Responsive Web Application for Desktop and Mobile Devices
AYUSH Habba is an AI-powered web application designed to digitize and interpret Ayurvedic Sanskrit shlokas from scanned images. The system combines Optical Character Recognition (OCR) with Large Language Models (LLMs) to extract Sanskrit text, perform Sanskrit-aware post-processing, reconstruct complete shlokas, and generate structured English interpretations.
Unlike conventional OCR systems that only extract text, AYUSH Habba performs domain-specific processing by identifying Sanskrit content, reconstructing complete verses, and providing contextual Ayurvedic explanations.
The application is built with a responsive user interface, allowing users to access the platform seamlessly from both desktop/laptop and mobile devices.
-
๐ท Upload scanned images containing Ayurvedic Sanskrit shlokas
-
๐ OCR using Tesseract OCR with the Sanskrit language model (
san.traineddata) -
๐งน Sanskrit-aware OCR post-processing
-
๐ Automatic reconstruction of complete shlokas
-
๐ค AI-powered interpretation using Google Gemini 2.5 Pro
-
๐ฟ Generates structured Ayurvedic information including:
- Simple Meaning
- Dosha Involved
- Clinical Context
- Classical Source (when identifiable)
- Key Sanskrit Terms with explanations
-
๐ฑ๐ป Responsive web application compatible with desktop, laptop, and mobile devices
-
โก REST API built with FastAPI
-
๐ OCR evaluation using Character Error Rate (CER)
Scanned Sanskrit Image
โ
โผ
Tesseract OCR (san.traineddata)
โ
โผ
Raw OCR Extraction
โ
โผ
Sanskrit-aware Text Cleaning
โ
โผ
Shloka Reconstruction
โ
โผ
Google Gemini 2.5 Pro
โ
โผ
Structured English Interpretation
โ
โผ
FastAPI Backend API
โ
โผ
Responsive Web Application
ayush_habba/
โ
โโโ backend/
โ โโโ main.py # FastAPI application
โ โโโ ocr.py # OCR pipeline
โ โโโ cleaning.py # Sanskrit-aware text cleaning
โ โโโ translate.py # Gemini integration
โ โโโ requirements.txt
โ
โโโ dataset/
โ โโโ images/ # Sample Sanskrit shloka images
โ
โโโ other/
โ โโโ evaluate_ocr.py # OCR evaluation script
โ โโโ evaluation.txt # Ground truth dataset
โ โโโ ocr_results.csv
โ โโโ no_post_op_ocr_results.csv
โ
โโโ README.md
โโโ .gitignore
- Python
- FastAPI
- Tesseract OCR
- Sanskrit Language Model (
san.traineddata) - Pillow
- Google Gemini 2.5 Pro
- Prompt Engineering
- Requests
- BeautifulSoup4
- RapidFuzz
- python-dotenv
The user uploads a scanned image containing one or more Ayurvedic Sanskrit shlokas.
โ
The uploaded image is converted to PNG format and processed using Tesseract OCR with the Sanskrit language model.
The OCR pipeline includes:
- Automatic image conversion
- Sanskrit OCR (
san) - Multiple Page Segmentation Modes (PSM 6 and PSM 7)
- Automatic fallback when OCR quality is insufficient
โ
The extracted text undergoes domain-specific post-processing to improve OCR quality.
This stage:
- Filters non-Sanskrit lines
- Removes OCR artifacts and unwanted symbols
- Preserves Sanskrit punctuation (
เฅคandเฅฅ) - Normalizes whitespace
- Maintains verse structure
โ
Individual OCR lines are grouped into complete Sanskrit shlokas using the verse delimiter (เฅฅ).
โ
Each reconstructed shloka is processed using Google Gemini 2.5 Pro, which generates:
- Simple English meaning
- Dosha involved
- Clinical context
- Classical source (if identifiable)
- Explanation of important Sanskrit terminology
โ
The FastAPI backend returns:
- Raw OCR text
- Cleaned Sanskrit text
- Reconstructed shlokas
- Structured AI interpretation
The information is then displayed through a responsive web interface optimized for desktop and mobile devices.
GET /{
"message": "AYUSH OCR backend is running"
}POST /ocrMultipart Form Data
| Parameter | Type | Description |
|---|---|---|
| file | Image | Sanskrit shloka image |
Supported formats:
- PNG
- JPG
- JPEG
{
"filename": "sample.png",
"raw_ocr_text": "...",
"cleaned_sanskrit_text": "...",
"shlokas": [
"..."
],
"translations": [
{
"sanskrit": "...",
"translation": {
"english": "...",
"source": "gemini"
}
}
]
}git clone https://github.com/poorvijn/ayush_habba.git
cd ayush_habba/backendpython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtInstall Tesseract OCR on your system and ensure that the Sanskrit language model (san.traineddata) is available in the tessdata directory.
Verify the installation:
tesseract --versionCreate a .env file inside the backend directory.
GEMINI_API_KEY=YOUR_GEMINI_API_KEYuvicorn main:app --reloadThe backend will start at:
http://127.0.0.1:8000
Swagger API documentation:
http://127.0.0.1:8000/docs
The repository includes an OCR evaluation framework for measuring recognition accuracy.
The evaluation pipeline:
- Uses manually annotated Sanskrit ground-truth text
- Runs OCR on each image
- Computes Character Error Rate (CER) using Levenshtein Distance
- Generates CSV reports for analysis
Evaluation resources:
other/
โโโ evaluate_ocr.py
โโโ evaluation.txt
โโโ ocr_results.csv
โโโ no_post_op_ocr_results.csv
This framework enables quantitative assessment of OCR performance and the effectiveness of Sanskrit-aware post-processing.
The repository contains a curated dataset of scanned Ayurvedic Sanskrit shlokas used for development and OCR evaluation.
The dataset includes:
- Single-line Sanskrit verse images
- Multi-line Sanskrit shlokas
- Ground-truth Sanskrit annotations
- OCR evaluation resources
- Support for handwritten Sanskrit manuscripts
- Batch image processing
- PDF document support
- Translation into additional languages
- Improved explanation of Ayurvedic concepts
- Retrieval-Augmented Generation (RAG) over classical Ayurvedic literature
- Cloud deployment
- Enhanced OCR accuracy through fine-tuning
Contributions are welcome.
- Fork the repository.
- Create a feature branch.
git checkout -b feature-name- Commit your changes.
git commit -m "Add feature"- Push the branch.
git push origin feature-name- Open a Pull Request.
This project is intended for educational and research purposes.
Developed as part of the AYUSH Habba project.
Contributors
- Poorvi J. Nayak
- Sriveda Aithaal
- Vibhuti Kalekar
- Sharanya Rao
- Delita Tauro
- Google Gemini API
- Tesseract OCR
- FastAPI
- Python Open Source Community
- Classical Ayurvedic Literature
โญ If you found this project useful, consider giving the repository a star!