Ollama-OCR: Advanced OCR with Vision Language Models via Ollama

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Ollama-OCR: Advanced OCR with Vision Language Models via Ollama

Summary

Ollama-OCR is a robust Python package and Streamlit application for Optical Character Recognition. It leverages state-of-the-art vision language models, accessible through Ollama, to accurately extract text from both images and PDF documents. The tool offers extensive features including support for multiple models, various output formats, and batch processing capabilities.

Repository Information

Analyzed by OSRepos on October 12, 2025

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

Ollama-OCR is a powerful and versatile Python package designed for Optical Character Recognition (OCR). It leverages state-of-the-art vision language models, made accessible through Ollama, to accurately extract text from both images and PDF documents. With over 2000 stars and 200 forks on GitHub, this project demonstrates significant community interest and utility. It is available as a Python library for programmatic use and also features a user-friendly Streamlit web application.

Explore Ollama-OCR on GitHub

Installation

To get started with Ollama-OCR, you first need to install Ollama and pull the desired vision models.

Prerequisites

  1. Install Ollama: Follow the instructions on the Ollama website.
  2. Pull Required Models: Use the ollama pull command for models like llama3.2-vision:11b, granite3.2-vision, moondream, or minicpm-v.
ollama pull llama3.2-vision:11b
ollama pull granite3.2-vision
ollama pull moondream
ollama pull minicpm-v

Package Installation

Install the Ollama-OCR Python package using pip:

pip install ollama-ocr

Examples

Ollama-OCR provides flexible options for processing single files or batches, and also includes a Streamlit application for a graphical interface.

Single File Processing

Process an individual image or PDF file with a specified model and output format:

from ollama_ocr import OCRProcessor

# Initialize OCR processor
ocr = OCRProcessor(model_name='llama3.2-vision:11b', base_url="http://host.docker.internal:11434/api/generate")
# You can pass your custom Ollama API URL

# Process an image or PDF
result = ocr.process_image(
    image_path="path/to/your/image.png", # or "path/to/your/file.pdf"
    format_type="markdown",  # Options: markdown, text, json, structured, key_value, table
    custom_prompt="Extract all text, focusing on dates and names.", # Optional custom prompt
    language="English" # Specify the language of the text
)
print(result)

Batch File Processing

Efficiently process multiple images or PDFs in parallel from a directory:

from ollama_ocr import OCRProcessor

# Initialize OCR processor with parallel workers
ocr = OCRProcessor(model_name='llama3.2-vision:11b', max_workers=4)

# Process multiple files with progress tracking
batch_results = ocr.process_batch(
    input_path="path/to/images/folder",  # Directory or list of image paths
    format_type="markdown",
    recursive=True,  # Search subdirectories
    preprocess=True,  # Enable image preprocessing
    custom_prompt="Extract all text, focusing on dates and names.", # Optional custom prompt
    language="English" # Specify the language of the text
)
# Access results
for file_path, text in batch_results['results'].items():
    print(f"\nFile: {file_path}")
    print(f"Extracted Text: {text}")

# View statistics
print("\nProcessing Statistics:")
print(f"Total images: {batch_results['statistics']['total']}")
print(f"Successfully processed: {batch_results['statistics']['successful']}")
print(f"Failed: {batch_results['statistics']['failed']}")

Streamlit Web Application

For a user-friendly experience, the project includes a Streamlit web application that supports batch processing, drag-and-drop uploads, and real-time results.

  1. Clone the repository:
    git clone https://github.com/imanoop7/Ollama-OCR.git
    cd Ollama-OCR
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Navigate to the src/ollama_ocr directory:
    cd src/ollama_ocr
    
  4. Run the Streamlit app:
    streamlit run app.py
    

Why Use Ollama-OCR?

Ollama-OCR stands out due to its comprehensive feature set and flexibility:

  • Extensive Model Support: Integrate with various powerful vision language models like LLaVA, Llama 3.2 Vision, Granite3.2-vision, Moondream, and Minicpm-v.
  • Versatile Output Formats: Obtain extracted text in Markdown, Plain Text, JSON, Structured, Key-Value Pairs, or Table formats, catering to diverse application needs.
  • Batch Processing: Efficiently handle multiple documents with parallel processing and progress tracking.
  • Custom Prompts: Tailor text extraction with custom instructions to focus on specific information.
  • PDF and Image Support: Process a wide range of document types.
  • User-Friendly Streamlit App: A responsive web interface simplifies usage for non-developers, offering drag-and-drop functionality and real-time results.
  • Language Selection: Improve OCR accuracy by specifying the language of the text.

Links

Related repositories

Similar repositories that may be relevant next.

GLM-OCR: Accurate, Fast, and Comprehensive Multimodal OCR Model

GLM-OCR: Accurate, Fast, and Comprehensive Multimodal OCR Model

May 28, 2026

GLM-OCR is a powerful multimodal OCR model designed for complex document understanding, built on the GLM-V encoder-decoder architecture. It achieves state-of-the-art performance across various benchmarks, offering efficient inference and easy integration. This open-source solution is optimized for real-world business scenarios, providing robust and high-quality OCR capabilities.

PythonOCRGLM
OmniParse: Ingest, Parse, and Optimize Data for GenAI Frameworks

OmniParse: Ingest, Parse, and Optimize Data for GenAI Frameworks

April 7, 2026

OmniParse is a powerful platform designed to ingest, parse, and optimize any unstructured data, from documents to multimedia, into structured, actionable formats. It enhances compatibility with GenAI frameworks, preparing data for applications like RAG and fine-tuning. This tool simplifies the complex process of data preparation for AI, making it accessible and efficient.

PythonGenAIData Ingestion
docling-api: Scalable Document to Markdown Conversion Server

docling-api: Scalable Document to Markdown Conversion Server

January 30, 2026

docling-api is a robust and scalable backend server designed for converting a wide array of document formats, including PDFs, DOCX, and images, into Markdown. Built with FastAPI, Celery, and Redis, it supports both CPU and GPU processing, making it ideal for large-scale workflows requiring efficient text, table, and image extraction, along with OCR capabilities. This service offers flexible synchronous and asynchronous API endpoints for single and batch document conversions.

PythonAPIFastAPI
Papermerge DMS: Open Source Document Management for Digital Archives

Papermerge DMS: Open Source Document Management for Digital Archives

January 8, 2026

Papermerge DMS is an open-source document management system specifically designed for scanned documents and digital archives. It leverages OCR technology to extract and index text, enabling full-text search and efficient organization. With a modern web UI, it provides a desktop-like experience for managing various document formats.

document managementDMSOCR

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️