A simple web application that detects if an image is real or AI-generated. No training required - works immediately! Features a modern Svelte frontend and FastAPI backend.
The baseline detector uses statistical feature analysis:
- Extract Features: Gradient variance, entropy, edge density, luminance statistics
- Rule-Based Classification: Real images have higher variance/entropy, AI images are smoother
- Output: Label (real/ai) with confidence score
No training required - works immediately on any image!
INSTALL.bat1. Install Python dependencies:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt2. Install frontend dependencies:
cd frontend-svelte
npm install
cd ..RUN_ALL.batTerminal 1 - Backend:
venv\Scripts\activate
python app.pyTerminal 2 - Frontend:
cd frontend-svelte
npm run devAccess:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Detect: Upload an image → Get instant result (real or AI)
- Analytics: View detection statistics and history
No training needed - the baseline detector works immediately!
from baseline_detector import predict
# Predict on an image (no training needed!)
result = predict("path/to/image.jpg")
print(f"Label: {result['label']}")
print(f"Confidence: {result['confidence']:.2%}")
print(f"Reasons: {result['reasons']}"){
"label": "real" or "ai",
"confidence": 0.0-1.0,
"score": float,
"features": {...},
"reasons": ["reason1", "reason2", "reason3"]
}- No Training Required: Works immediately on any image
- Fast Detection: <0.5 seconds per image
- Statistical Analysis: Uses gradient patterns to detect AI images
- Simple API: Just upload and get results
- Web Interface: Modern Svelte frontend
Backend:
- Python 3.8+
- FastAPI, Uvicorn
- NumPy, SciPy, scikit-learn
- OpenCV
Frontend:
- Node.js 18+
- npm/yarn/pnpm
See requirements.txt for complete Python dependencies.
- Accuracy: ~70-75% (baseline)
- Speed: <0.5 seconds per image
- No Training: Works immediately
- Lightweight: Minimal dependencies
For better accuracy, consider implementing neural network approaches (EfficientNet, Vision Transformer).
This implementation follows the mathematical pipeline described in the reference image and is provided as-is for research and educational purposes.