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-west regions 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.user IAM binding

License

MIT β€” commercial and non-commercial use permitted.


Last updated: February 2026

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support