Deepfakes Software For All www.faceswap.dev
Go to file
AbysmalBiscuit e0fa8c071e Adding tools.py as main script for using tools, as well as integrating all feature requests from #255 and #278 (#298)
* Add tools.py command and control script for use as the main interface for various tools. The structure and approach is the same as faceswap.py
Add many new features to tools/sort.py: various new sorting methods, grouping by folders, logging file renaming/movemeng, keeping original files in the input directory and improved cli options documentation. Argument parsing has been re-written to inteface with tools.py
Add __init__.py empty file in tools directory for python to register it as a module so that sort.py and future tools can be easily imported.

* Fix various bugs where the correct sorting method would not get called.
Add new sorting methon: face-cnn-dissim.
Update help documentation for face-cnn-dissim.
Change default grouping to rename.
Update initial print in all sorting/grouping methods to say precisely which method is being used.

* Major refactor and redesign.
Use dynamic method allocation to avoid large amounts of nested if-elif statements in process() function and to allow easily combine sort and group methods.

Change cli arguments to make them more intuitive and work with the new design.
Previous: '-g/--grouping' -> '-f/--final-processing' {folders,rename}
Previous: '-by/--by' -> '-s/--sort-by' {blur,face,face-cnn,face-cnn-dissim,face-dissim,hist,hist-dissim}
New: '-g/--group-by' {blur,face,face-cnn,hist}
Add: '--logfile' -> '-lg/--logfile' PATH_TO_LOGFILE

Greatly improve grouping performance.
Grouping now has to sort using one of the sorting methods which makes the grouping stable and no longer dependent on how well the the target files are already sorted.
Sorting and grouping methods can be combined in any way. If no -g/--group-by is specified by user, it will default to group by the non '-dissim' version of sort method.
Different combinations of sorting and grouping methods work well for different sets of data.

Fixes
Fix progress updates not showing properly by setting them to print to stdout instead of stderror.
Fix bug in grouping by face-cnn where wrong score method was being called.

Misc
Add documentation for reload_list() and splice_lists() methods because it's not obvious what they do.
Add warning message to tools.py to tell users to make sure they understand how the tool they want to use works before using it.
Add warning message to tools/sort.py to tell users to make sure they undrestand how the sort tool works before using it.
Update help documentation to reflect new functionality and options.
Set defaults for group by face-cnn to work properly with the correct score method.
Amend commit in order to sign it.

