RaidenIppen/antai-detector
Antai AI Image Detector – Inference API
FastAPI service implementing a two-stage multi-model routing architecture for AI vs human image detection.
Architecture
Image Input
│
▼
Stage 1 — Router (openai/clip-vit-base-patch32)
│ Zero-shot classification into 5 content buckets
│
▼
Stage 2 — Specialist (per-bucket, all default to Ateeqq/ai-vs-human-image-detector)
│ AI vs human classification tuned for the detected content type
│
▼
JSON ResponseRouting Table
Environment Variables
See space/.env.example for a copy-paste template.
Endpoints
POST /detect
{ "imageUrl": "https://..." }
// or
{ "imageData": "data:image/jpeg;base64,..." }Returns:
{
"confidence": 0.87,
"isAI": true,
"provider": "huggingface",
"routerLabel": "portrait_face",
"routerConfidence": 0.73,
"specialistModel": "Ateeqq/ai-vs-human-image-detector"
}With DEBUG=true, also includes:
{
"rawRouter": [{ "label": "portrait or face photo", "score": 0.73 }, ...],
"rawSpecialist": [{ "label": "ai", "score": 0.87 }, { "label": "hum", "score": 0.13 }]
}GET /health
Returns { "status": "ok" } — used by the Node.js backend to check if the Space is awake.
Docker / Space Build Notes
The Dockerfile uses huggingface-cli download (from huggingface_hub[cli]) to pre-cache both the router and default specialist at build time. Each model is a separate RUN layer for Docker cache granularity.
Memory footprint (default config): ~600 MB (CLIP router) + ~350 MB (one Ateeqq specialist shared across all 5 buckets) ≈ ~950 MB — well within the HF Spaces free-tier limit.
Custom specialists: If you override a specialist via an env var, that model is not pre-cached in the Docker image and will download on the first cold start. For production use, extend the Dockerfile with additional huggingface-cli download <model-id> lines or accept the first-request latency.
ZeroGPU: If deploying to a HuggingFace ZeroGPU Space, wrap specialist inference with the @spaces.GPU decorator and lazy-load pipelines inside it to avoid pre-allocating all VRAM at startup.
