Skip to content

Deepfake Detection using Domain Adversial Training

Notifications You must be signed in to change notification settings

priyank766/DFD-Research

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Deepfake Detection using Domain Adversial Training

This repository implements a deep learning framework for deepfake detection that leverages domain adversial training to enhance the robustness of the model. The goal is to distinguish between real and fake images by training a model that is not only effective in labeling authenticity but also learns domain invariant features.

88fe896c-e0c4-47ca-ba7a-385f2e776083

Overview

Deepfakes present a significant challenge due to the subtle differences between manipulated and authentic media. In this project, we propose a model architecture that integrates:

  • Feature Extraction: Using a powerful pre-trained convolutional neural network as the backbone.
  • Domain Adversial Training: Enabling the model to learn domain-invariant representations which help in generalizing across various data domains.
  • Dual Output Heads: The network outputs both the label prediction (real or fake) and domain prediction (identifying the data source/domain), thereby reinforcing the learning of robust features.

Repository Structure

  • dfdresearch.ipynb: A Jupyter Notebook containing the implementation details, data preprocessing, model architecture, and training routines.
  • TFRecord Files: The dataset is stored in TFRecord format, split into training and testing sets.
  • Other Directories: May include experiment logs, additional pre-processing scripts, and model checkpoints.

Model Architecture

The core of the model is based on a transfer learning approach:

  1. Base Model: We use a pretrained network (e.g., ResNet50) as the feature extractor.
  2. Global Average Pooling: Reducing the feature maps into a compact feature vector.
  3. Dense Layers: A dense layer with ReLU activation to capture high-level features.
  4. Output Heads:
    • Label Head: A sigmoid activated dense layer for binary classification (real vs fake).
    • Domain Head: A softmax activated dense layer for domain classification, aiding in adversarial training.

Additionally, a Gradient Reversal Layer is incorporated to perform the adversarial training, ensuring that the features learned are insensitive to domain-specific variations.

Pre-processing

Data preprocessing plays a crucial role in the performance of the model. The steps include:

  • TFRecord Parsing: Custom parsing functions decode and resize images, normalize pixel values, and extract labels.
  • Data Augmentation: (Optional) Techniques such as flipping, rotation, and color adjustments may be applied to improve model robustness.

Training Strategy

  • Adversarial Loss: The domain head is trained adversarially using a gradient reversal layer, which reverses the gradients to enforce domain invariance.
  • Multi-task Learning: The model is trained to simultaneously minimize the loss for label prediction and domain prediction.
  • Optimization: Standard optimization techniques (e.g., Adam optimizer) with appropriate learning rate scheduling are applied to converge efficiently.

Usage

To run the deepfake detection pipeline:

  1. Open the dfdresearch.ipynb notebook in Jupyter or Google Colab.
  2. Execute the cells sequentially to perform data loading, pre-processing, model training, and evaluation.
  3. Monitor training progress through logs and visualize the results and loss curves.

Future Work

  • Hyperparameter Tuning: Further explore the impact of adversarial loss weights and learning rates.
  • Expanded Dataset: Incorporate additional datasets for increased robustness.
  • Model Enhancements: Experiment with alternative architectures and more complex adversarial strategies.

This project represents a promising approach in detecting deepfakes, ensuring high accuracy and robust performance across varied data domains through the use of domain adversial training.

About

Deepfake Detection using Domain Adversial Training

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published