A full-stack AI application that detects AI-generated (Deepfake) faces using an Xception-based Convolutional Neural Network.
Live Demo: https://rohan45327-deepfake-image-analyzer.hf.space/
Note: The live link was published via HuggingFace 🤗 so it will take 5-10 seconds to load at first instance.
- Real-time Analysis: Upload any JPG/PNG image to determine if a face is real or manipulated.
- Xception Model: Leverages a pre-trained Xception network fine-tuned for facial forensics.
- FastAPI Backend: High-performance Python API for handling model inference.
- React Frontend: Modern, responsive UI built with Vite and Three.
- Production Ready: Fully deployed on HuggingFace with Docker, Git LFS for large model storage.
| Component | Technology |
|---|---|
| Frontend | React, Vite, Axios, three |
| Backend | FastAPI, Gunicorn, Uvicorn |
| Deep Learning | PyTorch, Torchvision, Xception |
| Deployment | HuggingFace, Docker, Git LFS |
| Model | FaceForensics++ |
- Preprocessing: The uploaded image is resized to 299x299 pixels and normalized.
- Inference: The tensor is passed through the Xception model, which analyzes high-frequency noise and facial textures often ignored by the human eye.
- Result: The model returns a confidence score. If the score is > 0.5, the image is flagged as a potential Deepfake.
The model was trained using the FaceForensics++ dataset, a benchmark for facial manipulation detection.
- Diverse Methods: It contains thousands of videos manipulated by four automated methods: Deepfakes, Face2Face, FaceSwap, and NeuralTextures.
- Real vs. Fake: It provides a balanced set of authentic and tampered imagery, allowing the model to learn the subtle "fingerprints" left by generative AI.
For the core architecture, I utilized the Xception (Extreme Inception) model.
- Depthwise Separable Convolutions: Unlike standard CNNs, Xception looks at cross-channel correlations and spatial correlations separately. This makes it highly efficient at finding fine-grained artifacts in skin textures.
- Transfer Learning: The model uses weights pre-trained on ImageNet, then fine-tuned on FaceForensics++ to specialize in identifying the boundary between real and synthetic pixels.
.
├── main.py # FastAPI Entry Point & API Routes
├── model_service.py # Logic for Model Loading & Inference
├── requirements.txt # Python Dependencies
├── network/ # Xception Architecture & Neural Network Files
│ └── models.py
├── deepfake_interface/ # Frontend (React + Three.js)
│ ├── src/
│ │ ├── components/ # UI Components & 3D Visuals
│ │ └── services/ # API Call Logic (Axios)
│ └── vite.config.js
└── model/ # Model Weights (Stored via Git LFS)
└── xception_model.pkl
- Clone the Repo
git clone https://github.com/rohan45327/Deep-Fake-Image-Analyzer.git cd Deep-Fake-Image-Analyzer - Backend Setup
pip install -r requirements.txt uvicorn main:app --reload
- Frontend Setup
cd deepfake_interface npm install npm run dev
While the Xception model is highly effective, it may produce inaccurate results in the following scenarios:
- Low-Resolution Images: Deepfake detection often relies on micro-textures. If an image is heavily compressed or blurry, the model may miss the artifacts of manipulation.
- Extreme Lighting/Angles: If the face is in deep shadow or at an extreme side profile, the feature extraction may be less reliable.
- Adversarial Attacks: Sophisticated deepfakes specifically designed to fool CNNs (adversarial examples) may bypass detection.
- Multiple Faces: The current version is optimized for single-face analysis; performance may vary when multiple subjects are in the frame.
- New Generative Techniques: As GANs and Diffusion models (like Sora or Midjourney v6) evolve, the artifacts they leave behind change, requiring constant model retraining.