Ollama OCR
A Python-based OCR tool leveraging the Llama 3.2-Vision model for highly accurate text recognition from images, preserving original formatting and structure.
Features
- 🚀 High Accuracy: Text recognition powered by the Llama 3.2-Vision model.
- 📝 Preserves Formatting: Maintains the original structure and layout of the recognized text.
- 🖼️ Wide Format Support: Works with image formats such as
.jpg,.jpeg, and.png. - ⚡️ Customizable Output: Returns results in either Markdown or JSON format.
- 💪 Robust Error Handling: Ensures smooth processing with clear error messages for unsupported formats or invalid configurations.
System Requirements
- Python 3.8 or higher
- Ollama Server running locally
- Llama 3.2-Vision model installed
Prerequisites
- Ensure the Ollama server is running before using the tool.
- Download and configure the Llama 3.2-Vision model for OCR tasks.
Instalation
pip install ollamaocr-python
Usage
Basic Usage
from ollamaocr import OllamaOCR
# Initialize the OCR tool
ocr = OllamaOCR()
# Perform OCR in Markdown format
markdown_result = ocr.perform_ocr("path/to/image.jpg", output_format="markdown")
print(markdown_result)
# Perform OCR in JSON format
json_result = ocr.perform_ocr("path/to/image.jpg", output_format="json")
print(json_result)
Error Handling
The class provides comprehensive error handling for unsupported formats or invalid configurations:
from ollamaocr import OllamaOCR
ocr = OllamaOCR()
try:
result = ocr.perform_ocr("invalid_file.bmp", output_format="markdown")
except ValueError as e:
print(f"Error: {e}")
Customizable Prompts
Modify the prompts used for OCR to suit specific requirements:
- Markdown Prompt: Preserves formatting in Markdown structure.
- JSON Prompt: Outputs results in JSON format.
Limitations
Currently supports only .jpg, .jpeg, and .png image formats. Requires the Ollama server to be running locally with the Llama 3.2-Vision model installed.
License
This project is licensed under the MIT License.
Metadata
Release files for ollamaocr-python 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ollamaocr-python-0.1.1.tar.gz | 4.3 kB | Without provenance | Details for ollamaocr-python-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ollamaocr_python-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for ollamaocr_python-0.1.1-py3-none-any.whl |
Total release size: 8.8 kB
Release files / ollamaocr-python-0.1.1.tar.gz
| Download URL | ollamaocr-python-0.1.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c83c5686d782a343b78fda0838861b3c1e14af6805c1fc74371686c7edc7bbcf
|
|
BLAKE2b-256 checksum How to use checksums |
2f5b4d17e9b3f8921c605d0c38c0d5fa7592ffc9f8f8ecc8863fddeb41f3e207
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.3
|
Release files / ollamaocr_python-0.1.1-py3-none-any.whl
| Download URL | ollamaocr_python-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd40a1fcd4e3ffdeafdaffa2bcce25b89c20a32e26b098fb5b402e52c61b20b2
|
|
BLAKE2b-256 checksum How to use checksums |
11acb55206e7ef554197e2d6a6a14662c3384911bfc662bdd05c117883868380
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.3
|
Security for ollamaocr-python 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.