Skip to content

Repository files navigation

DeepGuard AI

A deepfake detection web application built with Nuxt 3. Analyzes images, videos, and audio files for signs of AI generation or manipulation using a combination of ML model inference and forensic heuristics.

Features

  • Image analysis — ML model (ViT) + ELA, frequency domain (2D FFT), noise consistency, edge analysis, color channels, JPEG Q-table forensics, pixel artifact detection, metadata forensics
  • Video analysis — Per-frame ML inference, temporal consistency, inter-frame motion flow, metadata checks
  • Audio analysis — PCM spectral analysis, voice characteristics, dynamics, pattern repetition
  • Comparison mode — Side-by-side analysis of two files
  • Visual effects — Scan overlay during analysis, verdict stamp, ELA heatmap, verdict glow borders
  • Export & sharing — JSON export, print report, QR code sharing, copy link
  • Analysis history — Last 20 analyses stored in localStorage
  • Security — Magic byte MIME validation, rate limiting, CSP headers

Tech Stack

  • Framework: Nuxt 3 (Vue 3 + Nitro server)
  • Styling: Tailwind CSS
  • ML Inference: ONNX Runtime (ViT-based deepfake classifier)
  • Image Processing: sharp (libvips)
  • Animations: GSAP
  • No external APIs — Fully local analysis, no API keys required

Setup

npm install

ML Model Setup (recommended)

Download the pre-trained ViT deepfake detection model for ~92% accuracy:

npm run model:setup

This downloads the Deep-Fake-Detector-v2 model (83 MB quantized, ViT architecture trained on 56K images).

Without a model, the app falls back to heuristic-only analysis (lower accuracy).

Custom Model Training

Train your own model on any combination of datasets:

pip install torch torchvision transformers datasets pillow onnx onnxruntime

# Quick training on 10K images
python scripts/train-model.py --dataset prithivMLmods/Deepfake-VS-Real-10k --epochs 10

# Maximum accuracy — combine multiple datasets
python scripts/train-model.py \
  --dataset prithivMLmods/Deepfake-VS-Real-10k \
  --dataset2 prithivMLmods/Deepfake-Image-Detection-70k \
  --dataset3 OpenRL/DeepFakeArt-Challenge \
  --epochs 20

# Train on local data (folder with real/ and fake/ subdirs)
python scripts/train-model.py --data-dir ./training-data --epochs 15

The training script fine-tunes a ViT model, exports to ONNX, and saves the config — ready for immediate use.

Development

npm run dev

Production

npm run build
node .output/server/index.mjs

Detection Pipeline

With ML Model (recommended)

The ViT model receives 90% confidence weight in the final score. Heuristic dimensions (noise, edges, ELA, frequency) provide supplementary signals with lower weights. This produces ~92% accuracy.

Without ML Model

Forensic heuristics only — scores are calibrated conservatively to minimize false positives. Weak signals (missing EXIF, uniform noise, soft edges) receive low scores. The system will output inconclusive when confidence is too low for a definitive verdict.

Analysis Dimensions

Dimension Confidence Weight What It Detects
ML Model 90 Learned visual patterns of AI generation
Metadata 40 AI tool signatures, EXIF anomalies, camera data
ELA 35 Compression inconsistencies (splicing)
Frequency Domain 35 GAN upsampling artifacts (2D FFT)
Noise Consistency 30 Uniform vs heteroscedastic noise patterns
Pixel Artifacts 30 Checkerboard patterns, symmetry, color banding
JPEG Forensics 25 Quantization table analysis, recompression
Edge Analysis 20 Edge sharpness consistency
Color Channels 20 Channel correlation patterns
Quality 15 Compression level anomalies

Verdicts

  • Authentic — Score below 35%, confidence above 25%
  • Suspicious — Score 35-65%
  • Deepfake — Score above 65%
  • Inconclusive — Confidence below 25% (insufficient data for a verdict)

Project Structure

pages/
  index.vue          — Landing page
  detect.vue         — Upload + analyze
  results/[id].vue   — Results display
  compare.vue        — Side-by-side comparison

server/
  api/analyze/
    image.post.ts    — Image analysis endpoint
    video.post.ts    — Video analysis endpoint
    audio.post.ts    — Audio analysis endpoint
  utils/
    ai-providers.ts      — ONNX model inference + image forensics
    image-forensics.ts   — ELA, 2D FFT, JPEG Q-tables, pixel artifacts, metadata
    scoring-config.ts    — Centralized scoring thresholds
    mime-validation.ts   — Magic byte file validation
    audio-decode.ts      — PCM decoding + audio analysis
  middleware/
    rate-limit.ts        — Token bucket rate limiting
    security-headers.ts  — CSP + security headers

models/
  deepfake-detector.onnx  — ML model (downloaded via npm run model:setup)
  config.json             — Model configuration

scripts/
  download-model.mjs  — Download pre-trained model from HuggingFace
  train-model.py       — Train custom model on datasets

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages