AI-powered image processing microservices platform built for Google Cloud Platform.
- Upscale - 4x image upscaling using Real-ESRGAN
- Enhance - Image quality enhancement using SDXL Refiner
- Comic Style - Convert images to comic/cartoon style
- Aged Style - Apply aged/vintage effect to images
- Background Remove - Remove backgrounds using RMBG-1.4
Uses NVIDIA Triton Inference Server for efficient GPU utilization with dynamic batching.
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Client │────▶│ Cloud Run │────▶│ Pub/Sub │
└─────────────┘ │ (FastAPI) │ │ (Job Queue) │
└──────────────┘ └────────┬────────┘
│
┌─────────────────────────────┼───────────────┐
│ GKE Autopilot ▼ │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Workers (CPU-only) │ │
│ │ upscale │ enhance │ comic │ ... │ │
│ └─────────────────┬───────────────────┘ │
│ │ gRPC │
│ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ Triton Inference Server (T4 GPU) │ │
│ │ • Dynamic batching (2-4 images) │ │
│ │ • All 5 models on single GPU │ │
│ │ • ~4x throughput vs old approach │ │
│ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
Cost Savings: 60-80% reduction by consolidating 5 GPU workers → 1-3 Triton instances.
- Python 3.11+
- Docker & Docker Compose
- GCP account with billing enabled (for production)
- gcloud CLI configured (for production)
# Setup environment
cd imagen
cp .env.example .env
nano .env # Update GOOGLE_CLOUD_PROJECT and GCS_BUCKET
# Install dependencies
pip install -e ".[dev]"
# Start local services (Redis, MinIO)
make dev
# Run API server
make api
# Run Triton locally (requires NVIDIA GPU + Docker)
make triton-local
# Run thin workers (connects to local Triton)
make worker-triton-upscale
make worker-triton-enhance
# ... etc
# Run tests
make testModels are downloaded automatically by Triton on first startup (~18.5GB total).
For faster cold starts, pre-download models:
make download-modelsSee docs/models/MODEL_MANAGEMENT.md for details.
POST /api/v1/images/upscale - Upscale image 4x
POST /api/v1/images/enhance - Enhance image quality
POST /api/v1/images/style/comic - Convert to comic style
POST /api/v1/images/style/aged - Apply aged/vintage effect
POST /api/v1/images/background/remove - Remove background
GET /api/v1/jobs/{job_id} - Get job status
# Submit an upscale job
curl -X POST "http://localhost:8000/api/v1/images/upscale" \
-F "file=@image.jpg" \
-F "prompt=high quality"
# Response: {"job_id": "abc-123", "status": "queued"}
# Check job status
curl "http://localhost:8000/api/v1/jobs/abc-123"# Deploy to dev
kubectl apply -k k8s/overlays/dev
# Deploy to production
kubectl apply -k k8s/overlays/prod
# Verify deployment
kubectl get pods -n imagen# Initialize Terraform
cd terraform
terraform init
# Plan and apply
terraform plan -var-file=environments/prod.tfvars
terraform apply -var-file=environments/prod.tfvarsPush to main triggers automatic deployment via Cloud Build:
- Builds API, Worker, and Triton images
- Deploys to GKE
- Waits for Triton to be ready
- Deploys thin workers
See cloudbuild.yaml for details.
imagen/
├── src/
│ ├── api/ # FastAPI application
│ ├── workers/ # Triton workers (triton_worker.py)
│ ├── services/ # GCP + Triton client integrations
│ └── core/ # Configuration & utilities
├── triton/ # Triton model repository
│ ├── Dockerfile
│ └── model_repository/
│ ├── upscale/
│ ├── enhance/
│ ├── background_remove/
│ ├── style_comic/
│ └── style_aged/
├── docker/ # Dockerfiles
├── k8s/ # Kubernetes manifests
│ ├── base/
│ ├── triton/ # Triton deployment
│ ├── workers/ # CPU-only workers
│ ├── autoscaling/
│ └── overlays/
├── terraform/ # Infrastructure as Code
└── docs/ # Documentation
| Variable | Description | Default |
|---|---|---|
GOOGLE_CLOUD_PROJECT |
GCP project ID | - |
GCS_BUCKET |
Storage bucket name | - |
TRITON_URL |
Triton gRPC endpoint | triton:8001 |
DEBUG |
Enable debug mode | false |
📚 Complete Documentation Index
| Guide | Description |
|---|---|
| ⚡ Quickstart | Get running locally |
| 🚀 First Deployment | Deploy to GKE |
| 📖 System Design | Architecture deep-dive |
| 🔧 Triton Setup | Triton configuration |
MIT