Spaces:
Running
title: VeriFile-X API
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
VeriFile-X
Forensic-Grade AI Image Detection
VeriFile-X β Unmask AI Content with Confidence
Theme Options
| Theme | Description |
|---|---|
| Animated | Three.js 3D background with floating objects and mouse parallax |
| Dark | Clean dark forensics theme |
| Light | Professional light theme |
26 Detection Signals Β· 85β92% Accuracy Β· Court-Ready Analysis
Can you tell if an image was made by AI? VeriFile-X can β with forensic precision.
What Is VeriFile-X?
VeriFile-X is an open-source forensic AI image detection platform. It analyzes any image using 26 independent detection signals across multiple state-of-the-art methods β diffusion reconstruction, semantic embeddings, statistical forensics, generator attribution, and platform fingerprinting β and returns a detailed, transparent report showing exactly why it made its decision.
Designed for researchers, journalists, legal professionals, and developers who need more than just a number.
Live Detection Examples
| Input | AI Probability | Verdict |
|---|---|---|
| Midjourney generated portrait | 94% | π΄ Likely AI Generated |
| Real DSLR photograph | 8% | π’ Likely Authentic |
| Stable Diffusion landscape | 87% | π΄ Likely AI Generated |
| Phone camera selfie | 12% | π’ Likely Authentic |
| DALL-E 3 architectural render | 91% | π΄ Likely AI Generated |
Detection Methods
DIRE β Diffusion Reconstruction Error
Based on DIRE (ICCV 2023)
Reconstructs the image using Stable Diffusion 2.1 and measures how well the model can reproduce it. AI-generated images fit the diffusion distribution perfectly (low error). Real photographs do not.
- Detects: Stable Diffusion, DALL-E 3, Midjourney, Adobe Firefly
- Accuracy: 85β92% on diffusion models
CLIP Universal Detection
Based on UnivFD (CVPR 2023)
Uses OpenAI CLIP embeddings to measure semantic distance from learned real vs. AI image centroids. Generalizes to unseen generators without retraining.
- Accuracy: 85β92% across all generator types
- Zero-shot: works on generators it has never seen before
Own EfficientNet Embedding Detector
Custom-trained EfficientNet-B0 binary classifier fine-tuned on 408K+ images (208K real, 200K AI). Combined with centroid-based similarity scoring for maximum accuracy.
- Trained on: CelebA, FFHQ, COCO, DIV2K, StyleGAN2, Stable Diffusion
- Method: Direct classification + cosine distance to learned centroids
Statistical Analysis β 19 Signals
Analyzes pixel-level patterns, frequency domain artifacts, and statistical distributions that differ systematically between AI-generated and real images.
| Signal | What It Measures |
|---|---|
| Mahalanobis Distance | Deviation from natural image statistics |
| KL Divergence | Pixel intensity distribution anomalies |
| Perturbation Stability | Sensitivity to added noise |
| FFT Radial Spectrum | Frequency domain artifact fingerprint |
| DCT Coefficients | JPEG compression pattern anomalies |
| Wavelet Energy | Multi-scale texture inconsistencies |
| Eigenvalue Spread | Covariance structure of image patches |
| Local Covariance | Spatial correlation abnormalities |
| Patch Anisotropy | Directional texture variance |
| RGB Noise Covariance | Cross-channel noise correlation |
| Patch Spectral Variance | Frequency variance across regions |
| Natural Prior Deviation | Distance from natural image priors |
| Laplacian Variance | Noise level and edge sharpness |
| Color Entropy | HSV histogram distribution |
| GLCM Texture | Gray-level co-occurrence matrix features |
| LBP Texture | Local binary pattern analysis |
| Edge Statistics | Unnatural edge distribution patterns |
| Spectral Entropy | Frequency band energy distribution |
| Compression Artifacts | JPEG block artifact inconsistencies |
Additional Forensic Signals
| Signal | What It Detects |
|---|---|
| PRNU | Camera sensor fingerprint (absence = no real camera) |
| ELA | Error Level Analysis β JPEG compression inconsistencies |
| DCT Frequency | GAN checkerboard artifacts in frequency domain |
| Metadata Forensics | Missing/inconsistent EXIF and AI software markers |
Generator Attribution
Classifies AI-generated images into generator families using DCT frequency fingerprints:
stylegan Β· dalle3 Β· sd14 Β· sdxl Β· midjourney Β· real Β· unknown
Platform Forensics
Detects social media re-encoding signatures via JPEG quantization table fingerprinting:
whatsapp Β· instagram Β· discord Β· telegram Β· twitter_x Β· facebook Β· original
C2PA Provenance Verification
Checks for Coalition for Content Provenance and Authenticity (C2PA) credentials:
verified Β· partial Β· none Β· tampered
XGBoost Ensemble Fusion
All 26 signals are fed into a trained XGBoost classifier for the final decision. Signal contributions are derived from 5-fold cross-validated performance, not manual weights. SHAP values provide per-signal explainability.
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend β
β GitHub Pages Β· Plain HTML/CSS/JS β
β Upload β 26 Signals Β· Hashes Β· EXIF Β· Heatmap Β· Export β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β POST /api/v1/analyze/image
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β Backend β FastAPI + Uvicorn β
β HuggingFace Spaces Β· Docker Β· Python 3.11 β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β ImageForensics β β
β β βββ extract_exif() β β
β β βββ generate_hashes() SHA256Β·MD5Β·pHash β β
β β βββ detect_tampering() FlagsΒ·Confidence β β
β β βββ detect_ai_generation() β β
β β β βββ AdvancedEnsembleDetector (26 signals) β β
β β βββ attribute_generator() StyleGAN/DALLE/SD/MJ β β
β β βββ detect_platform() Social media fingerprintβ β
β β βββ verify_c2pa() Content credentials β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β API Endpoints: /analyze/* Β· /cases/* Β· /keys/* β
β Security: Rate limiting Β· MIME validation Β· In-memory β
β Caching: SHA256-keyed LRU Β· 60min TTL Β· 500 entries β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
API Reference
Analyze an Image
curl -X POST https://abinazebinoy-verifile-x-api.hf.space/api/v1/analyze/image \
-F "file=@your_image.jpg"
All Endpoints
| Method | Endpoint | Description | Rate Limit |
|---|---|---|---|
GET |
/health |
Health check | None |
POST |
/api/v1/analyze/image |
Full forensic analysis (max 10MB) | 10/min |
POST |
/api/v1/analyze/image/heatmap |
Grad-CAM localization heatmap | 5/min |
POST |
/api/v1/analyze/attribution |
Generator attribution | 10/min |
POST |
/api/v1/analyze/platform |
Social media platform detection | 10/min |
POST |
/api/v1/analyze/c2pa |
C2PA provenance verification | 10/min |
POST |
/api/v1/analyze/robustness |
Adversarial robustness test | 2/min |
POST |
/api/v1/analyze/batch |
Batch analysis (up to 10 images) | 2/min |
POST |
/api/v1/analyze/export/{fmt} |
Export report (pdf/json/csv) | 5/min |
POST |
/api/v1/cases/ |
Create investigation case | 20/min |
GET |
/api/v1/cases/ |
List cases | 30/min |
GET |
/api/v1/cases/search |
Search cases | 20/min |
GET |
/api/v1/cases/{id} |
Get case details | 30/min |
POST |
/api/v1/cases/{id}/evidence |
Add evidence to case | 20/min |
PATCH |
/api/v1/cases/{id}/status |
Update case status | 20/min |
GET |
/api/v1/keys/verify |
Verify API key | 30/min |
GET |
/api/v1/metrics |
System observability metrics | 30/min |
POST |
/api/v1/metrics/reset |
Reset metrics counters | 5/min |
GET |
/docs |
Interactive API documentation | None |
Classification Labels
| Label | Probability | Meaning |
|---|---|---|
likely_ai_generated |
> 80% | Strong multi-signal evidence of AI generation |
likely_ai_generated |
70β80% | High confidence AI indicators |
possibly_ai_generated |
50β70% | Multiple signals indicate AI, not conclusive |
possibly_authentic |
30β50% | Likely real, some minor anomalies |
likely_authentic |
< 30% | Strong evidence of authentic photograph |
Quick Start
git clone https://github.com/abinaze/VeriFile-X.git
cd VeriFile-X
# Linux/macOS
sudo apt-get install -y libmagic1
pip install -r backend/requirements.txt
# Windows
pip install -r backend/requirements-windows.txt
export PYTHONPATH=$(pwd)
uvicorn backend.main:app --host 0.0.0.0 --port 8000
# Open interactive docs
open http://localhost:8000/docs
Tech Stack
| Layer | Technology |
|---|---|
| Backend | FastAPI 0.115 Β· Uvicorn Β· Python 3.11 |
| AI Detection | PyTorch 2.6 Β· OpenAI CLIP Β· EfficientNet-B0 Β· Stable Diffusion 2.1 |
| Ensemble | XGBoost + SHAP explainability Β· 26-signal feature matrix |
| Image Processing | OpenCV Β· Pillow Β· scikit-image Β· PyWavelets |
| Statistical Analysis | NumPy Β· SciPy Β· scikit-learn |
| Hashing | hashlib (SHA256/MD5) Β· imagehash (perceptual) |
| Security | slowapi rate limiting Β· python-magic MIME validation Β· SHA-256 API keys |
| Caching | In-memory SHA256-keyed LRU Β· 60min TTL |
| Storage | Append-only JSONL (cases, audit log, API keys) |
| Frontend | Plain HTML5 Β· CSS3 Β· Vanilla JavaScript Β· Three.js |
| CI/CD | GitHub Actions Β· flake8 Β· mypy Β· pip-audit |
| Deployment | HuggingFace Spaces (Docker) Β· GitHub Pages |
Security
- Rate limited: per-endpoint limits from 2β30 requests/minute per IP
- Double MIME validation: Content-type header + python-magic file signature
- In-memory only: Uploaded files are never written to disk
- API keys: SHA-256 hashed, raw key shown once, never stored
- RBAC: viewer / analyst / admin role hierarchy
- No data stored: Cache stores results only, cleared on restart
- Zero tracking: No analytics, no cookies, no accounts required
Tests
# Run all fast tests
pytest backend/tests/ -v -m "not slow" --tb=short
# Run with coverage
pytest backend/tests/ --cov=backend --cov-report=html
200+ tests covering all 26 signals, API endpoints, batch processing, case management, platform detection, C2PA verification, adversarial robustness, and invariant/property-based tests.
Phases Completed
| Phase | Feature | Status |
|---|---|---|
| 1 | Dataset foundation (408K+ images) | β |
| 2 | EfficientNet embedding detector | β |
| 3 | Centroid database + ensemble | β |
| 4 | XGBoost trained ensemble + SHAP | β |
| 5 | Grad-CAM localization heatmap | β |
| 6 | Generator attribution classifier | β |
| 7 | Social media platform forensics | β |
| 8 | C2PA content credentials | β |
| 9 | Adversarial robustness testing | β |
| 10 | Batch investigation mode | β |
| 11 | Evidence case management | β |
| 12 | Report export suite (PDF/JSON/CSV) | β |
| 13 | API keys + RBAC | β |
| 14 | CI coverage + hardening | β |
| 15 | System hardening + quality gate | β |
| 16 | Monitoring + inconclusive verdict + image type | β |
| 17 | Frontend hardening + rate limit consolidation | β |
Known Limitations
- DIRE requires ~4GB Stable Diffusion model download on first use β falls back to neutral score in memory-constrained environments
- Generator attribution uses rule-based heuristics (~60β70% accuracy) when no trained attribution model is present
- Heavily edited real images may produce false positives
- Images smaller than 32Γ32 pixels are automatically skipped
Not a replacement for human expert review. Always treat results as one forensic input, not a definitive verdict.
Contributing
git checkout -b feature/your-feature
# make changes
pytest backend/tests/ -v
git commit -m "feat: your description"
git push origin feature/your-feature
# open a Pull Request
See CONTRIBUTING.md for full guidelines.
License
MIT β free to use, modify, and distribute. See LICENSE.
Built with precision Β· Open source forever