CoolFace
Apppublic

ofc01/janrakshak-api

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

šŸ›”ļø JanRakshak Vision — Backend API (v7)

AI Deepfake Detection Backend | JanRakshak Vision | Tradition Hacks 2026 Team: Anonymous Group | Leader: Kushal Soni

![HuggingFace Space](https://ofc01-janrakshak-api.hf.space) ![FastAPI](https://fastapi.tiangolo.com/) ![Python](https://python.org)


🌐 Live Deployment

ServiceURL
API Basehttps://ofc01-janrakshak-api.hf.space
Swagger UIhttps://ofc01-janrakshak-api.hf.space/docs
Frontendhttps://janrakshak-frontend.vercel.app

šŸ“” API Endpoints

GET /

Health check and basic info.

json
{
  "status": "JanRakshak Vision API āœ…",
  "version": "1.0.0",
  "team": "Anonymous Group",
  "leader": "Kushal Soni",
  "competition": "Tradition Hacks 2026",
  "limits": {
    "image_max": "50MB",
    "video_max": "100MB",
    "rate_image": "10 requests/minute per IP",
    "rate_video": "5 requests/minute per IP"
  }
}

POST /analyze/image

Upload any image (JPG, PNG, WEBP, GIF, BMP — max 50MB)

Response:

json
{
  "verdict": "FAKE",
  "confidence": 88,
  "fake_score": 0.8842,
  "real_score": 0.1158,
  "explanation": {
    "en": "This image shows 88% signs of AI generation...",
    "hi": "इस ą¤¤ą¤øą„ą¤µą„€ą¤° ą¤®ą„‡ą¤‚ 88% AI ą¤Øą¤æą¤°ą„ą¤®ą¤¾ą¤£ ą¤•ą„‡ ą¤øą¤‚ą¤•ą„‡ą¤¤ ą¤¹ą„ˆą¤‚...",
    "bn": "ą¦ą¦‡ ছবিতে 88% AI তৈরির ą¦²ą¦•ą§ą¦·ą¦£ রয়েছে..."
  },
  "file_type": "image",
  "file_name": "photo.jpg",
  "frames_analyzed": null,
  "model_votes": [
    { "name": "detector_v2", "fake_score": 0.95, "verdict": "FAKE", "confidence": 95 },
    { "name": "sdxl",        "fake_score": 0.82, "verdict": "FAKE", "confidence": 82 },
    { "name": "general",     "fake_score": 0.85, "verdict": "FAKE", "confidence": 85 }
  ]
}

POST /analyze/video

Upload any video (MP4, AVI, MOV, MKV — max 100MB)

Same response format + frames_analyzed count + frame_breakdown array (per-frame verdicts), plus avg_fake_score and real_score averaged across frames.


šŸ¤– The "3-Brain" AI Ensemble (v7)

Three models run in parallel, combined with a custom Smart Heuristic Engine:

ModelHuggingFace IDWeightSpecialty
detector_v2 (Gen-AI)haywoodsloan/ai-image-detector-deploy35%Generative AI (Midjourney, DALL-E, SDXL)
sdxl (Texture)Organika/sdxl-detector35%Pixel noise, texture artifacts
general (Composites)umm-maybe/AI-image-detector30%Composite edits, face-swaps, Photoshop

Smart Heuristic Logic:

  • —High-Confidence Boost: If any single model >85% FAKE, final score is boosted.
  • —Composite Floor: If Brain 3 (Composites) ≄70%, final verdict floored to SUSPICIOUS.
  • —Screenshot Filter: Detects UI screenshots (low color count + low variance) and dampens the fake score by 60% to prevent false positives.
  • —Thresholds: FAKE ≄ 50%, SUSPICIOUS ≄ 30%, REAL < 30%

šŸ—ļø Architecture

React Frontend (Vercel)
        │
        │ HTTPS POST /analyze/image
        ā–¼
FastAPI Backend (HuggingFace Space — Docker)
        │
        ā”œā”€ā”€ Brain 1: haywoodsloan (35%)
        ā”œā”€ā”€ Brain 2: Organika (35%)
        └── Brain 3: umm-maybe (30%)
                │
                └── Smart Heuristic Engine (Python)
                        │
                        └── FAKE / SUSPICIOUS / REAL

šŸš€ Local Development

bash
# Install dependencies
pip install -r requirements.txt

# Run locally
uvicorn app:app --reload --port 8000

# Test API
curl -X POST "http://localhost:8000/analyze/image" \
  -F "file=@test_image.jpg"

šŸ“ Project Structure

janrakshak-backend/
ā”œā”€ā”€ app.py              # FastAPI routes, Rate Limiting (slowapi), CORS, lifespan
ā”œā”€ā”€ models.py           # 3-model ensemble inference & heuristic engine
ā”œā”€ā”€ utils.py            # PIL helpers, video frame extraction, memory mgmt
ā”œā”€ā”€ requirements.txt    # Python dependencies
└── Dockerfile          # HuggingFace Space Docker config

šŸ”’ Privacy & Zero-Storage

  • —Zero storage — files analyzed in RAM, never written to disk (except temp video files, instantly deleted via os.unlink).
  • —Memory Management — explicitly calls del and gc.collect() after every inference to free memory instantly.
  • —No logging — image contents, user IPs, and hashes are never stored.

<div align="center"> Built for Tradition Hacks 2026 | Leader: Kushal Soni | Anonymous Group </div>