Detects whether an image or video is AI-generated using:
- EfficientNet-B4 neural classifier
- FFT frequency analysis for artifact detection
- Ensemble scoring (80% neural + 20% FFT)
pip install -r requirements.txtpython app.pyOpen http://localhost:5000 in your browser.
ai-detector/
├── app.py # Flask web server
├── model.py # Model loading + inference
├── train.py # Fine-tuning script
├── requirements.txt
├── models/
│ └── detector.pth # (optional) fine-tuned weights
├── templates/
│ └── index.html # Frontend UI
└── data/ # (for training only)
├── train/
│ ├── real/
│ └── fake/
└── val/
├── real/
└── fake/
-
Organize images into
data/train/real,data/train/fake,data/val/real,data/val/fake -
Run:
python train.pyThe best checkpoint is saved to models/detector.pth and auto-loaded by the app.
| Dataset | Link |
|---|---|
| CIFAKE | https://www.kaggle.com/datasets/birdy654/cifake-real-and-ai-generated-synthetic-images |
| CNNDetection | https://github.com/peterwang512/CNNDetection |
| GenImage | https://github.com/GenImage-Dataset/GenImage |
| FaceForensics++ | https://github.com/ondyari/FaceForensics (for deepfake video) |
Swap efficientnet_b4 in model.py for any timm model, or load weights from:
- UniversalFakeDetect: strongest for diffusion images
- FaceForensics++: best for deepfake faces in video
-
No fine-tuned weights = ImageNet pretrained only (weaker, but still runs)
-
Video analysis samples 1 frame every 15 frames (configurable in
model.py) -
Heavy JPEG compression degrades detection accuracy
-
Confidence shown is for AI Generated — lower = more likely real
-
The Working Link (" https://maheshepili.github.io/Ai-Detector/ ")