Skip to content

Latest commit

ย 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

เฅฅ เคถเฅเคฐเฅ€ เค—เคฃเฅ‡เคถเคพเคฏ เคจเคฎเคƒ เฅฅ



Typing SVG

Cost Savings ย  Crash Safe ย  Mantra Detection


Quick Start ย ย  Documentation ย ย  Star


Python Gemini EasyOCR UV License

Stars Forks Watchers


OCR-Devnagari Demo

Processing a 1000-page tantric manuscript with crash-safe resume capability




๐ŸŒŸ Why OCR-Devnagari?

๐Ÿ˜ซ The Problem

Ancient Sanskrit and Hindi manuscriptsโ€”tantras, stotras, and sacred textsโ€”are being lost to time. Existing OCR tools:

Issue Impact
โŒ Can't handle complex conjuncts เคธเค‚เคฏเฅเค•เฅเคคเคพเค•เฅเคทเคฐ destroyed
โŒ Destroys mantras เฅ เคนเฅเคฐเฅ€เค‚ เคถเฅเคฐเฅ€เค‚ corrupted
โŒ Costs a fortune $10+ per manuscript
โŒ Crashes lose work Hours of progress gone

๐ŸŽฏ The Solution

OCR-Devnagari combines local OCR speed with Gemini AI accuracy:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                             โ”‚
โ”‚   ๐Ÿ“œ 1000-page Manuscript   โ”‚
โ”‚                             โ”‚
โ”‚   Before: $10+ cost         โ”‚
โ”‚   After:  $1 cost           โ”‚
โ”‚                             โ”‚
โ”‚   โœจ 90% Savings โœจ          โ”‚
โ”‚                             โ”‚
โ”‚   Zero data loss on         โ”‚
โ”‚   crash or interrupt        โ”‚
โ”‚                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜



โœจ Features

Feature Description
๐Ÿ”€ Multi-Engine Support 5 OCR backends to choose from
๐Ÿง  Smart Hybrid Mode EasyOCR + Gemini for optimal results
๐Ÿ•‰๏ธ Mantra Detection Auto-detect and preserve sacred text
โšก High Performance Async concurrent workers
๐Ÿ’พ Crash-Safe Resume from any interruption
๐Ÿ“Š Live Progress Real-time tracking with ETA
๐Ÿ›ก๏ธ Graceful Shutdown Ctrl+C saves all work
๐Ÿงน Memory Efficient Handles 1000+ page PDFs
โœ… Response Validation Rejects invalid OCR results



โšก Quick Start

๐Ÿ“ฆ Installation

# Clone the repository
git clone https://github.com/rajeshkanaka/OCR-Devnagari.git
cd OCR-Devnagari

# Install with UV (recommended)
uv sync && uv pip install easyocr

# Or with pip
pip install -r requirements.txt && pip install easyocr

๐Ÿ”‘ Configure API (for Gemini features)

# Option A: Vertex AI (Recommended for production)
export GOOGLE_CLOUD_PROJECT="your-project"
export GOOGLE_CLOUD_LOCATION="global"
export GOOGLE_GENAI_USE_VERTEXAI=1

# Option B: API Key (Quick setup)
export GEMINI_API_KEY="your-key"

๐Ÿš€ Run!

# ๐Ÿ”ฅ Hybrid mode โ€” 90% savings, maximum accuracy
python -m ocr_hindi ocr manuscript.pdf --pages "all"

# ๐Ÿ†“ 100% FREE local processing
python -m ocr_hindi ocr manuscript.pdf -e easyocr

# ๐Ÿ’Ž Premium Gemini mode for critical documents
python -m ocr_hindi ocr manuscript.pdf -e gemini



๐Ÿ’ฐ Cost Comparison

๐Ÿ’ธ How much can you save?

โŒ Traditional Approach

โœ… With OCR-Devnagari

Metric Value
๐Ÿ“„ Pages 1000
๐Ÿ’ธ Cost ~$10-15
๐Ÿ”„ API Calls 1000
โฑ๏ธ Time ~45 min
๐Ÿ›ก๏ธ On Crash LOSE ALL

โ†’