* Perform unittests for all options and combinations of sort and group methods: everything OK.
Fix typos in help documentation.
2018-03-21 11:12:12 +01:00
.github Added command line used in other relevant steps 2018-03-13 23:39:57 +01:00
lib Align Eyes Horizontally After Umeyama + Blur Detection (#242) 2018-03-13 20:35:14 -04:00
plugins Fix gan128 (#288) 2018-03-14 11:53:33 +01:00
scripts Fixed error handling in train.py (#293) 2018-03-16 17:16:17 +01:00
tools Adding tools.py as main script for using tools, as well as integrating all feature requests from #255 and #278 (#298) 2018-03-21 11:12:12 +01:00
.dockerignore Clearer requirements for each platform (#183) 2018-02-14 16:22:02 +01:00
.gitignore Adding new plugins (Extract_Align & Convert_Masked) 2018-01-03 10:33:42 +01:00
Dockerfile Clearer requirements for each platform (#183) 2018-02-14 16:22:02 +01:00
faceswap.py Update GAN64 to v2 (#217) 2018-03-09 19:43:24 -05:00
INSTALL.md Update INSTALL.md (#178) 2018-02-12 15:44:17 +01:00
LICENSE Add GNU General Public License v3.0 2018-02-25 16:41:32 +00:00
README.md Documentation and grammar (#167) 2018-02-11 17:27:16 +01:00
requirements-gpu-python35-cuda8.txt Clearer requirements for each platform (#183) 2018-02-14 16:22:02 +01:00
requirements-gpu-python36-cuda9.txt Clearer requirements for each platform (#183) 2018-02-14 16:22:02 +01:00
requirements-python35.txt Clearer requirements for each platform (#183) 2018-02-14 16:22:02 +01:00
requirements-python36.txt Clearer requirements for each platform (#183) 2018-02-14 16:22:02 +01:00
tools.py Adding tools.py as main script for using tools, as well as integrating all feature requests from #255 and #278 (#298) 2018-03-21 11:12:12 +01:00
USAGE.md Match the command to split/generate video (#196) 2018-02-26 15:08:42 +01:00

Notice: This repository is not operated or maintained by /u/deepfakes. Please read the explanation below for details.


deepfakes_faceswap

Faceswap is a tool that utilizes deep learning to recognize and swap faces in pictures and videos.

Overview

The project has multiple entry points. You will have to:

  • Gather photos (or use the one provided in the training data provided below)
  • Extract faces from your raw photos
  • Train a model on your photos (or use the one provided in the training data provided below)
  • Convert your sources with the model

Extract

From your setup folder, run python faceswap.py extract. This will take photos from src folder and extract faces into extract folder.

Train

From your setup folder, run python faceswap.py train. This will take photos from two folders containing pictures of both faces and train a model that will be saved inside the models folder.

Convert

From your setup folder, run python faceswap.py convert. This will take photos from original folder and apply new faces into modified folder.

General notes:

  • All of the scripts mentioned have -h/--help options with arguments that they will accept. You're smart, you can figure out how this works, right?!

Note: there is no conversion for video yet. You can use ffmpeg to convert video into photos, process images, and convert images back to video.

Training Data

Whole project with training images and trained model (~300MB): https://anonfile.com/p7w3m0d5be/face-swap.zip or click here to download

How To setup and run the project

Setup

Clone the repo and setup you environment. There is a Dockerfile that should kickstart you. Otherwise you can setup things manually, see in the Dockerfiles for dependencies.

Check out ../blob/master/INSTALL.md and ../blob/master/USAGE.md for basic information on how to configure virtualenv and use the program.

You also need a modern GPU with CUDA support for best performance

Some tips:

Reusing existing models will train much faster than starting from nothing.
If there is not enough training data, start with someone who looks similar, then switch the data.

Docker

If you prefer using Docker, You can start the project with:

  • Build: docker build -t deepfakes .
  • Run: docker run --rm --name deepfakes -v [src_folder]:/srv -it deepfakes bash . bash can be replaced by your command line Note that the Dockerfile does not have all good requirments, so it will fail on some python 3 commands. Also note that it does not have a GUI output, so the train.py will fail on showing image. You can comment this, or save it as a file.

How to contribute

For people interested in the generative models

  • Go to the 'faceswap-model' to discuss/suggest/commit alternatives to the current algorithm.

For devs

  • Read this README entirely
  • Fork the repo
  • Download the data with the link provided below
  • Play with it
  • Check issues with the 'dev' tag
  • For devs more interested in computer vision and openCV, look at issues with the 'opencv' tag. Also feel free to add your own alternatives/improvments

For non-dev advanced users

  • Read this README entirely
  • Clone the repo
  • Download the data with the link provided below
  • Play with it
  • Check issues with the 'advuser' tag
  • Also go to the 'faceswap-playground' repo and help others.

For end-users

  • Get the code here and play with it if you can
  • You can also go to the 'faceswap-playground' repo and help or get help from others.
  • Be patient. This is relatively new technology for developers as well. Much effort is already being put into making this program easy to use for the average user. It just takes time!
  • Notice Any issue related to running the code has to be open in the 'faceswap-playground' project!

For haters

Sorry, no time for that.

About github.com/deepfakes

What is this repo?

It is a community repository for active users.

Why this repo?

The joshua-wu repo seems not active. Simple bugs like missing http:// in front of urls have not been solved since days.

Why is it named 'deepfakes' if it is not /u/deepfakes?

  1. Because a typosquat would have happened sooner or later as project grows
  2. Because all glory go to /u/deepfakes
  3. Because it will better federate contributors and users

What if /u/deepfakes feels bad about that?

This is a friendly typosquat, and it is fully dedicated to the project. If /u/deepfakes wants to take over this repo/user and drive the project, he is welcomed to do so (Raise an issue, and he will be contacted on Reddit). Please do not send /u/deepfakes messages for help with the code you find here.

About machine learning

How does a computer know how to recognise/shape a faces? How does machine learning work? What is a neural network?

It's complicated. Here's a good video that makes the process understandable: How Machines Learn

Here's a slightly more in depth video that tries to explain the basic functioning of a neural network: How Machines Learn

tl;dr: training data + trial and error