Notice: This repository is not operated or maintained by /u/deepfakes. Please read the explanation below for details.
Faceswap is a tool that utilizes deep learning to recognize and swap faces in pictures and videos.
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
From your setup folder, run python faceswap.py extract
. This will take photos from src
folder and extract faces into extract
folder.
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.
From your setup folder, run python faceswap.py convert
. This will take photos from original
folder and apply new faces into modified
folder.
Alternatively you can run the GUI by running python faceswap.py gui
- 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?!
NB: there is a conversion tool for video. This can be accessed by running python tools.py effmpeg -h
. Alternatively you can use ffmpeg to convert video into photos, process images, and convert images back to video.
A pre-trained model is not required, but you can download the following pre-trained Cage/Trump training model:
Whole project with training images and trained model (~300MB): https://anonfile.com/p7w3m0d5be/face-swap.zip or click here to download
Clone the repo and setup you environment.
You can either use the docker image or run python setup.py
Check out INSTALL.md and USAGE.md for more detailed instructions and basic information on how to configure virtualenv.
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.
- Go to the 'faceswap-model' to discuss/suggest/commit alternatives to the current algorithm.
- 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
- 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.
- 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!
Sorry, no time for that.
It is a community repository for active users.
The joshua-wu repo seems not active. Simple bugs like missing http:// in front of urls have not been solved since days.
- Because a typosquat would have happened sooner or later as project grows
- Because all glory go to /u/deepfakes
- Because it will better federate contributors and users
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.
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:
Here's a slightly more in depth video that tries to explain the basic functioning of a neural network:
tl;dr: training data + trial and error