YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Google Cloud Vision AI OCR
A production-ready toolkit for document digitisation using Google Cloud Vision API, featuring multi-format support, batch processing, and enterprise deployment patterns.
Quick Start
# Clone and configure
git clone https://github.com/swordenkisk/vision-ai-ocr-guide.git
cd vision-ai-ocr-guide
# Install dependencies
pip install -r requirements.txt
# Authenticate with Google Cloud
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
# Run first extraction
python src/ocr.py samples/invoice.jpg
Repository Structure
vision-ai-ocr-guide/
βββ src/
β βββ ocr.py # Core extraction engine
β βββ batch_processor.py # High-volume parallel automation
β βββ handwriting.py # Cursive & printed handwriting recognition
β βββ layout_analyzer.py # Spatial text mapping & column detection
βββ integrations/
β βββ gcs_loader.py # Cloud Storage connector & Cloud Function trigger
β βββ bigquery_export.py # Data warehouse streaming pipeline
β βββ document_ai_bridge.py # Advanced form & invoice parsing
βββ infrastructure/
β βββ Dockerfile # Container specification
β βββ docker-compose.yml # Multi-service orchestration
β βββ cloudbuild.yaml # CI/CD β Cloud Run deployment
β βββ terraform/ # GCP resource provisioning (IaC)
βββ notebooks/
β βββ interactive_tutorial.ipynb # Step-by-step exploration
βββ docs/
β βββ format_specifications.md # Supported formats & quality guidelines
β βββ pricing_optimization.md # Cost reduction strategies
βββ samples/ # Place test images here
βββ requirements.txt
Features
- Single & batch document processing β process one image or thousands in parallel
- 50+ language support including handwriting recognition
- Multi-format input β JPEG, PNG, TIFF, PDF, BMP, WebP, GIF
- Spatial layout analysis β column detection, reading-order reconstruction, table identification
- GCS integration β trigger OCR automatically on file upload via Cloud Functions
- BigQuery export β stream results to a data warehouse for analytics
- Document AI bridge β structured extraction for invoices, forms, and receipts
- Dockerised microservices β production-ready container with Cloud Run support
- Terraform IaC β one-command GCP infrastructure provisioning
Module Reference
src/ocr.py β Core Extraction Engine
from src.ocr import DocumentExtractor
extractor = DocumentExtractor()
# Standard OCR (photos, sparse layouts)
result = extractor.extract("invoice.jpg", language="en")
print(result["text"])
print(result["word_count"])
# Document OCR (dense text, forms, invoices)
result = extractor.extract_document("report.pdf", language="en")
print(result["pages"])
src/batch_processor.py β Parallel Batch Processing
from src.batch_processor import BatchProcessor
processor = BatchProcessor(max_workers=10)
report = processor.process_directory("./documents", "./results")
# Results: per-file JSON + _report.json summary
src/handwriting.py β Handwriting Recognition
from src.handwriting import HandwritingExtractor
extractor = HandwritingExtractor()
result = extractor.extract("scan.jpg", language_hints=["en", "fr"])
print(result["text"])
print(result["detected_language"])
src/layout_analyzer.py β Spatial Layout Analysis
from src.layout_analyzer import LayoutAnalyzer
analyzer = LayoutAnalyzer()
layout = analyzer.analyze("page.jpg")
columns = analyzer.detect_columns(layout)
tables = analyzer.find_tables(layout)
Deployment
Docker
docker build -t vision-ocr:latest -f infrastructure/Dockerfile .
docker run \
-v $(pwd)/documents:/input \
-v $(pwd)/results:/output \
-e GOOGLE_APPLICATION_CREDENTIALS=/secrets/key.json \
-v $GOOGLE_APPLICATION_CREDENTIALS:/secrets/key.json:ro \
vision-ocr:latest
Cloud Run (via Cloud Build)
gcloud builds submit --config infrastructure/cloudbuild.yaml .
Terraform (GCP Infrastructure)
cd infrastructure/terraform
terraform init
terraform apply -var="project_id=YOUR_PROJECT_ID"
Security
- Never commit service account keys β use Secret Manager in production
- Process EU documents in
europe-westregions for GDPR compliance - Vision API encrypts data in transit and at rest by default
- Enable VPC Service Controls for sensitive document processing
Requirements
- Python 3.11+
- Google Cloud project with Vision API enabled
- Service account with
roles/vision.userIAM binding
License
MIT β commercial and non-commercial use permitted.
Last updated: February 2026
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support