Skip to content

A Flask-based web application that digitizes and interprets historical handwritten documents using the Gemini AI API

Notifications You must be signed in to change notification settings

hari7261/Image-DocumentAnalyzerOCR

Repository files navigation

Historical Document Interpreter 📜🔍

A Flask-based web application that digitizes and interprets historical handwritten documents using the Gemini AI API

🌟 Features

📥 Document Upload

  • Accepts PDFs, JPGs, and PNGs of historical documents
  • Handles multi-page PDFs by converting each page to images
  • Secure file storage with original preservation

✨ AI-Powered Processing (Gemini API)

  • Handwriting Recognition: Extracts text from even poor-quality scans
  • Text Cleaning: Fixes spacing and obvious errors while preserving original meaning
  • Smart Entity Extraction: Identifies and tags:
    • People ([PERSON])
    • Locations ([LOCATION])
    • Dates ([DATE])
    • Document types ([DOC_TYPE])
  • Automatic Summarization: Creates easy-to-understand summaries
  • Historical Term Glossary: Explains archaic legal/administrative terms

💬 Interactive Document Chat

  • Ask natural language questions like:
    • "Who is mentioned in this document?"
    • "What is the main purpose of this deed?"
    • "Translate this section to Hindi"
  • Get context-aware answers based on the document content

📊 Results Presentation

  • Side-by-Side View: Compare original document with processed text
  • Color-Coded Highlights: Easily spot important entities
  • Download Options: Save processed text or summary as TXT/PDF

⏳ Processing History

  • View all previously processed documents
  • Quick access to past results
  • Never lose your work

🏆 Use Cases

🏛️ For Historians & Researchers

  • Quickly digitize archival materials
  • Search across collections for names/places
  • Understand obsolete legal terminology

👨‍⚖️ Legal Professionals

  • Analyze old property deeds and land records
  • Trace historical ownership chains
  • Extract key clauses from vintage contracts

👪 Genealogy Enthusiasts

  • Read old family documents and letters
  • Identify ancestors in historical records
  • Understand context of old certificates

📚 Librarians & Archivists

  • Create searchable digital archives
  • Preserve fragile documents through digitization
  • Make collections more accessible

🛠️ Technical Stack

Backend

  • Flask (Python web framework)
  • SQLite (Lightweight database)
  • Gemini API (For all AI processing)
  • PyMuPDF (PDF processing)
  • Pillow (Image handling)

Frontend

  • HTML5/CSS3 with responsive design
  • JavaScript for interactive features
  • Bootstrap 5 for clean UI components

🚀 Getting Started

Prerequisites

  • Python 3.8+
  • Gemini API key (free tier available)
  • Basic terminal skills

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/historical-docs-interpreter.git
    cd historical-docs-interpreter
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configure your Gemini API key:

    • Create a config.py file
    • Add: GEMINI_API_KEY = "your-api-key-here"
  4. Run the application:

    python app.py
  5. Access in your browser at:

    http://localhost:5000
    

📖 Usage Guide

  1. Upload Documents

    • Click "Choose File" or drag-and-drop
    • Supported formats: PDF, JPG, PNG
    • Maximum size: 16MB
  2. View Results

    • Left panel shows original document
    • Right panel shows processed text with:
      • Summary at the top
      • Full text below
      • Color-highlighted entities
  3. Ask Questions

    • Type questions in the chat box
    • Examples:
      • "List all people mentioned"
      • "What year was this written?"
      • "Explain the legal terms used"
  4. Access History

    • View all processed documents
    • Click any entry to reload results

🌍 Multilingual Support

The system can handle documents in:

  • English (including archaic forms)
  • Hindi (and other Indian languages)
  • Mixed-language documents

Translation features:

  • Modernize old language forms
  • Explain regional terms
  • Cross-language queries ("Translate this to Hindi")

⚠️ Limitations

  1. Handwriting Quality

    • Works best with clear handwriting
    • May struggle with very cursive scripts
  2. Document Age

    • Best for 18th-20th century documents
    • Older materials may need manual verification
  3. Language Coverage

    • Strongest support for English and Hindi
    • Other languages may have reduced accuracy

📜 License

MIT License - Free for personal and academic use

🙏 Acknowledgments

  • Built using Google's Gemini AI
  • Inspired by archival digitization projects worldwide
  • Community contributors welcome!

About

A Flask-based web application that digitizes and interprets historical handwritten documents using the Gemini AI API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published