llSourcell / deepfakes

This is the code for "DeepFakes" by Siraj Raval on Youtube
967 stars 464 forks source link

Coding Challenge - Due Date, Thursday Feb 15 2018

Generate your own faceswap using this algorithm. Post your github link with your code in the youtube comment section of this video. Bonus points if you document your code so that a beginner can do this easily (easier than this code).

Overview

This is the code for this video on Youtube by Siraj Raval.

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:

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:

Note: there is no conversion for video yet. You can use MJPG 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:

How to contribute

For people interested in the generative models

For devs

For non-dev advanced users

For end-users

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 url has 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

Credits

Credit goes to deepfakes.