# ๐ง Deepfake Detection with Emotion Analysis using EfficientNet and DeepFace A hybrid deep learning system designed to detect **deepfakes** in both images and videos, while simultaneously performing **facial emotion analysis**. Built using EfficientNetB4, CNN-GRU, and DeepFace, the system is lightweight, scalable, and tailored for real-world deployment. --- ## ๐ Key Features - ๐ Detects deepfakes in **images and videos** - ๐ง Performs **emotion recognition** using DeepFace - ๐ Live plotting of **deepfake probability** and **emotion timeline** - ๐งฎ Metrics: Accuracy, Precision, Recall, F1, AUC - โ๏ธ EfficientNetB4 + CNN-GRU architecture for temporal video analysis - ๐ป Optimized for **low-resource systems** --- ## ๐งฐ Tech Stack | Area | Tools & Libraries | | ---------------- | ------------------------------------------ | | Deep Learning | TensorFlow, Keras, EfficientNetB4, GRU | | Face Analysis | DeepFace (for emotion detection) | | Image Processing | OpenCV, Haar Cascades | | Data | NumPy, pandas, scikit-learn | | Visualization | Matplotlib | --- ## ๐ง Model Architectures ### ๐น EfficientNetB4 (Image-Based) ``` EfficientNetB4 (frozen) โ GlobalAveragePooling2D โ Dropout + Dense โ Sigmoid output (real vs fake)
TimeDistributed(EfficientNetB4) โ GlobalAveragePooling2D (per frame) โ GRU โ Dense โ Sigmoid output
deepfake_train.py
โ Train image-based modelevaluate_image_model.py
โ Evaluate on static imagesanalyze_single_image.py
โ Image + emotion detectionanalyze_video_with_emotion.py
โ Video analysis with live plotscnn_gru_train.py
โ Temporal model training (video)cnn_gru_evaluation.py
โ CNN-GRU video evaluationModel | Accuracy | Precision | Recall | F1 Score |
---|---|---|---|---|
EfficientNetB4 (Base) | 48.1% | 45.6% | 53.5% | 49.2% |
Fine-tuned Model | 57.7% | 53.6% | 74.6% | 62.3% |
happy
, sad
, angry
, surprise
, neutral
, etc.deepfake_video_graph.png
โ Deepfake probability over time
emotion_over_time_graph.png
โ Emotion timeline from video
Combined real-time predictions:
Frame 120 | Deepfake: 0.8723 | Emotion: neutral Frame 125 | Deepfake: 0.9231 | Emotion: happy
Real and Fake Face Detection:
https://www.kaggle.com/datasets/ciplab/real-and-fake-face-detection
Deepfake Detection on Images and Videos (video-based):
https://www.kaggle.com/code/krooz0/deep-fake-detection-on-images-and-videos/input
Data processing steps include:
# Train EfficientNetB4 python deepfake_train.py # Evaluate image model python evaluate_image_model.py # Analyze single image (deepfake + emotion) python analyze_single_image.py # Analyze video (deepfake + emotion timeline) python analyze_video_with_emotion.py # Train temporal model (CNN + GRU) python cnn_gru_train.py # Evaluate temporal model python cnn_gru_evaluation.py
Harshit Bansal
๐ซ harshitbansalmi@gmail.com
๐ GitHub | LinkedIn
Licensed under the MIT License.
Free to use, adapt, and cite with attribution.