File size: 20,276 Bytes
d89b78a 470a637 3337c5d 470a637 3337c5d 6b659dc 470a637 6b659dc 470a637 6b659dc 470a637 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | ---
title: Authrix Deepfake Detector
emoji: π
colorFrom: green
colorTo: green
sdk: docker
pinned: false
app_port: 7860
license: mit
---
<div align="center">
# π AUTHRIX
### AI-Powered Deepfake Detection Engine
[](https://python.org)
[](https://fastapi.tiangolo.com)
[](https://react.dev)
[](https://huggingface.co)
[](https://docker.com)
[](LICENSE)
**Authrix** is a full-stack, multi-agent deepfake detection platform that analyzes videos for AI-generated content using a Vision Transformer (ViT) ensemble, temporal consistency analysis, C2PA metadata scanning, and AI audio detection β all wrapped in a sleek cyberpunk-themed dashboard and a Chrome extension.
[π Live Demo](https://aarav13-authrix.hf.space) Β· [π§© Chrome Extension](#browser-extension) Β· [π‘ API Reference](#api-reference) Β· [π¬ Pricing](#pricing--tiers)
</div>
---
## β¨ Key Features
| Feature | Description |
|---|---|
| π§ **ViT Ensemble** | 2-model Vision Transformer ensemble (dima806 + prithivMLmods) with float16 batched inference |
| ποΈ **Temporal Analysis** | Detects AI video patterns: unnatural motion smoothness, temporal flickering, color drift |
| π **C2PA / Metadata Scan** | Identifies AI generator signatures from Veo3, Sora, Runway, Firefly, Kling, etc. |
| π **Audio Detection** | Spectral analysis for AI voice synthesis & audio-visual mismatch detection |
| π **Browser Extension** | Chrome/Edge extension (MV3) that captures tab video stream for real-time analysis |
| π **URL Analysis** | Paste any YouTube/TikTok/Twitter/Instagram URL β powered by yt-dlp |
| π **API Key System** | Tiered access control with per-month usage quotas and Stripe billing integration |
| π³ **Docker + Render** | One-command deployment to Render (or any Docker host / HuggingFace Spaces) |
---
## ποΈ Architecture
```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT LAYER β
β βββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββ β
β β React Frontend β β Chrome Extension β β REST API β β
β β (Vite + TW4) β β (MV3, JS) β β Consumers β β
β ββββββββββ¬βββββββββ ββββββββββ¬ββββββββββ βββββββ¬βββββββ β
βββββββββββββΌβββββββββββββββββββ βΌβββββββββββββββββββ βΌβββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI BACKEND β
β β
β POST /analyze POST /analyze-url GET /health β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β DETECTION PIPELINE β β
β β β β
β β Agent 0a: Metadata Agent (C2PA / AI tool scan) β β
β β Agent 0b: Temporal Agent (flicker / motion CV) β β
β β Agent 1: Frame Extractor (dedup, 40-frame sample) β β
β β Agent 2: Face Detector (MediaPipe, single ctx) β β
β β Agent 3: Decision Agent (ViT ensemble, float16) β β
β β Agent 4: Report Agent (calibrated + audio fused) β β
β β Agent 5: Audio Agent (librosa spectral + AV sync)β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### Detection Pipeline
1. **Metadata Agent** β Binary-scans the first 512 KB + last 64 KB of the video file for C2PA markers, XMP tags, and known AI-generator signatures (Veo, Sora, Runway, Kling, Fireflyβ¦). If a C2PA block is found, the file is immediately flagged with 98% confidence.
2. **Temporal Agent** β Measures pixel-level temporal variance, frame-difference coefficient of variation, high-frequency noise consistency, and color-channel drift across frames. Catches modern AI video generators that produce unnaturally smooth motion.
3. **Frame Extractor** β Intelligently samples up to 40 deduplicated frames, skipping near-identical consecutive frames to save inference time.
4. **Face Detector** β MediaPipe face detection runs in a **single context** across all frames (avoids repeated model init) and crops each face with 20% padding.
5. **Decision Agent (ViT Ensemble)** β All face crops are sent to **both ViT models in a single batched forward pass** (float16). Model 2 is early-exited if Model 1 is already very confident (>88% or <12%). Scores are ensemble-weighted 55/45.
6. **Audio Agent** β Extracts audio track via MoviePy/ffmpeg, runs librosa spectral analysis to detect AI voice synthesis, unnatural pitch/tempo regularity, and audio-visual sync mismatches.
7. **Report Agent** β Fuses all signals with an adaptive threshold. A C2PA hard match always wins; audio-visual mismatch overrides visual; otherwise, temporal + visual ensemble determines the final verdict with calibrated confidence.
---
## ποΈ Project Structure
```
authrix/
βββ backend/ # FastAPI backend
β βββ main.py # App entry point, routes, middleware
β βββ detector.py # Core multi-agent detection engine (all 5 agents)
β βββ audio_detector.py # Audio analysis agent (librosa + AV sync)
β βββ auth.py # API key validation, tier limits
β βββ stripe_integration.py # Stripe billing hooks
β βββ create_owner_key.py # CLI helper to mint API keys
β βββ test_temporal.py # Unit tests for temporal analysis
β βββ requirements.txt # Python dependencies
β βββ uploads/ # Temp upload directory (auto-cleaned)
β
βββ frontend/ # React 19 + Vite 8 + Tailwind 4 dashboard
β βββ src/
β β βββ components/ # UI components (Loader, ResultCard, etc.)
β β βββ main.jsx # App entry
β βββ index.html
β βββ package.json
β βββ vite.config.js
β
βββ frontend-vanilla/ # Vanilla HTML/JS fallback frontend
β βββ index.html
β βββ pricing.html
β βββ script.js # ~15KB β full upload + results UI
β
βββ extension/ # Chrome Extension (Manifest V3)
β βββ manifest.json # Permissions, MV3 config
β βββ background.js # Service worker (tab capture)
β βββ content.js # Content script (overlay injection)
β βββ offscreen.js # Offscreen document for MediaRecorder
β βββ popup.html / popup.js # Extension popup UI
β βββ overlay.css # Injected overlay styles
β βββ icons/ # Extension icons (16/48/128px)
β
βββ Dockerfile # Multi-stage Docker build
βββ render.yaml # Render.com deployment config
βββ setup.sh / setup.bat # One-command environment setup
βββ start.sh / start.bat # Dev server launcher
βββ BUSINESS_MODEL.md # Monetization guide & pricing
```
---
## π Getting Started
### Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Backend runtime |
| Node.js | 18+ | Frontend build |
| npm / pnpm | Latest | JS package manager |
| ffmpeg | Any | Video conversion (auto-bundled via imageio-ffmpeg) |
| Docker | 24+ | Containerized deployment (optional) |
> **Windows users:** ffmpeg is bundled via `imageio-ffmpeg` β no manual install required.
---
### Option A β Quick Start (Local Dev)
#### 1. Clone the Repository
```bash
git clone https://github.com/Aarav-bit/Authrix.git
cd Authrix
```
#### 2. Backend Setup
```bash
cd backend
python -m venv ../venv
# Activate (Linux/macOS)
source ../venv/bin/activate
# Activate (Windows)
..\venv\Scripts\activate
pip install -r requirements.txt
```
> **Note:** First startup downloads ~2 GB of ViT model weights from HuggingFace. Subsequent starts use the local cache.
#### 3. Start the Backend
```bash
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
```
The API will be live at **http://localhost:8000** and the vanilla frontend will be served automatically.
#### 4. (Optional) Start the React Frontend
```bash
cd ../frontend
npm install
npm run dev
```
React dashboard available at **http://localhost:5173**.
---
### Option B β One-Command Setup Scripts
```bash
# Linux / macOS
./setup.sh
./start.sh
# Windows
setup.bat
start.bat
```
---
### Option C β Docker
```bash
# Build image
docker build -t authrix .
# Run
docker run -p 7860:7860 authrix
```
Open **http://localhost:7860**.
---
## π Deployment
### Render (Recommended)
1. Fork this repository.
2. Create a new **Web Service** on [Render](https://render.com).
3. Connect your GitHub repo β Render auto-detects `render.yaml`.
4. Set env vars (see below).
5. Deploy. β
`render.yaml` configures:
- Runtime: Docker
- Health check: `GET /health`
- Port: `8000`
### HuggingFace Spaces
The `Dockerfile` is pre-configured for HuggingFace Spaces (port 7860, user 1000) and pre-caches both ViT models at build time.
1. Create a new Space β **Docker** runtime.
2. Push this repo as the Space source.
3. Models are cached in the image β cold start is instant.
### Manual VPS
```bash
# Pull latest
git pull origin main
# Build frontend
cd frontend && npm run build
cp -r dist ../frontend-dist
# Install Python deps
cd ../backend
pip install -r requirements.txt
# Start with Gunicorn (production)
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 2
```
---
## βοΈ Environment Variables
| Variable | Required | Description | Example |
|---|---|---|---|
| `PORT` | No | Port to bind | `8000` |
| `PYTHONUNBUFFERED` | No | Force stdout flush | `1` |
| `STRIPE_SECRET_KEY` | Optional | Stripe billing | `sk_live_...` |
| `STRIPE_WEBHOOK_SECRET` | Optional | Stripe webhooks | `whsec_...` |
> API keys for end-users are stored in `backend/api_keys.json` (auto-generated). No external database required.
---
## π API Reference
### Base URL
```
https://aarav13-authrix.hf.space (production)
http://localhost:8000 (local)
```
### Authentication
Pass your API key as a header. For local development, the key is optional.
```
X-API-Key: authrix_YOUR_KEY_HERE
```
---
### `GET /health`
Check server readiness.
```bash
curl https://aarav13-authrix.hf.space/health
```
**Response:**
```json
{
"status": "ok",
"model": "Ensemble (2 ViT models)",
"ready": true
}
```
---
### `POST /analyze`
Analyze an uploaded video file for deepfake content.
```bash
curl -X POST http://localhost:8000/analyze \
-H "X-API-Key: authrix_YOUR_KEY" \
-F "file=@/path/to/video.mp4"
```
**Supported formats:** `.mp4`, `.avi`, `.mov`, `.mkv`, `.webm`, `.wmv`
**Max file size:** 100 MB
**Response:**
```json
{
"result": "FAKE",
"confidence": 87.3,
"details": {
"visual_score": 0.82,
"audio_result": "AI_VOICE",
"temporal_signals": ["Perfectly uniform motion (CV=0.01)"],
"metadata_signals": ["c2pa", "tool:runway"],
"face_coverage": 0.92,
"frames_analyzed": 38
},
"frame_timeline": [
{ "frame_index": 0, "fake_probability": 0.84 },
{ "frame_index": 5, "fake_probability": 0.79 }
],
"metadata": {
"frames_analyzed": 38,
"frames_with_faces": 35,
"video_duration_sec": 12.4,
"video_fps": 30.0,
"resolution": "1280x720"
}
}
```
---
### `POST /analyze-url`
Analyze a video from a URL (YouTube, TikTok, Twitter, Instagram, etc.).
```bash
curl -X POST http://localhost:8000/analyze-url \
-H "Content-Type: application/json" \
-d '{"url": "https://www.youtube.com/watch?v=..."}'
```
**Response:** Same structure as `/analyze`.
---
### Error Codes
| Status | Meaning |
|---|---|
| `400` | Bad request (unsupported format, invalid URL) |
| `401` | Invalid or missing API key |
| `413` | File too large (>100 MB) |
| `429` | Monthly usage limit exceeded |
| `503` | Server still initializing β retry in 30s |
---
## π° Pricing & Tiers
| Tier | Price | Analyses / Month | Features |
|---|---|---|---|
| **Free** | $0 | 10 | Extension, 2-min videos, community support |
| **Pro** | $9.99/mo | 100 | 10-min videos, API access (100 calls), email support |
| **Business** | $49/mo | 1,000 | Unlimited length, API (5K calls), white-label reports |
| **Enterprise** | Custom | Unlimited | On-premise, custom training, SLA, dedicated support |
### Pay-Per-Use API
| Video Length | Price |
|---|---|
| < 5 min | $0.05 |
| 5β15 min | $0.10 |
| > 15 min | $0.25 |
### Generate an API Key (Self-Hosted)
```bash
cd backend
python create_owner_key.py
# Or:
python -c "from auth import create_api_key; print(create_api_key('you@email.com', 'pro'))"
```
---
## π§© Browser Extension
The Authrix Chrome Extension (v2.2.0, Manifest V3) allows one-click deepfake analysis of any video playing in your browser tab.
### How It Works
1. User clicks the Authrix toolbar icon while a video is playing.
2. The background service worker uses the `tabCapture` API to start recording the tab's media stream.
3. An offscreen document captures ~8 seconds of video via `MediaRecorder`.
4. The clip is posted to the Authrix API and the result is overlaid on the page.
### Install (Developer Mode)
1. Open `chrome://extensions`
2. Enable **Developer Mode** (top-right toggle)
3. Click **Load unpacked** β select the `extension/` folder
4. The Authrix icon appears in your toolbar
### Permissions
| Permission | Reason |
|---|---|
| `tabCapture` | Record tab video stream |
| `scripting` | Inject result overlay |
| `storage` | Cache API key & usage |
| `offscreen` | Run MediaRecorder out-of-context |
| `contextMenus` | Right-click menu |
---
## π οΈ Development
### Backend
```bash
# Run with hot-reload
uvicorn main:app --reload --port 8000
# Run tests
cd backend
python test_temporal.py
# Lint
flake8 . --max-line-length=120
```
### Frontend (React)
```bash
cd frontend
npm run dev # Dev server with HMR
npm run build # Production build β dist/
npm run lint # ESLint
npm run preview # Preview production build
```
### Available Scripts Summary
| Command | Description |
|---|---|
| `uvicorn main:app --reload` | Backend dev server |
| `npm run dev` | React frontend dev server |
| `npm run build` | Build React app for production |
| `python create_owner_key.py` | Generate a new API key |
| `docker build -t authrix .` | Build Docker image |
---
## π¬ Tech Stack
### Backend
- **FastAPI 0.111** β Async REST API with automatic OpenAPI docs
- **Python 3.11** β Core runtime
- **OpenCV 4.9** β Video decoding and frame extraction
- **MediaPipe 0.10** β Face detection (single-context optimized)
- **HuggingFace Transformers** β ViT model loading and inference
- **PyTorch 2.3+** β Float16 batched tensor inference
- **librosa 0.10** β Audio feature extraction and spectral analysis
- **imageio-ffmpeg** β Bundled ffmpeg binary for video conversion
- **yt-dlp** β URL-based video download (YouTube, TikTok, etc.)
- **Stripe** β Payment processing and subscription management
### Frontend
- **React 19** β UI library
- **Vite 8** β Build tool and dev server
- **Tailwind CSS 4** β Utility-first styling
- **Three.js + @react-three/fiber** β 3D particle effects
- **Framer Motion** β Animations
- **Zustand** β Lightweight state management
### Infrastructure
- **Docker** β Containerization
- **Render** β PaaS deployment
- **HuggingFace Spaces** β Model hosting and demo deployment
### AI Models
| Model | Source | Purpose |
|---|---|---|
| `dima806/deepfake_vs_real_image_detection` | HuggingFace | Primary ViT classifier |
| `prithivMLmods/Deep-Fake-Detector-v2-Model` | HuggingFace | Secondary ViT classifier |
---
## π§ Troubleshooting
### Server takes a long time to start
**Cause:** HuggingFace models (~1β2 GB) are being downloaded on first run.
**Fix:** Wait ~2β5 minutes. Subsequent starts use the local cache at `~/.cache/huggingface/`.
### `Could not open video` / OpenCV error on Windows
**Cause:** OpenCV on Windows cannot natively decode `.webm` or `.mkv`.
**Fix:** The backend automatically converts these via bundled ffmpeg. Ensure `imageio-ffmpeg` is installed:
```bash
pip install imageio-ffmpeg
```
### Extension not sending data to the API
**Cause:** The extension is hard-coded to connect to `http://localhost:8000` (dev) or `https://aarav13-authrix.hf.space` (prod).
**Fix:** Update `host_permissions` in `extension/manifest.json` to match your deployment URL, then reload the extension.
### `429 Monthly limit exceeded`
**Cause:** Your API key has hit its monthly quota.
**Fix:** Upgrade your plan, or generate a new owner key locally:
```bash
python create_owner_key.py
```
### `503 Server still initializing`
**Cause:** The ViT models haven't finished loading yet.
**Fix:** Hit `GET /health` and wait until `"ready": true`, then retry.
### Audio analysis not available
**Cause:** `librosa`, `soundfile`, or `moviepy` not installed, or the video has no audio track.
**Fix:**
```bash
pip install librosa soundfile moviepy
```
---
## πΊοΈ Roadmap
- [ ] Firefox extension support
- [ ] Real-time video stream analysis via WebSocket
- [ ] Mobile app (React Native)
- [ ] Batch analysis endpoint for enterprise workflows
- [ ] Webhook notifications for async analysis
- [ ] GDPR-compliant EU data residency option
- [ ] On-premise deployment Helm chart
- [ ] Fine-tuned model on latest Veo3 / Sora outputs
---
## π€ Contributing
Contributions are welcome! Please follow these steps:
1. Fork the repository
2. Create a feature branch: `git checkout -b feat/my-feature`
3. Commit your changes: `git commit -m 'feat: add my feature'`
4. Push to the branch: `git push origin feat/my-feature`
5. Open a Pull Request
Please make sure your code passes linting before submitting.
---
## π License
This project is licensed under the **MIT License** β see the [LICENSE](LICENSE) file for details.
---
## π§ Contact
| Channel | Link |
|---|---|
| Enterprise Sales | enterprise@authrix.ai |
| Live Demo | https://aarav13-authrix.hf.space |
| API Docs | https://aarav13-authrix.hf.space/docs |
---
<div align="center">
**Built with β€οΈ by the Authrix Team**
*Fighting misinformation, one frame at a time.*
</div>
|