Metric Value
๐Ÿ“„ Pages 1000
๐Ÿ’ธ Cost ~$1-2
๐Ÿ”„ API Calls ~100-150
โฑ๏ธ Time ~90 min
๐Ÿ›ก๏ธ On Crash Resume โœ“

๐Ÿ† Engine Comparison

Engine Cost Accuracy Speed Best For
๐Ÿ”€ hybrid ~$0.30/1K โญโญโญโญโญ โšกโšกโšก Recommended
๐Ÿ†“ easyocr FREE โญโญโญโญ โšกโšก Budget-conscious
๐Ÿ†“ marker FREE โญโญโญโญโญ โšกโšกโšก Structured PDFs
๐Ÿ†“ tesseract FREE โญโญโญ โšกโšกโšกโšก Simple documents
๐Ÿ’Ž gemini ~$2/1K โญโญโญโญโญ โšกโšกโšกโšก Critical accuracy



๐Ÿ—๏ธ Architecture

"Write once, crash anywhere, resume everywhere"

                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚           ๐Ÿ“„ PDF Input                  โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                  โ”‚
                                                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              ๐Ÿ”€ INTELLIGENT ROUTING                                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                     โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚    โ”‚  hybrid  โ”‚    โ”‚ easyocr  โ”‚    โ”‚  marker  โ”‚    โ”‚tesseract โ”‚    โ”‚  gemini  โ”‚     โ”‚
โ”‚    โ”‚ DEFAULT  โ”‚    โ”‚   FREE   โ”‚    โ”‚   FREE   โ”‚    โ”‚   FREE   โ”‚    โ”‚ PREMIUM  โ”‚     โ”‚
โ”‚    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚         โ”‚                                                                           โ”‚
โ”‚         โ–ผ                                                                           โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚    โ”‚                     ๐Ÿง  HYBRID DECISION ENGINE                           โ”‚      โ”‚
โ”‚    โ”‚                                                                         โ”‚      โ”‚
โ”‚    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚      โ”‚
โ”‚    โ”‚   โ”‚  EasyOCR    โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ โ”‚ Confidence Checkโ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ โ”‚   Mantra    โ”‚   โ”‚      โ”‚
โ”‚    โ”‚   โ”‚    FREE     โ”‚         โ”‚     < 85% ?     โ”‚         โ”‚  Detected?  โ”‚   โ”‚      โ”‚
โ”‚    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚      โ”‚
โ”‚    โ”‚                                    โ”‚                         โ”‚          โ”‚      โ”‚
โ”‚    โ”‚                                    โ–ผ                         โ–ผ          โ”‚      โ”‚
โ”‚    โ”‚                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚      โ”‚
โ”‚    โ”‚                           โ”‚        ๐Ÿ’Ž Gemini 2.0 Flash            โ”‚      โ”‚      โ”‚
โ”‚    โ”‚                           โ”‚   โ€ข thinking_level: "low"             โ”‚      โ”‚     โ”‚
โ”‚    โ”‚                           โ”‚   โ€ข media_resolution: "high"          โ”‚      โ”‚     โ”‚
โ”‚    โ”‚                           โ”‚   โ€ข Token tracking for cost           โ”‚      โ”‚     โ”‚
โ”‚    โ”‚                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚     โ”‚
โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ”‚                                                                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                  โ”‚
                                                  โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              ๐Ÿ›ก๏ธ CRASH-SAFE PIPELINE                                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                                     โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚    โ”‚   OCR    โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚    Cache     โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Progress   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Release    โ”‚      โ”‚
โ”‚    โ”‚ Process  โ”‚     โ”‚ Atomic Write โ”‚     โ”‚   Update     โ”‚     โ”‚   Memory     โ”‚      โ”‚
โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚ page_NNN.txt โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ”‚                     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                                โ”‚
โ”‚                                                                                     โ”‚
โ”‚    On interrupt (Ctrl+C) or crash:                                                  โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚    โ”‚  โœ“ All cached pages preserved    โœ“ Resume skips completed pages         โ”‚      โ”‚
โ”‚    โ”‚  โœ“ No duplicate API charges      โœ“ Output merged from cache             โ”‚      โ”‚ 
โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ”‚                                                                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                  โ”‚
                                                  โ–ผ
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚   ๐Ÿ“ Markdown Output + ๐Ÿ’ฐ Cost Report    โ”‚
                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜



