A deep learning deepfake detection system built with EfficientNetV2B0 + CBAM Attention, available as both a Streamlit web app and a Chrome Extension for real-time AI-generated content detection on any web page.
- Real-time page scanning — Automatically detects AI-generated images and videos on any web page
- 100% local inference — All analysis runs on-device using TensorFlow.js; no data ever leaves your machine
- Smart detection — MutationObserver-based scanning catches dynamically loaded content (infinite scroll, SPAs)
- Video frame analysis — Extracts and analyzes video frames at configurable intervals
- Premium UI — Glassmorphism popup dashboard with real-time stats, detection history, and configurable settings
- In-page overlays — Non-intrusive badges on scanned images showing Real/AI-Generated status with confidence scores
- User-configurable — Toggle auto-scan, adjust sensitivity, show/hide overlays, enable/disable video scanning
-
Convert the trained model to TensorFlow.js format:
pip install tensorflowjs python scripts/convert_model.py
This produces
extension/model/model.json+ weight.binfiles. -
Load the extension in Chrome:
- Open
chrome://extensions/ - Enable Developer mode (top-right toggle)
- Click Load unpacked
- Select the
extension/folder
- Open
-
Usage:
- Click the 🛡️ DeepGuard AI icon in the toolbar
- Click "Scan This Page" to analyze all images/videos
- Toggle Auto-Scan in settings to scan pages automatically
- Hover over badges on images to see detailed confidence scores
extension/
├── manifest.json # Manifest V3 configuration
├── background.js # Service worker (message routing, state management)
├── content/
│ ├── content.js # DOM scanner, MutationObserver, overlay injection
│ └── overlay.css # In-page glassmorphism badges
├── offscreen/
│ ├── offscreen.html # Hidden document for TF.js inference
│ └── offscreen.js # Model loading, preprocessing, prediction
├── popup/
│ ├── popup.html # Dashboard UI
│ ├── popup.css # Premium glassmorphism styles
│ └── popup.js # Settings, stats, scan control
├── lib/
│ └── tf.min.js # TensorFlow.js library (~1.4 MB)
├── model/
│ ├── model.json # Converted model topology
│ └── *.bin # Weight shards (~10-15 MB)
└── assets/
└── icons/ # Extension icons (16, 48, 128px)
data/raw: Original dataset images/videos (managed bydownload_data.py).data/processed: Cropped faces and preprocessed data.models/: Saved model weights (.h5,.keras).src/: Source code for preprocessing, training, and inference.notebooks/: Jupyter notebooks for experimentation.scripts/: Model conversion utilities.download_data.py: Script to download and set up the dataset.
- Create a virtual environment:
python -m venv venv
- Activate the environment:
- Windows:
.\venv\Scripts\activate - Mac/Linux:
source venv/bin/activate
- Windows:
- Install dependencies:
pip install -r requirements.txt
- Kaggle API:
- Go to Kaggle Account.
- Click "Create New API Token" to download
kaggle.json. - Place
kaggle.jsoninC:\Users\<YourUser>\.kaggle\OR in this project folder.
- Download Data:
This will download the
python download_data.py
ciplab/real-and-fake-face-detectiondataset and organize it intodata/raw/realanddata/raw/fake.
Run the preprocessing script to extract faces from videos/images:
python src/preprocess.pyThis will populate data/processed/real and data/processed/fake.
Train the EfficientNetV2B0 + CBAM model with two-phase training:
python src/train.pyThis saves the model to models/deepfake_detector.keras.
Generate a comprehensive evaluation report:
python src/evaluate.pyLaunch the web interface for manual video analysis:
streamlit run app.py- Base Model: EfficientNetV2B0 (pre-trained on ImageNet)
- Attention: CBAM (Convolutional Block Attention Module)
- Custom Head: GAP → Dense(512) → BN → Dropout → Dense(256) → BN → Dropout → Sigmoid
- Training: Two-phase (frozen backbone → fine-tuning top 30 layers)
- Loss: Binary Focal Crossentropy
- Metrics: Accuracy, AUC, Precision, Recall
- Python 3.10+
- TensorFlow 2.12+
- Chrome 120+ (for extension)
- See
requirements.txtfor full dependency list