Spaces:
Sleeping
title: Antai AI Image Detector
emoji: π
colorFrom: red
colorTo: yellow
sdk: docker
pinned: false
app_port: 7860
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 Response
Routing Table
| Bucket | CLIP Candidate Label | Specialist Env Var |
|---|---|---|
portrait_face |
"portrait or face photo" |
SPECIALIST_FACE_MODEL_ID |
document_ui_screenshot |
"document screenshot or UI" |
SPECIALIST_DOCUMENT_MODEL_ID |
art_illustration |
"artwork illustration or painting" |
SPECIALIST_ART_MODEL_ID |
nature_landscape |
"nature landscape or outdoor" |
SPECIALIST_NATURE_MODEL_ID |
general |
"general photo or other" (also fallback) |
SPECIALIST_GENERAL_MODEL_ID |
Environment Variables
| Variable | Default | Description |
|---|---|---|
ROUTER_MODEL_ID |
openai/clip-vit-base-patch32 |
Router model (zero-shot-image-classification task) |
SPECIALIST_GENERAL_MODEL_ID |
Ateeqq/ai-vs-human-image-detector |
Specialist for the general / fallback bucket |
SPECIALIST_FACE_MODEL_ID |
Ateeqq/ai-vs-human-image-detector |
Specialist for portrait / face imagery |
SPECIALIST_DOCUMENT_MODEL_ID |
Ateeqq/ai-vs-human-image-detector |
Specialist for screenshots and documents |
SPECIALIST_ART_MODEL_ID |
Ateeqq/ai-vs-human-image-detector |
Specialist for art and illustrations |
SPECIALIST_NATURE_MODEL_ID |
Ateeqq/ai-vs-human-image-detector |
Specialist for nature and landscapes |
AI_THRESHOLD |
0.5 |
Confidence threshold for isAI: true |
DEBUG |
false |
When true, adds rawRouter and rawSpecialist to response |
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.