A comprehensive OCR application powered by GutenOCR Vision Language Models with CPU/GPU support, featuring a user-friendly interface and combined Docling integration.
git clone https://github.com/YOUR_USERNAME/GutenOCR-Test.git
cd GutenOCR-Test
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Start the standard OCR web interface:
./scripts/start.sh --mode gradio
Access the UI at: http://localhost:7860
Start the advanced document processing interface:
./scripts/start.sh --mode docling-ui
Access the UI at: http://localhost:7861
Features:
Process documents directly:
./scripts/start.sh --mode combined
Start with Docker (CPU):
./scripts/start.sh --mode docker-cpu
Start with Docker (GPU):
./scripts/start.sh --mode docker-gpu
Purpose: Fast OCR processing for images
Setup Tab: Initialize the model
Single Image Tab: Process individual images
Batch Processing Tab: Process multiple images
./input directory./output directoryPurpose: Advanced document processing with structure extraction
Access: http://localhost:7861
Setup Tab: Initialize the combined processor
Single Document Tab: Process individual documents
Batch Processing Tab: Process multiple documents
./input directory./output directory with detailed JSONHelp Tab: Comprehensive usage guide and troubleshooting
Supported Formats:
Processing Modes:
from src.gutenocr_engine import GutenOCREngine
engine = GutenOCREngine(
model_id="rootsautomation/GutenOCR-3B",
use_cpu=False # Set to True for CPU
)
result = engine.process_image(
image_path="path/to/image.png",
task_type="reading",
output_format="TEXT"
)
print(result['text'])
from src.gutenocr_engine import GutenOCREngine
from src.file_processor import FileProcessor
engine = GutenOCREngine()
processor = FileProcessor()
# Discover images
images = processor.discover_images(recursive=True)
# Process batch
results = engine.batch_process(images)
# Save results
processor.save_results(results, format="json")
# Command line processing
python src/docling_gutenocr_combined.py \
--input ./input \
--output ./output \
--model rootsautomation/GutenOCR-3B
# Or use the start script
./scripts/start.sh --mode combined
from src.docling_gutenocr_combined import DoclingGutenOCRProcessor
# Initialize processor
processor = DoclingGutenOCRProcessor(
gutenocr_model="rootsautomation/GutenOCR-3B",
use_cpu=False,
use_docling=True
)
# Process single document
result = processor.process_document(
file_path="document.pdf",
extract_structure=True,
extract_tables=True,
ocr_images=True
)
print(result['combined_text'])
# Batch process
results = processor.batch_process(
input_dir="./input",
output_dir="./output"
)
GutenOCR-Test/
βββ src/
β βββ gutenocr_engine.py # Core OCR engine
β βββ file_processor.py # File handling and output management
β βββ gradio_ui.py # Standard OCR web interface
β βββ docling_gradio_ui.py # Docling + GutenOCR web interface (NEW!)
β βββ docling_gutenocr_combined.py # Combined processor
βββ docker/
β βββ Dockerfile.gutenocr # CPU Docker image
β βββ Dockerfile.gutenocr-gpu # GPU Docker image
β βββ Dockerfile.combined # Combined processor image
β βββ docker-compose.yml # Docker Compose configuration
β βββ .dockerignore # Docker ignore file
βββ kubernetes/
β βββ deployment-cpu.yaml # CPU deployment
β βββ deployment-gpu.yaml # GPU deployment
β βββ persistent-volumes.yaml # Storage configuration
β βββ configmap.yaml # Configuration
β βββ ingress.yaml # Ingress rules
βββ scripts/
β βββ start.sh # Start script
β βββ stop.sh # Stop script
β βββ push-to-github.sh # GitHub automation
βββ input/ # Input images directory
βββ output/ # Output results directory
βββ docs/ # Documentation
βββ tests/ # Test files
βββ requirements.txt # Python dependencies
βββ README.md # This file
See Architecture Documentation for detailed information.
# CPU version
docker build -f docker/Dockerfile.gutenocr -t gutenocr:cpu-latest .
# GPU version
docker build -f docker/Dockerfile.gutenocr-gpu -t gutenocr:gpu-latest .
# Combined processor
docker build -f docker/Dockerfile.combined -t gutenocr:combined-latest .
# CPU version
docker run -d \
--name gutenocr-cpu \
-p 7860:7860 \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
gutenocr:cpu-latest
# GPU version (requires nvidia-docker)
docker run -d \
--name gutenocr-gpu \
--gpus all \
-p 7860:7860 \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
gutenocr:gpu-latest
# Start CPU version
docker-compose -f docker/docker-compose.yml up -d gutenocr-cpu
# Start GPU version
docker-compose -f docker/docker-compose.yml up -d gutenocr-gpu
# Start combined processor
docker-compose -f docker/docker-compose.yml --profile batch up combined-processor
# Deploy using automation script
./scripts/start.sh --mode k8s
# Or manually:
kubectl apply -f kubernetes/persistent-volumes.yaml
kubectl apply -f kubernetes/configmap.yaml
kubectl apply -f kubernetes/deployment-cpu.yaml
kubectl apply -f kubernetes/deployment-gpu.yaml
kubectl apply -f kubernetes/ingress.yaml
# Check pods
kubectl get pods -l app=gutenocr
# Check services
kubectl get services -l app=gutenocr
# View logs
kubectl logs -f deployment/gutenocr-cpu
# Scale CPU deployment
kubectl scale deployment gutenocr-cpu --replicas=3
# Scale GPU deployment
kubectl scale deployment gutenocr-gpu --replicas=2
class GutenOCREngine:
def __init__(
self,
model_id: str = "rootsautomation/GutenOCR-3B",
device: str = "auto",
use_cpu: bool = False,
torch_dtype: Optional[torch.dtype] = None
)
def process_image(
self,
image_path: str,
task_type: str = "reading",
output_format: str = "TEXT",
max_new_tokens: int = 4096,
custom_prompt: Optional[str] = None
) -> Dict[str, Any]
def batch_process(
self,
image_paths: List[str],
task_type: str = "reading",
output_format: str = "TEXT",
max_new_tokens: int = 4096
) -> List[Dict[str, Any]]
# Model configuration
GUTENOCR_MODEL=rootsautomation/GutenOCR-3B
GUTENOCR_USE_CPU=false
# Server configuration
GRADIO_SERVER_NAME=0.0.0.0
GRADIO_SERVER_PORT=7860
# Processing configuration
MAX_NEW_TOKENS=4096
DEFAULT_TASK_TYPE=reading
DEFAULT_OUTPUT_FORMAT=TEXT
GPU (Recommended):
CPU:
use_cpu=True in engine initializationSolution: Use GutenOCR-3B instead of 7B, or enable CPU mode
Solution: Install CUDA toolkit or use CPU mode with --cpu flag
Solution: Check internet connection and HuggingFace access
Set HF_TOKEN environment variable if needed
Solution: Change port in environment variables or stop conflicting service
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
The GutenOCR model weights are licensed under CC-BY-NC.
Built with β€οΈ using GutenOCR
A comprehensive OCR application powered by GutenOCR Vision Language Models with CPU/GPU support, featuring a user-friendly interface and combined Docling integration.
git clone https://github.com/YOUR_USERNAME/GutenOCR-Test.git
cd GutenOCR-Test
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Start the standard OCR web interface:
./scripts/start.sh --mode gradio
Access the UI at: http://localhost:7860
Start the advanced document processing interface:
./scripts/start.sh --mode docling-ui
Access the UI at: http://localhost:7861
Features:
Process documents directly:
./scripts/start.sh --mode combined
Start with Docker (CPU):
./scripts/start.sh --mode docker-cpu
Start with Docker (GPU):
./scripts/start.sh --mode docker-gpu
Purpose: Fast OCR processing for images
Setup Tab: Initialize the model
Single Image Tab: Process individual images
Batch Processing Tab: Process multiple images
./input directory./output directoryPurpose: Advanced document processing with structure extraction
Access: http://localhost:7861
Setup Tab: Initialize the combined processor
Single Document Tab: Process individual documents
Batch Processing Tab: Process multiple documents
./input directory./output directory with detailed JSONHelp Tab: Comprehensive usage guide and troubleshooting
Supported Formats:
Processing Modes:
from src.gutenocr_engine import GutenOCREngine
engine = GutenOCREngine(
model_id="rootsautomation/GutenOCR-3B",
use_cpu=False # Set to True for CPU
)
result = engine.process_image(
image_path="path/to/image.png",
task_type="reading",
output_format="TEXT"
)
print(result['text'])
from src.gutenocr_engine import GutenOCREngine
from src.file_processor import FileProcessor
engine = GutenOCREngine()
processor = FileProcessor()
# Discover images
images = processor.discover_images(recursive=True)
# Process batch
results = engine.batch_process(images)
# Save results
processor.save_results(results, format="json")
# Command line processing
python src/docling_gutenocr_combined.py \
--input ./input \
--output ./output \
--model rootsautomation/GutenOCR-3B
# Or use the start script
./scripts/start.sh --mode combined
from src.docling_gutenocr_combined import DoclingGutenOCRProcessor
# Initialize processor
processor = DoclingGutenOCRProcessor(
gutenocr_model="rootsautomation/GutenOCR-3B",
use_cpu=False,
use_docling=True
)
# Process single document
result = processor.process_document(
file_path="document.pdf",
extract_structure=True,
extract_tables=True,
ocr_images=True
)
print(result['combined_text'])
# Batch process
results = processor.batch_process(
input_dir="./input",
output_dir="./output"
)
GutenOCR-Test/
βββ src/
β βββ gutenocr_engine.py # Core OCR engine
β βββ file_processor.py # File handling and output management
β βββ gradio_ui.py # Standard OCR web interface
β βββ docling_gradio_ui.py # Docling + GutenOCR web interface (NEW!)
β βββ docling_gutenocr_combined.py # Combined processor
βββ docker/
β βββ Dockerfile.gutenocr # CPU Docker image
β βββ Dockerfile.gutenocr-gpu # GPU Docker image
β βββ Dockerfile.combined # Combined processor image
β βββ docker-compose.yml # Docker Compose configuration
β βββ .dockerignore # Docker ignore file
βββ kubernetes/
β βββ deployment-cpu.yaml # CPU deployment
β βββ deployment-gpu.yaml # GPU deployment
β βββ persistent-volumes.yaml # Storage configuration
β βββ configmap.yaml # Configuration
β βββ ingress.yaml # Ingress rules
βββ scripts/
β βββ start.sh # Start script
β βββ stop.sh # Stop script
β βββ push-to-github.sh # GitHub automation
βββ input/ # Input images directory
βββ output/ # Output results directory
βββ docs/ # Documentation
βββ tests/ # Test files
βββ requirements.txt # Python dependencies
βββ README.md # This file
See Architecture Documentation for detailed information.
# CPU version
docker build -f docker/Dockerfile.gutenocr -t gutenocr:cpu-latest .
# GPU version
docker build -f docker/Dockerfile.gutenocr-gpu -t gutenocr:gpu-latest .
# Combined processor
docker build -f docker/Dockerfile.combined -t gutenocr:combined-latest .
# CPU version
docker run -d \
--name gutenocr-cpu \
-p 7860:7860 \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
gutenocr:cpu-latest
# GPU version (requires nvidia-docker)
docker run -d \
--name gutenocr-gpu \
--gpus all \
-p 7860:7860 \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
gutenocr:gpu-latest
# Start CPU version
docker-compose -f docker/docker-compose.yml up -d gutenocr-cpu
# Start GPU version
docker-compose -f docker/docker-compose.yml up -d gutenocr-gpu
# Start combined processor
docker-compose -f docker/docker-compose.yml --profile batch up combined-processor
# Deploy using automation script
./scripts/start.sh --mode k8s
# Or manually:
kubectl apply -f kubernetes/persistent-volumes.yaml
kubectl apply -f kubernetes/configmap.yaml
kubectl apply -f kubernetes/deployment-cpu.yaml
kubectl apply -f kubernetes/deployment-gpu.yaml
kubectl apply -f kubernetes/ingress.yaml
# Check pods
kubectl get pods -l app=gutenocr
# Check services
kubectl get services -l app=gutenocr
# View logs
kubectl logs -f deployment/gutenocr-cpu
# Scale CPU deployment
kubectl scale deployment gutenocr-cpu --replicas=3
# Scale GPU deployment
kubectl scale deployment gutenocr-gpu --replicas=2
class GutenOCREngine:
def __init__(
self,
model_id: str = "rootsautomation/GutenOCR-3B",
device: str = "auto",
use_cpu: bool = False,
torch_dtype: Optional[torch.dtype] = None
)
def process_image(
self,
image_path: str,
task_type: str = "reading",
output_format: str = "TEXT",
max_new_tokens: int = 4096,
custom_prompt: Optional[str] = None
) -> Dict[str, Any]
def batch_process(
self,
image_paths: List[str],
task_type: str = "reading",
output_format: str = "TEXT",
max_new_tokens: int = 4096
) -> List[Dict[str, Any]]
# Model configuration
GUTENOCR_MODEL=rootsautomation/GutenOCR-3B
GUTENOCR_USE_CPU=false
# Server configuration
GRADIO_SERVER_NAME=0.0.0.0
GRADIO_SERVER_PORT=7860
# Processing configuration
MAX_NEW_TOKENS=4096
DEFAULT_TASK_TYPE=reading
DEFAULT_OUTPUT_FORMAT=TEXT
GPU (Recommended):
CPU:
use_cpu=True in engine initializationSolution: Use GutenOCR-3B instead of 7B, or enable CPU mode
Solution: Install CUDA toolkit or use CPU mode with --cpu flag
Solution: Check internet connection and HuggingFace access
Set HF_TOKEN environment variable if needed
Solution: Change port in environment variables or stop conflicting service
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
The GutenOCR model weights are licensed under CC-BY-NC.
Built with β€οΈ using GutenOCR