{"name":"Ollama-OCR: Advanced OCR with Vision Language Models via Ollama","description":"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.","github":"https://github.com/imanoop7/Ollama-OCR","url":"https://osrepos.com/repo/imanoop7-ollama-ocr","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/imanoop7-ollama-ocr","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/imanoop7-ollama-ocr.md","json":"https://osrepos.com/repo/imanoop7-ollama-ocr.json","topics":["OCR","Ollama","Python","Machine Learning","Vision Models","AI","Streamlit","Document Processing"],"keywords":["OCR","Ollama","Python","Machine Learning","Vision Models","AI","Streamlit","Document Processing"],"stars":null,"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.","content":"## Introduction\n\nOllama-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.\n\n[Explore Ollama-OCR on GitHub](https://github.com/imanoop7/Ollama-OCR){:target=\"_blank\"}\n\n## Installation\n\nTo get started with Ollama-OCR, you first need to install Ollama and pull the desired vision models.\n\n### Prerequisites\n\n1.  **Install Ollama**: Follow the instructions on the [Ollama website](https://ollama.com){:target=\"_blank\"}.\n2.  **Pull Required Models**: Use the `ollama pull` command for models like `llama3.2-vision:11b`, `granite3.2-vision`, `moondream`, or `minicpm-v`.\n\nbash\nollama pull llama3.2-vision:11b\nollama pull granite3.2-vision\nollama pull moondream\nollama pull minicpm-v\n\n\n### Package Installation\n\nInstall the Ollama-OCR Python package using pip:\n\nbash\npip install ollama-ocr\n\n\n## Examples\n\nOllama-OCR provides flexible options for processing single files or batches, and also includes a Streamlit application for a graphical interface.\n\n### Single File Processing\n\nProcess an individual image or PDF file with a specified model and output format:\n\npython\nfrom ollama_ocr import OCRProcessor\n\n# Initialize OCR processor\nocr = OCRProcessor(model_name='llama3.2-vision:11b', base_url=\"http://host.docker.internal:11434/api/generate\")\n# You can pass your custom Ollama API URL\n\n# Process an image or PDF\nresult = ocr.process_image(\n    image_path=\"path/to/your/image.png\", # or \"path/to/your/file.pdf\"\n    format_type=\"markdown\",  # Options: markdown, text, json, structured, key_value, table\n    custom_prompt=\"Extract all text, focusing on dates and names.\", # Optional custom prompt\n    language=\"English\" # Specify the language of the text\n)\nprint(result)\n\n\n### Batch File Processing\n\nEfficiently process multiple images or PDFs in parallel from a directory:\n\npython\nfrom ollama_ocr import OCRProcessor\n\n# Initialize OCR processor with parallel workers\nocr = OCRProcessor(model_name='llama3.2-vision:11b', max_workers=4)\n\n# Process multiple files with progress tracking\nbatch_results = ocr.process_batch(\n    input_path=\"path/to/images/folder\",  # Directory or list of image paths\n    format_type=\"markdown\",\n    recursive=True,  # Search subdirectories\n    preprocess=True,  # Enable image preprocessing\n    custom_prompt=\"Extract all text, focusing on dates and names.\", # Optional custom prompt\n    language=\"English\" # Specify the language of the text\n)\n# Access results\nfor file_path, text in batch_results['results'].items():\n    print(f\"\\nFile: {file_path}\")\n    print(f\"Extracted Text: {text}\")\n\n# View statistics\nprint(\"\\nProcessing Statistics:\")\nprint(f\"Total images: {batch_results['statistics']['total']}\")\nprint(f\"Successfully processed: {batch_results['statistics']['successful']}\")\nprint(f\"Failed: {batch_results['statistics']['failed']}\")\n\n\n### Streamlit Web Application\n\nFor a user-friendly experience, the project includes a Streamlit web application that supports batch processing, drag-and-drop uploads, and real-time results.\n\n1.  Clone the repository:\n    bash\ngit clone https://github.com/imanoop7/Ollama-OCR.git\ncd Ollama-OCR\n    \n2.  Install dependencies:\n    bash\npip install -r requirements.txt\n    \n3.  Navigate to the `src/ollama_ocr` directory:\n    bash\ncd src/ollama_ocr\n    \n4.  Run the Streamlit app:\n    bash\nstreamlit run app.py\n    \n\n## Why Use Ollama-OCR?\n\nOllama-OCR stands out due to its comprehensive feature set and flexibility:\n\n*   **Extensive Model Support**: Integrate with various powerful vision language models like LLaVA, Llama 3.2 Vision, Granite3.2-vision, Moondream, and Minicpm-v.\n*   **Versatile Output Formats**: Obtain extracted text in Markdown, Plain Text, JSON, Structured, Key-Value Pairs, or Table formats, catering to diverse application needs.\n*   **Batch Processing**: Efficiently handle multiple documents with parallel processing and progress tracking.\n*   **Custom Prompts**: Tailor text extraction with custom instructions to focus on specific information.\n*   **PDF and Image Support**: Process a wide range of document types.\n*   **User-Friendly Streamlit App**: A responsive web interface simplifies usage for non-developers, offering drag-and-drop functionality and real-time results.\n*   **Language Selection**: Improve OCR accuracy by specifying the language of the text.\n\n## Links\n\n*   **GitHub Repository**: [imanoop7/Ollama-OCR](https://github.com/imanoop7/Ollama-OCR){:target=\"_blank\"}\n*   **Ollama Official Website**: [ollama.com](https://ollama.com){:target=\"_blank\"}\n*   **LLaVA Model**: [ollama.com/library/llava](https://ollama.com/library/llava){:target=\"_blank\"}\n*   **Granite3.2-vision Model**: [ollama.com/library/granite3.2-vision](https://ollama.com/library/granite3.2-vision){:target=\"_blank\"}\n*   **Moondream Model**: [ollama.com/library/moondream](https://ollama.com/library/moondream){:target=\"_blank\"}\n*   **Minicpm-v Model**: [ollama.com/library/minicpm-v](https://ollama.com/library/minicpm-v){:target=\"_blank\"}\n*   **Example Notebooks**: [Ollama-OCR Example Notebooks](https://github.com/imanoop7/Ollama-OCR/tree/main/example_notebooks){:target=\"_blank\"}","metrics":{"detailViews":67,"githubClicks":4},"dates":{"published":null,"modified":"2025-10-12T06:10:52.000Z"}}