๐Ÿ•‰๏ธ Mantra Detection

Intelligent detection of sacred text patterns ensures mantras are always verified with maximum accuracy


เคฌเฅ€เคœ เคฎเคจเฅเคคเฅเคฐ
Seed Syllables

เฅ    เคนเฅเคฐเฅ€เค‚   เคถเฅเคฐเฅ€เค‚
เค•เฅเคฒเฅ€เค‚   เคเค‚    เคนเฅเค‚

เคฎเคจเฅเคคเฅเคฐ เคธเคฎเคพเคชเฅเคคเคฟ
Sacred Endings

เคธเฅเคตเคพเคนเคพ   เคจเคฎเคƒ   เคซเคŸเฅ
เคตเฅŒเคทเคŸเฅ   เคนเฅเค‚   เค เคƒ

เคถเฅเคฒเฅ‹เค• เคšเคฟเคนเฅเคจ
Verse Markers

เฅฅเฅงเฅฅ  เฅฅเฅจเฅฅ  เฅฅเฅฉเฅฅ
เฅฅ เค‡เคคเคฟ เฅฅ

เคตเคฟเคญเคพเค— เคธเฅ‚เคšเค•
Section Indicators

เคตเคฟเคจเคฟเคฏเฅ‹เค—  เคจเฅเคฏเคพเคธ
เคงเฅเคฏเคพเคจ   เค•เคตเคš



๐Ÿ“– Usage Examples

๐Ÿ”€ Hybrid Mode (Recommended)

# Process entire manuscript with intelligent routing
python -m ocr_hindi ocr sacred_text.pdf --pages "all"

# Adjust confidence threshold (higher = more Gemini verification)
python -m ocr_hindi ocr sacred_text.pdf --confidence 0.90

# Disable mantra verification for faster processing
python -m ocr_hindi ocr sacred_text.pdf --no-verify-mantras

# Process specific page ranges
python -m ocr_hindi ocr sacred_text.pdf --pages "1-100,200-250"

# Use more workers for faster processing
python -m ocr_hindi ocr sacred_text.pdf --workers 10

๐Ÿ†“ Free Local Processing

# EasyOCR โ€” Good Hindi/Devanagari support, no API needed
python -m ocr_hindi ocr book.pdf -e easyocr

# Marker โ€” Best for structured books and PDFs
python -m ocr_hindi ocr book.pdf -e marker

# Tesseract โ€” Fast, requires system installation
python -m ocr_hindi ocr book.pdf -e tesseract

๐Ÿ’Ž Premium Gemini Mode

# Maximum accuracy for critical manuscripts
python -m ocr_hindi ocr rare_manuscript.pdf -e gemini

# With high concurrency
python -m ocr_hindi ocr rare_manuscript.pdf -e gemini --workers 15

๐Ÿ› ๏ธ Utility Commands

# List all available engines with details
python -m ocr_hindi engines

# Validate your setup (dependencies + authentication)
python -m ocr_hindi validate

# View PDF information
python -m ocr_hindi info manuscript.pdf

# Dry run โ€” see what would be processed
python -m ocr_hindi ocr manuscript.pdf --dry-run

# Resume interrupted processing
python -m ocr_hindi ocr manuscript.pdf --resume



โš™๏ธ Configuration

Option Description Default
-e, --engine OCR engine (hybrid, easyocr, marker, tesseract, gemini) hybrid
-p, --pages Page range (all, 1-50, 1,5,10-20) interactive
-w, --workers Concurrent workers (1-20) 5
-c, --confidence Hybrid threshold (0.0-1.0) 0.85
--verify-mantras Verify mantra pages with Gemini true
-r, --resume Resume from previous progress false
-n, --dry-run Preview without processing false
--dpi PDF rendering quality 200



๐Ÿ“ Output Structure

