Deep Learning with Tensorflow
- install python – best to do this using anaconda if you’re going to use the pytorch based files so do this
* go here https://repo.continuum.io/archive/ get the 4.2.0 if you’re going to use python 3.5.2 like me
* download and run the file
* once it’s installed run the anaconda prompt as administrator from windows start (don’t forget to run as administrator
* inside the anaconda prompt run this: conda install -c anaconda python=3.5.2 - pip install tensorflow or pip install tensorflow-gpu
- install CUDNN 6.0
- install CUDA 8.0
- install dlib – if it doesn’t work, you might need to find and download the wheel and pip install the wheel
- install opencv
- install boost if it’s missing: ONLY install it if opencv isn’t working and complaining about it.
- install keras: pip install keras
- install Visual Studio run time if needed
- install scipy : pip install scipy
- install numpy : pip install numpy
- install h5py : pip install h5py
- install matplotlib : pip install matplotlib
- install tqdm: pip install tqdm
- install umeyama: download umeyama.py from https://github.com/deepfakes/faceswap/tree/master/lib
- install skimage: pip install scikit-image
- download code from github repo
- copy code into e.g. “c:\deepfakes”
- get the pictures of each person using face_align.py** NOTE: THIS WILL REQUIRE INSTALL OF PYTORCH – I’m working on this so stay tuned for a guide.
*do this inside anaconda prompt: conda install -c peterjc123 pytorch_legacy cuda80
* NOTE: ^ may be different for you: I have windows 8.1 and I have an NVIDIA card See: https://github.com/pytorch/pytorch/issues/494#issuecomment-304439658 - copy the “to” pictures into “trump” or vice versa
- copy the “from” pictures into “cage” or vice versa
- run the train.py by doing python train.py : if it’s working you will see “using tensorflow backend” then “press ‘q’ to stop training and save model. NOTE here is where things could go wrong if you haven’t installed all the necessary python packages. For example when I ran it at first, it was missing keras so I got “ImportError: no module named ‘keras’. Then it ran for a while and I got “ImportError: ‘save_weights’ requires h5py. The solution in both of these cases is pip install. so pip install keras and pip install h5py. Then rinse and repeat till you’ve got everything working.
- run the merge_faces.py script
- use ffmpeg to make the frames into a video
- NOTE: If you have never used pip before and when you run the scripts you get import errors, you will have to identify each module needed and do pip install for each of the modules. e.g. (you know you need it if when you try to run python train.py (or any other of the .py files it complains by going “ImportError: no module named ‘keras’ ). So.. in my case I have python in c:\python35 so open up a cmd prompt and CD C:\python35 then pip install keras
https://www.reddit.com/r/deepfakes/comments/7n00f2/really_high_level_tutorial/
- Face alignment scripts based on https://github.com/1adrianb/face-alignment
- Please check Phil_Latio’s comment to learn how to install this repo.
- After testing it’s own examples/detect_landmarks_in_image.py, make sure it works.
- Copy
align_images.py
andumeyama.py
intoface-alignment
( notface-alignment/face_alignment
) - Run
python align_images.py your_raw_image_folder
- The script will create an
aligned
subfolder and analignments.json
file under your raw images folder. - You may remove bad aligned images in
aligned
folder. - Copy
merge_faces.py
intoface-swap
project folder. - Run
python merge_faces.py your_raw_image_folder
- The script will convert every existed aligned image with trained model, and merge it back to original raw image. The new images will be saved to
merged
subfolder under raw images folder.