Explainable AI for Image Authenticity Detection
DeepGuard is an academic-grade full-stack system designed to detect whether an image is Genuine (Real) or AI-Generated (Fake), providing visual evidence of its decision using Grad-CAM class activation mapping. The system features a custom ResNet50 convolutional neural network, a FastAPI backend, and a high-fidelity glassmorphic React frontend.
- Dual-Layer Forensic Pipeline: Combines deep learning classification with EXIF metadata parsing and AIGC signature audits.
- EXIF & AIGC Metadata Scanner: Automatically parses embedded camera metadata (make, model, software, creation dates) and scans PNG/JPEG text chunks for AI signatures (e.g., Stable Diffusion prompt parameters, Midjourney metadata, and DALL-E tags). AI-detected metadata automatically overrides classification to
AI-Generatedwith 100% confidence. - Interactive Heatmap Opacity Blender: An interactive slider overlay in the React UI allows users to dynamically blend and fade the Grad-CAM activation heatmap on top of their uploaded image.
- Memory-Optimized Cloud Fallback: Features a robust, silent
FORCE_MOCK_MODEenvironment toggle. If enabled (e.g., on Render's 512MB free tier to prevent Out-of-Memory crashes) or if TensorFlow is missing, the backend runs in a fast, lightweight mock mode (~35MB RAM). - Premium Glassmorphic Design: Clean typography with Google Font Plus Jakarta Sans, vibrant color states, smooth animations, and fully responsive grid layouts.
[ User Uploads Image ]
β
[ React Frontend ] (Vite + Plus Jakarta Sans + Axios)
β POST /predict
[ FastAPI Backend ] (CORS Enabled, port 8000)
/ \
/ \
[ EXIF & AIGC Scanner ] [ Deep Learning Classifier ]
(Pillow metadata scans) (ResNet50 Sigmoid Output)
\ /
\ /
[ Payload Builder ] βββββ [ Grad-CAM Heatmap Generator ]
{ label, confidence, heatmap_b64, metadata }
β
[ Frontend Overlay Blender ] (Dynamic alpha slider controls)
DeepGuard/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI server configuration
β β βββ routes/
β β β βββ predict.py # POST /predict controller
β β βββ services/
β β β βββ model_service.py # Model loader & inference wrapper
β β β βββ gradcam.py # Grad-CAM heatmap generator
β β βββ utils/
β β βββ image_utils.py # Image validation & BGR preprocessing
β β βββ metadata_utils.py # Pillow-based EXIF and AIGC scanner
β βββ requirements.txt # Backend dependencies
β βββ test_model.py # Local model prediction tests
β βββ test_gradcam.py # Local Grad-CAM heatmap rendering tests
β βββ test_predict.py # Local API router endpoint tests
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Navbar.jsx # Premium glassmorphic header
β β β βββ HeroSection.jsx # Title & onboarding intro
β β β βββ UploadSection.jsx # Drag-and-drop file uploader
β β β βββ ResultsSection.jsx # Results dashboard with opacity slider
β β β βββ Footer.jsx # Info footer
β β βββ services/
β β β βββ api.js # Axios client
β β βββ App.jsx
β β βββ index.css # Base Tailwind & custom card borders
β β βββ main.jsx
β βββ index.html # HTML template & Jakarta font loading
β βββ package.json # Node dependencies
β βββ vite.config.js # Proxy setup for localhost dev
β βββ vercel.json # Vercel SPA rewrites config
βββ model/
β βββ deepguard_model.h5 # Model file placeholder
βββ training/
β βββ train_model.py # Complete ResNet50 fine-tuning script
βββ render.yaml # Render Infrastructure-as-code Blueprint
βββ README.md
- Python
$\ge$ 3.10 (Tested on Python 3.11.7 and Python 3.14.5) - Node.js
$\ge$ 18 (Tested on Node.js v24.16.0)
# Navigate to backend directory
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
.\venv\Scripts\activate
# macOS/Linux:
# source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Start FastAPI server
python -m uvicorn app.main:app --port 8000 --reloadThe API docs will be available at http://localhost:8000/docs.
# Open a new terminal and navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start Vite development server
npm run devThe React interface will be running at http://localhost:5173. The Vite proxy configuration automatically routes /predict and /health requests to http://localhost:8000.
The training directory includes a transfer learning pipeline based on ResNet50 pre-trained on ImageNet.
cd training
# Train with default settings (expects dataset/real and dataset/ai_generated)
python train_model.py --epochs 15 --batch 32 --lr 0.0001--dataset: Directory path of dataset (default:../dataset)--output: Output file path for saving the model (default:../model/deepguard_model.h5)--epochs: Maximum number of training epochs (default:15)--lr: Base learning rate (default:1e-4)--fine_tune_at: Unfreeze base ResNet50 weights starting at this layer index (default:140)
GET /health
- Response:
{"status": "running"}
POST /predict
-
Request:
multipart/form-datawith form fieldfile(JPG/PNG image file$\le$ 10MB) -
Response Payload (
200 OK):
{
"label": "AI-Generated",
"confidence": 1.00,
"reliability": "High (Metadata Confirmed)",
"heatmap": "<base64_encoded_png_image>",
"metadata": {
"has_exif": false,
"camera_make": "N/A",
"camera_model": "N/A",
"software": "Stable Diffusion",
"created_at": "N/A",
"ai_tool_detected": "Stable Diffusion Metadata Signature",
"file_type": "PNG",
"dimensions": "1024 x 1024"
}
}Run the following scripts inside the backend directory to verify your installation:
cd backend
# Verify model service fallback architecture
python test_model.py
# Verify Grad-CAM activation mapping
python test_gradcam.py
# Verify FastAPI endpoint responses
python test_predict.py- Go to your Render Dashboard.
- Create a New + -> Web Service or choose Blueprint (which automatically parses the root render.yaml file).
- Connect your repository.
- Set Root Directory to
backend. - Set the following environment variables:
PYTHON_VERSION=3.11.7FORCE_MOCK_MODE=true(Forces lightweight execution to prevent OOM on Render Free Tier)ALLOWED_ORIGINS=*
- Go to your Vercel Dashboard.
- Import the same repository (
Frenzy-codes/Deepguard). - Set Root Directory to
frontend. - Add the following environment variable:
VITE_API_URL= Your live Render backend URL (e.g.,https://deepguard-backend-yuuc.onrender.com).
- Click Deploy.
This project is open-source and intended solely for academic, research, and educational purposes. It is not designed to be used as legal evidence, forensic testimony, or for commercial content moderation.
Built with β€οΈ by Team DeepGuard for Explainable AI research