your_manuscript/
โ”œโ”€โ”€ ๐Ÿ“„ manuscript.pdf                        # Original file
โ”œโ”€โ”€ ๐Ÿ“ manuscript_unicode.md                 # โœจ Final output (Devanagari text)
โ”œโ”€โ”€ ๐Ÿ“‹ ocr_manuscript_20240120_143022.log    # Processing log
โ”œโ”€โ”€ ๐Ÿ“Š .ocr_progress_manuscript.json         # Resume state
โ””โ”€โ”€ ๐Ÿ“‚ .ocr_cache_manuscript/                # ๐Ÿ›ก๏ธ Crash-safe cache
    โ”œโ”€โ”€ page_0001.txt                        #    Individual page cache
    โ”œโ”€โ”€ page_0001.meta.json                  #    Page metadata
    โ”œโ”€โ”€ page_0002.txt
    โ””โ”€โ”€ ...



๐Ÿ“Š Performance Benchmarks

Mode 1000 Pages Throughput Cost Notes
๐Ÿ”€ Hybrid ~90 min ~11 ppm ~$1 Best value
๐Ÿ†“ EasyOCR ~120 min ~8 ppm $0 100% free
๐Ÿ†“ Marker ~60 min ~16 ppm $0 Structured PDFs
๐Ÿ’Ž Gemini ~45 min ~22 ppm ~$10 Max accuracy

ppm = pages per minute โ€ข Tested on M1 MacBook Pro with 10 workers




๐Ÿ”ง Troubleshooting

โŒ "poppler not found"
# macOS
brew install poppler

# Ubuntu/Debian
sudo apt-get install poppler-utils

# Windows - Download from:
# https://github.com/oschwartz10612/poppler-windows/releases
โŒ "EasyOCR not installed"
uv pip install easyocr
# or
pip install easyocr
โŒ "Tesseract not installed"
# macOS
brew install tesseract tesseract-lang

# Ubuntu/Debian
sudo apt install tesseract-ocr tesseract-ocr-hin tesseract-ocr-san

# Windows - Download installer from:
# https://github.com/UB-Mannheim/tesseract/wiki
โŒ Authentication errors
# Verify Vertex AI setup
gcloud auth application-default login
gcloud config set project YOUR_PROJECT_ID

# Or use API key instead
export GEMINI_API_KEY="your-api-key-here"

# Test authentication
python -m ocr_hindi validate
โŒ Rate limiting (429 errors)
# Reduce concurrent workers
python -m ocr_hindi ocr book.pdf --workers 3

# The system will automatically retry with exponential backoff
โŒ High memory usage
# Reduce workers (each worker holds images in memory)
python -m ocr_hindi ocr book.pdf --workers 2

# Or process in smaller batches
python -m ocr_hindi ocr book.pdf --pages "1-100"
python -m ocr_hindi ocr book.pdf --pages "101-200" --resume



๐Ÿค Contributing

Contributions are what make the open source community amazing!


๐Ÿ› Bug Reports
Open an Issue

๐Ÿ’ก Feature Ideas
Start a Discussion

๐Ÿ”ง Pull Requests
Fork & Submit PR

๐Ÿ“– Documentation
Help improve docs


# Fork, clone, and create a branch
git clone https://github.com/YOUR_USERNAME/OCR-Devnagari.git
cd OCR-Devnagari
git checkout -b feature/amazing-feature

# Make your changes, then
git commit -m "Add amazing feature"
git push origin feature/amazing-feature

# Open a Pull Request ๐ŸŽ‰



๐Ÿ“œ License

MIT License โ€” Free for personal and commercial use

See LICENSE for details




๐Ÿ™ Acknowledgments

This project stands on the shoulders of giants


Gemini ย  EasyOCR ย  Tesseract ย  Marker



เฅฅ เคธเคฐเฅเคตเฅ‡ เคญเคตเคจเฅเคคเฅ เคธเฅเค–เคฟเคจเคƒ เฅฅ

May all beings be happy


Om



Built with โค๏ธ for the Sanskrit & Vaidik community- by RajeshKanaka


Star



About

Production-grade OCR for Hindi, Sanskrit & Devanagari manuscripts

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages