All Projects → AKASH2907 → Deepfakes_video_classification

AKASH2907 / Deepfakes_video_classification

Deepfakes Video classification via CNN, LSTM, C3D and triplets

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Deepfakes video classification

Fast Pytorch
Pytorch Tutorial, Pytorch with Google Colab, Pytorch Implementations: CNN, RNN, DCGAN, Transfer Learning, Chatbot, Pytorch Sample Codes
Stars: ✭ 346 (+1341.67%)
Mutual labels:  cnn, rnn, transfer-learning
Video Classification
Tutorial for video classification/ action recognition using 3D CNN/ CNN+RNN on UCF101
Stars: ✭ 543 (+2162.5%)
Mutual labels:  cnn, rnn, transfer-learning
Text Classification Cnn Rnn
CNN-RNN中文文本分类,基于TensorFlow
Stars: ✭ 3,613 (+14954.17%)
Mutual labels:  cnn, rnn
Tsai
Time series Timeseries Deep Learning Pytorch fastai - State-of-the-art Deep Learning with Time Series and Sequences in Pytorch / fastai
Stars: ✭ 407 (+1595.83%)
Mutual labels:  cnn, rnn
Deep Music Genre Classification
🎵 Using Deep Learning to Categorize Music as Time Progresses Through Spectrogram Analysis
Stars: ✭ 23 (-4.17%)
Mutual labels:  cnn, rnn
Mydeeplearning
A deep learning library to provide algs in pure Numpy or Tensorflow.
Stars: ✭ 281 (+1070.83%)
Mutual labels:  cnn, rnn
Unet Zoo
A collection of UNet and hybrid architectures in PyTorch for 2D and 3D Biomedical Image segmentation
Stars: ✭ 302 (+1158.33%)
Mutual labels:  cnn, rnn
Rmdl
RMDL: Random Multimodel Deep Learning for Classification
Stars: ✭ 375 (+1462.5%)
Mutual labels:  cnn, rnn
How To Learn Deep Learning
A top-down, practical guide to learn AI, Deep learning and Machine Learning.
Stars: ✭ 544 (+2166.67%)
Mutual labels:  cnn, rnn
Deeplearning
深度学习入门教程, 优秀文章, Deep Learning Tutorial
Stars: ✭ 6,783 (+28162.5%)
Mutual labels:  cnn, rnn
Handwritingrecognitionsystem
Handwriting Recognition System based on a deep Convolutional Recurrent Neural Network architecture
Stars: ✭ 262 (+991.67%)
Mutual labels:  cnn, rnn
Tensorflow cookbook
Code for Tensorflow Machine Learning Cookbook
Stars: ✭ 5,984 (+24833.33%)
Mutual labels:  cnn, rnn
deep-learning-coursera-complete
Deep Learning Specialization by Andrew Ng on Coursera - My Completed Coursework Repo - All 5 Courses
Stars: ✭ 104 (+333.33%)
Mutual labels:  cnn, rnn
Basicocr
BasicOCR是一个致力于解决自然场景文字识别算法研究的项目。该项目由长城数字大数据应用技术研究院佟派AI团队发起和维护。
Stars: ✭ 336 (+1300%)
Mutual labels:  cnn, rnn
udacity-cvnd-projects
My solutions to the projects assigned for the Udacity Computer Vision Nanodegree
Stars: ✭ 36 (+50%)
Mutual labels:  rnn, transfer-learning
Automatic speech recognition
End-to-end Automatic Speech Recognition for Madarian and English in Tensorflow
Stars: ✭ 2,751 (+11362.5%)
Mutual labels:  cnn, rnn
Lightnet
Efficient, transparent deep learning in hundreds of lines of code.
Stars: ✭ 243 (+912.5%)
Mutual labels:  cnn, rnn
Crnn Pytorch
Pytorch implementation of CRNN (CNN + RNN + CTCLoss) for all language OCR.
Stars: ✭ 248 (+933.33%)
Mutual labels:  cnn, rnn
Tensorflow Tutorial
Tensorflow tutorial from basic to hard, 莫烦Python 中文AI教学
Stars: ✭ 4,122 (+17075%)
Mutual labels:  cnn, rnn
Multi Class Text Classification Cnn Rnn
Classify Kaggle San Francisco Crime Description into 39 classes. Build the model with CNN, RNN (GRU and LSTM) and Word Embeddings on Tensorflow.
Stars: ✭ 570 (+2275%)
Mutual labels:  cnn, rnn

deepfakes_classification

arXiv

This repository provides the official Python implementation of Deepfakes Detection with Metric Learning accepted at 8th International Workshop on Biometrics and Forensics. Medium blog post is shared here: deepfakes-classification-via-metric-learning

Table of Contents

Requirements

Tested on Python 3.6.x and Keras 2.3.0 with TF backend version 1.14.0.

  • Numpy (1.16.4)
  • OpenCV (4.1.0)
  • Pandas (0.25.3)
  • Scikit-learn (0.22.1)
  • facenet-pytorch (2.0.1)
  • PyTorch (1.2.0)

Getting Started

  • Install the required dependencies:
