Awesome
Interpretable-through-prototypes deepfake detection for diffusion models
Paper: Aghasanli, Agil, Dmitry Kangin, and Plamen Angelov. "Interpretable-through-prototypes deepfake detection for diffusion models." Proceedings of the IEEE/CVF International Conference on Computer Vision. 2023. https://openaccess.thecvf.com/content/ICCV2023W/DFAD/papers/Aghasanli_Interpretable-Through-Prototypes_Deepfake_Detection_for_Diffusion_Models_ICCVW_2023_paper.pdf
Getting Started
Prerequisites
Ensure you have downloaded the project datasets before proceeding with the execution of any script.
Feature Extraction
Using Pretrained Models
- Open the
Feature_extraction_pretrained.py
file. - Set the
data_dir
variable in line 72 to the appropriate path on your local machine where the datasets are stored. - Run the script using the command:
python Feature_extraction_pretrained.py
This script will generate four CSV files containing the train/test features and labels.
Using Finetuned Weights
- Open the
Feature_extraction_finetuned.py
file. - Adjust the
data_dir
variable in line 66 to match the path on your local machine. - In line 25, initialize the ViT model using the appropriate .bin and .json files generated from the finetuning process (refer to the Finetuning section below).
- Execute the script with:
python Feature_extraction_finetuned.py
Similar to the pretrained model, this will generate four distinct CSV files for train/test features and labels.
Classifier Testing
xDNN Classifier
After obtaining the necessary CSV files:
- After generating the CSV files, update lines 13-16 in
xDNN_run.py
to import the correct CSV files. - Run the
xDNN_run.py
script to test the xDNN classifier:
python xDNN_run.py
This script also generates a data file containing prototypes for later use (e.g., explainability).
Other Classifiers
To see the results using SVM, KNN, and Naive Bayes:
- Update lines 15-18 in
test_classifiers.py
to be compatible with the names of the generated CSV files. - Execute:
python test_classifiers.py
Finetuning Process
Vision Transformer (ViT) on Deepfake FFHQ Dataset
Run the Jupyter Notebook finetune.ipynb
to perform finetuning on the ViT model using the Deepfake FFHQ dataset (or possibly another new dataset).
Follow these instructions to ensure the correct setup and execution of scripts within the project.