CoolFace
Apppublic

digopala/ai-inference-architecture-healthcare

sourceHugging Faceupdated 1y agoView on Hugging Face
12likes
App README

AI Inference Architecture for Healthcare

This project provides a scalable, production-ready AI inference architecture designed for healthcare and pharmaceutical applications. It integrates Triton Inference Server, FastAPI, and Kubernetes to support high-throughput model inference.

πŸš€ Key Features

  • β€”Modular container-based architecture with FastAPI gateway
  • β€”Supports NLP and CV models with optional preprocessing
  • β€”Inference via Triton Inference Server using ONNX or TorchScript models
  • β€”GitHub Actions-powered CI/CD pipeline to auto-deploy model updates
  • β€”Kubernetes-based pod management, autoscaling, and volume mounting
  • β€”Full observability stack: Prometheus + Grafana for metrics and monitoring
  • β€”Compliant with HIPAA-aligned standards: secure APIs, logging, encryption

🧱 Architecture Overview

Healthcare/Pharma Clients β†’ FastAPI Gateway β†’ Optional Preprocessor β†’ Triton Pod
       ↓                        ↓                            ↓             ↓
 Model Registry ← GitHub CI/CD Pipeline ← Kubernetes ← Monitoring (Prometheus + Grafana)

βš™οΈ Deployment Options

▢️ Local (Docker Compose)

bash
docker compose up --build

☸️ Kubernetes (Production)

bash
kubectl apply -f k8s.yaml
kubectl apply -f preprocessor.yaml
kubectl apply -f hpa.yaml

πŸ“¦ Model Lifecycle

  1. 1.Train model locally or in pipeline (e.g., PyTorch/ONNX)
  2. 2.Push model to GitHub repository
  3. 3.GitHub Actions CI/CD triggers and pushes model to Model Registry
  4. 4.Kubernetes mounts model volume into Triton pod
  5. 5.Triton automatically reloads model

πŸ” Monitoring and Observability

  • β€”Metrics via Prometheus sidecar scraping port 8002 on Triton pod
  • β€”Dashboards in Grafana track latency, throughput, failures

πŸ§ͺ Sample Inference Request

bash
curl -X POST http://localhost:8000/infer   -H "Content-Type: application/json"   -d '{"input": "Patient data or image here"}'

Enhancements Based on Peer Technical Review

Preprocessing Execution Model

The NLP/CV preprocessing stage runs as an independent Kubernetes microservice for isolation and scale. The FastAPI Gateway performs conditional routing:

  • β€”content_type=image/* β†’ CV preprocessor β†’ Triton
  • β€”content_type=text/* β†’ NLP preprocessor β†’ Triton
  • β€”Already-normalized inputs β†’ direct to Triton A lightweight schema-validation step remains in the gateway.

Model Lifecycle: Versioning, Promotion, Rollback

  • β€”Models are versioned under /models/<name>/<version> (e.g., /models/ner/1).
  • β€”CI/CD publishes to staging; promotion updates a release tag (e.g., current -> 2) for Triton to hot-reload.
  • β€”Rollback re-points the tag to the last known-good (current -> 1).
  • β€”Supports blue‑green (two deployments, Service selector switch) and canary (small % routed to a second Triton deployment).

Scalability & Resilience

  • β€”HPA scales Triton pods based on CPU (and can extend to latency custom metrics).
  • β€”Readiness/Liveness probes guard rollout and enable auto‑healing.
  • β€”Gateway uses timeouts and retry on transient 5xx. If a pod is Unready, traffic shifts to healthy pods.

Security, Compliance & Audit

  • β€”TLS in transit; optional mTLS inside cluster.
  • β€”OAuth2/JWT at the gateway with per‑route scopes.
  • β€”Audit logs (structured JSON with request_id) across gateway, preprocessors, and Triton; logs ship to ELK/Loki.
  • β€”Optional PHI de‑identification in preprocessors; strict schema validation; data minimization and retention controls aligned to HIPAA/GDPR.

Data Flow & Validation

  • β€”Gateway enforces MIME/JSON schema and rejects malformed/unauthorized requests.
  • β€”Preprocessors normalize inputs (e.g., tokenize text, resize/normalize images).
  • β€”Triton returns prediction JSON; gateway maps to a domain response schema and may redact fields per policy.

πŸ“Œ See SECURITY.md for detailed security, compliance, and audit logging implementation.

πŸ“„ See preprocessor.yaml for deployment details of the NLP/CV preprocessing microservice.

πŸ“„ See hpa.yaml for Triton autoscaling configuration.

πŸ“‚ File Reference

  • β€”k8s.yaml β†’ Triton deployment
  • β€”preprocessor.yaml β†’ NLP/CV preprocessing service
  • β€”hpa.yaml β†’ Horizontal Pod Autoscaler for Triton