pip install -r requirements.txt
python 00.train_data_prepare.py -img_size 160 -fpv 25

-  [-img_size] IMG_SIZE, Resize face image size
-  [-fpv] FRAMES_PER_VIDEO, Number of frames per video to consider

python 01.train_CNN.py -e 20 -m xception -w xception_best -b 32 -im_size 160

-  [-e] EPOCHS, Number of epochs
-  [-m] MODEL_NAME, Imagenet architecture
-  [-w] WEIGHTS_SAVE_NAME, Model weights name
-  [-b] BATCH_SIZE, Batch size
-  [-im_size] IMAGE_SIZE, Input image dimension
python 02.evaluate_CNN.py -m ef0 -w ef0.hdf5 -im_size 160

- [-m] MODEL_NAME, Imagenet architecture, ef0=EfficientNet0
- [-w] LOAD_WEIGHTS_NAME, Load saved weights
- [-im_size] IMAGE_SIZE, Input image dimension
python 03.train_C3D.py -e 15 -m c3d -b 32 -im_size 160

-  [-e] EPOCHS, Number of epochs
-  [-m] MODEL_NAME, conv3d or c3d model
-  [-w] WEIGHTS_SAVE_NAME, Model weights name
-  [-b] BATCH_SIZE, Batch size
python 04.evaluate_C3D.py -m c3d -w trained_wts/weights_c3d.h5 -b 32

- [-m] MODEL_NAME, Imagenet architecture, c3d/conv3d
- [-w] LOAD_WEIGHTS_NAME, Load saved weights
- [-b] BATCH_SIZE, Batch size
python 05.lstm_features.py -seq 25 -m ef0 -w ef0 -im_size 160

- [-seq] SEQ_LENGTH, Number of frames to consider per video
- [-m] MODEL_NAME, Imagenet architecture, ef0=EfficientNet0
- [-w] LOAD_WEIGHTS_NAME, Load saved weights
- [-im_size] IMAGE_SIZE, Input image dimension 
python 06.train_CNN_LSTM.py -e 15 -b 32 -w lstm_wts

-  [-e] EPOCHS, Number of epochs
-  [-w] WEIGHTS_SAVE_NAME, Model weights name
-  [-b] BATCH_SIZE, Batch size
python 07.evaluate_CNN_LSTM.py -seq 25 -m ef0 -w ef0 -im_size 160

- [-seq] SEQ_LENGTH, Number of frames to consider per video
- [-m] MODEL_NAME, Imagenet architecture, ef0=EfficientNet0
- [-w] LOAD_WEIGHTS_NAME, Load saved weights
- [-im_size] IMAGE_SIZE, Input image dimension 
python 10.train_triplets_semi_hard.py -f True -e 20

- [-f] TRAIN_FLAG, True-> Train else test
- [-e] EPOCHS, Number of epochs

Celeb-DF

It contains high resolution videos, with 5299/712 training distribution and 340/178 videos in testing distribution as real/fake videos. With frame rate 5, there are approximately 70K frames generated.

Although Celeb-DF face quality is better than FaceForensics++ c-40 videos, training directly on whole frames is not useful. Therefore, we extracted faces from frames and then utilised that for classification. Data imbalance plays a huge role that affects the weights of network. In our case, it was 7:1. We applied bagging and boosting algorithm. So, the dataset was divided into 7 chunks of 1400 videos approximately: 700 fake and 700 real. It was trained on each distribution and then performance was boosted by max voting all the predictions.

Frames contains a lot of noise and we have to focus on face. We used facenet model to extract faces from the whole video (can be done directly using videos or after extraction of frames), and then we trained XceptionNet for 50 epochs with EarlyStopping (patience=10) and ModelCheckpoint to save only the best mdoel by tracking the val_loss. We achieve the accuracy of 96% and after boosting accuracy improves to 98%.

TSNE plot before and after training using frames only (2D-CNN- Xception)

TSNE plot before and after training using Triplet Network

Grad CAM Activation maps

Face-forensics

FaceForensics++ dataset contains four types of forgeries:

  • Face2Face
  • FaceSwap
  • Deepfakes
  • Neural Texture

It contains 1000 manipulated videos of each type and 1000 real videos on which these 4 manipulations have been done.

Final Architecture

TSNE plot of FaceForensics++ dataset

Results

Citation

If you find this work useful, please consider citing the following paper:

@INPROCEEDINGS{9107962,
 author={A. {Kumar} and A. {Bhavsar} and R. {Verma}},
 booktitle={2020 8th International Workshop on Biometrics and Forensics (IWBF)}, 
 title={Detecting Deepfakes with Metric Learning}, 
 year={2020},
 volume={},
 number={},
 pages={1-6},}

Notes

For FaceForensics++ and Celeb-DF dataset, contact the authors of the dataset. The dataset can't be shared with the third party. You need to accept the terms on their pages. Then, they will provide you with the access.

Codes have been formatted in PEP-8 styling so that it's easy to read and reproducible to all. If any errors you face in the repo, please raise a issue. (Any place where I should explain more) I'll be happy to resolve it as soon as possible.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].