Giter VIP home page Giter VIP logo

faceforensics's Introduction

FaceForensics++ DIY Version

Introduction

This project fork from https://github.com/ondyari/FaceForensics.

It is convenient to implement their trained model by this original project.

This forked DIY version provides TOOLS for:

Data Preprocessing

In directory [/FaceForensics/DataPreprocess]:

  • [ExtractVideoFrame.py] : Extract frame from provided video dataset.

  • [ExtractFaceFromFrame.py] : Extract face from every frame. Because the paper introduce a face detection algorithm to enhance the performance of fake detection.

  • [SplitDataset.py] : Split dataset into training, validation and test set. The ratio mentioned in their paper is 0.72. 0.14, 0.14.

  • [MergeDataset.py] : Merge dataset of manipulated images(Deepfake, Face2face, Faceswap and NeuralTextures) into type 1 and original images into type 0.

Model Training

In directory [/FaceForensics/TrainModel]:

  • [TrainModel_2.py] : Use a rransfer learning template in pytorch.
    • Choose your merged dataset path in Line 25
    • Choose batch size in line 37
    • Pretrain the last linear layer with 3 epochs by adding parameter '----pretrain3epochs' like TrainModel_2.py --pretrain3epochs
    • Train whole model with 15epochs directly TrainModel_2.py
    • Save the trained model in Line 199(specify your output path and filename here).

Model Testing

You can see the testing and validation accuracy in the console during training time. If you want to see the test set counterpart, use code in directory [/FaceForensics/TestModel]:

  • [test_model.py] : Detect all images in a directory and write all prediction output into a .txt file.
  • [test_model_GUI.py] : Detect single video and output a series of frames with face box and prediction tag.
  • [test_our_model.py] : Implement our trained model of [TrainModel_2.py] and output prediction tag into .txt file. Implement format is : test_our_model.py -i /test_set_images_path -m /model_path -o /output_txt_file_path

Stat Accuracy

After get prediction output by [test_our_model.py], use code in directory [/FaceForensics/StatResult] to stat accuracy:

  • [cal_accuracy.py] : stat whole test set accuracy.
  • [cal_accuracy_single.py] : stat single test set accuracy, eg. Deepfakes.

Last but not least

If you have any questions, contact me via [email protected].

faceforensics's People

Contributors

ondyari avatar racerchen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.