Mr DeepFakes Forums
  • New and improved dark forum theme!
  • Guests can now comment on videos on the tube.
   
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • ...
  • 16
  • Next 
DeepFaceLab Explained and Usage Tutorial
#1
DeepFaceLab

NOTE: Making DeepFakes require a NVIDIA GPU with 2GB+ vRAM

I have moved from Faceswap to DeepFaceLab due to ease of use, better outcomes, and a lot of time saved. This tutorial will be a mix of the creator's instructions, and how I use and understand the program. The GitHub can be found here: You are not allowed to view links. Register or Login to view.

You are not allowed to view links. Register or Login to view.

Features:
  • Available as standalone with zero dependencies, ready to be used with prebult binary for all windows versions.
  • New models (H64, H128, DF, LIAEF128, MIAEF128, AVATAR)
  • New architecture, easy to experiement with models
  • Works on 2GB old cards, such as GT730. Example of a deepfake trained on a 2GB gtx850m notebook in 18 hours: You are not allowed to view links. Register or Login to view.
  • Face data embedded in png files
  • Automatically manage GPU by choosing the best GPU(s) and also supports multi GPUs (only for identical cards) - do not use cards in SLI mode.
  • New preview window
  • Extractor in parallel
  • Converter in parallel
  • Added debug option for all stages
  • Added MTCNN extractor which reduces less jitter aligned faces complared to DLIBCNN; however this can produce more false positives in facial recognition.
[Image: 68747470733a2f2f692e696d6775722e636f6d2f...562e676966]
Left = dlib
Right = MTCNN
  • Manual extractor allows you to fix missed faces, manually, or do full manual extract
[Image: manual_extractor_0.jpg]
[Image: 38454756-0fa7a86c-3a7e-11e8-9065-182b4a8a7a43.gif]

Models Types:

H64 (2GB+): 64x64 face resolution, which is used in the original FakeApp or FaceSwap app, but this model in DeepFaceLab uses TensorFlow 1.8 DSSIM Loss function and separated mask decoder and better ConverterMasked. For 2GB and 3GB VRAM model works in reduced mode.

H64 example: Robert Downey Jr

[Image: H64_Downey_0.jpg]

[Image: H64_Downey_1.jpg]

H128 (3GB+): Same as above; however the resolution is improved 128x128 which conserves better face details, and will perform better with higher resolution videos and close-up shots. For 3GB and 4GB VRAM model works in reduced mode.

H128 example: Nicholas Cage

[Image: H128_Cage_0.jpg]

H128 example: Asian face on blurry target

[Image: H128_Asian_0.jpg]

[Image: H128_Asian_1.jpg]

DF (5+GB): dfaker model. Has 128x128 resolution with a full face model. When using this model, it is recommended not to mix src faces with different lighting conditions.

DF example: Nicholas Cage

[Image: DF_Cage_0.jpg]

LIAEF (5GB+): New model which combines DF, IAE and experiments. The model tries to morph the src face into dst while keeping the facial features of src face but less aggressive morphine. This model has problems with closed eyes recognition. 

LIAEF128 example: Nicholas Cage

[Image: LIAEF128_Cage_0.jpg]

[Image: LIAEF128_Cage_1.jpg]

LIAEF128: Trump to Nicholas Cage example video



LIAEF128YAW (5GB+): Currently testing, but useful for when your src has too many side faces against dst faces. It feeds NN by sorted samples by yaw.

MIAEF128 (5GB+): Same as the model above, but it also tries to match brightness and color features.

MIAEF128 model algorithm:

[Image: MIAEF128_diagramm.png]

MIAEF128 success example: Harrison Ford

[Image: MIAEF128_Ford_0.jpg]

MIAEF128 fail example: Nicholas Cage

[Image: MIAEF128_Cage_fail.jpg]

AVATAR (4GB+): non GAN, 256x256 face controlling model.

[Image: AVATAR_Navalniy_0.jpg]

AVATAR video example:

#2
How to Use DeepFaceLab

This tutorial is based on how I use DeepFaceLab, which I now use to create my deepfakes. I don't know everything about this app yet, but this is a quick explanation of how I use it. I try to use an application that will produce decent results, with the least amount of work or time. For me, the easy version of DeepFaceLab works the best. This version has easy to use .bat files that input common commands for users so that we don't have to manually edit Python commands/codes to create our deepfakes.

You are not allowed to view links. Register or Login to view.

NOTE: This application uses PNG files for every frame. These images can be large in size, and since we are working with videos and extracting EACH frame, you need a lot of hard drive space. For example, one of my deepfakes from start to finish is 47 GB.

Install DeepFaceLab
  • The application in the download link above is already compiled with everything it needs to make deepfakes. You just need to extract the folder anywhere you want. In this example I have extracted it to my "D:\" drive on a Windows 10 PC.
Components of DeepFaceLab
  • Once you extract the folder to your PC, you should have something that looks like this
[Image: FrmLfAg.jpg]

Folders:

_internal - this folder contains all the dependencies, and python apps that are used in the background. You will not likely need to modify anything in this folder (unless you need to update something to the latest version)

workspace - this folder is where you will go to add stuff for the app to work. For example, you will add videos, and images to this folder which will be used to create your deepfake (see explanation below). This will also be where your final video will be generated. This is what your "workspace" folder should look like:

[Image: x21WTuF.jpg]
For the application to work, the names of the above files must remain this way. Please be sure not to change them.

"data_dst" folder - this is the folder where all your "destination" files will be contained. The "destination" is usually dealing with the model that you would like to change the face of (Pornstar).

"data_src" folder - this is the folder where all your "source" files will be contained. The "source" is usually the model face you would like to place on the "destination" model (Celebrity).

"data_dst" video - this is a video file that contains the video with the body you want to use (Porn video). It is called the destination video because this is the destination of where the desired face will be implanted.

"data_src" video - this is a video file that contains the face (celebrity) you want to take and place onto the destination body. 

Explanation of .bat files
The .bat files are files that will execute a certain code automatically. For new users, this saves us headaches by hiding the complicated code, and all we have to do is run one of the .bat files. I will be referring to the image above to explain only the ones I use. They are all titled appropriately and are pretty self explanatory. 

"1) clear workspace" - this will literally delete everything in the "workspace" folder and restore everything to the default folder/file structure. This is meant to be used when you want to start a new project. But if you want to save your model for later use, please remember to back it up! I don't use this .bat, I just manually delete the contents in "data_dst" and "data_src" folders.

"2) extract PNG from video data_src (1 FPS/5 FPS/10 FPS/ FULL FPS)" - this will take the video file that you named "data_src" in the workspace folder, and cut the video into frames so that you can extract the faces. You can choose which FPS (frame per second) to use. The higher the FPS, the more frames will be generated, meaning more faces and folder size.

"3.2) extract PNG from video data_dst FULL FPS" - this will take your destination video (porn video) and cut every frame into a PNG image. You can only use full FPS for this option because when you try to generate the video with the swapped faces, we want to FPS to be the same as the original.

"4) data_src extract faces MT best GPU" - this runs the module to extract faces from the images generated from the frames of video "data_src" using the MTCNN face detection. This may take longer than DLIB, but catches more angles then DLIB. It also produces more false positives (extracts faces that aren't really faces).

"4) data_src extract faces DLIB best GPU" - this runs the module to extract faces from the images generated from the frames of video "data_src" but using DLIB detection instead. This is is quicker than MTCNN but does not capture all angles.

"4.2.1) data_src sort by blur" - this takes all the extracted faces from your "data_src" video and sorts them by how blurry they are.

"4.2.2) data_src sort by similar histogram" - this takes all the extracted faces from your "data_src" video and sorts them by histogram (lights and darks), but it also does a good job at grouping faces together. This is useful when identifying extracted faces that are not your target, usually when more than one person/face is in your "data_src" video.

"5) data_dst extract faces MT all GPU" - once again, extracts all the faces from your "data_dst" video using the MTCNN face detection module.

"5) data_dst extract faces DLIB all GPU" - again, extracts all the faces from your "data_dst" video but uses the DLIB module.

"5.2) data_dst sort by similar histogram" - again, sorts all the extracted faces from your "data_dst" video by histogram. This also groups different faces together, making it easier to remove non-target faces.

"6) train (AVATAR/DF/H64/H128/LIAEF128/LIAEF128YAW/MIAEF128) best GPU" - begins training your model based on the one you selected. See post 1 above for examples and descriptions of each model type.

"7) convert (AVATAR/DF/H64/H128/LIAEF128/LIAEF128YAW/MIAEF128)" - this takes your trained model, and "converts" your dst face into your targeted src face. This will create a folder called "merged" in your data_dst folder where the converted images are kept.

"8) convert to (avi/mp4)" - this takes the converted images from the merged folder and compiles them into a watchable video format (.avi or .mp4) depending on what you choose. The audio will also be automatically transferred as well.
#3
My Personal DeepFake Workflow

The following describes my process and workflow. This is what works for me, it may not be the best or most efficient way to create deepfakes.

Creating Celebrity Faceset - Collecting data_src (celebrity) videos
  1. YouTube - 90% of the time I try to find interview videos on YouTube where I can extract images from. This is the simplest and quickest way to collect a celebrity faceset. I use the tool You are not allowed to view links. Register or Login to view. to download clips from YouTube in HD.
  2. Movies/TV shows - similarly, if the celebrity is in movies or TV shows, you can download them and use a video editor to splice out scenes of the celebrity. TV shows or movies are also a good source to find those difficult angles (below or above).
  3. Images - Last source would be source image boards or googles for photoshoots with HD photos.
  • If I find a single long, interview video that has consistent lighting, with different facial expressions and different angles, I download and rename the video "data_src" to extract the celebrity face.
  • If I need to collect interview clips from multiple short videos, I use a video editor (Adobe Premiere) to combine the videos into one, then rename the video "data_src" to extract the celebrity face.
Extracting Faces from data_src (celebrity) video
  1. Make sure you name the celebrity video you just made to "data_src" and place it in the appropriate directory "/workspace"
  2. Next, run "2) extract PNG from video data_src 5 FPS" -  usually use 5 FPS so I can ensure I have enough images for a decent faceset. I can always remove and delete images later if I want to reduce the size of the faceset.
  3. Next, run "4) data_src extract faces MT best GPU" - This will extract and align your faceset. The images will be in "/workspace/data_src/aligned" in sequence. The faceset needs to stay in this directory, but you can now clean up the faceset.
  4. Next, run "4.2.2) data_src sort by similar histogram" - This will sort all the images by histogram, and often groups different faces together. You should then manually go through this folder and delete any images that are not of the target celebrity, are blurry, or any duplicates. Some times I use the program You are not allowed to view links. Register or Login to view. to help remove similar images if I have a lot extracted.
  5. (Optional) Sometimes I also run "4.2.4) data_src sort by dissimilar histogram" - This will sort images that are really different from each other first. I then view the images at the end of the folder, and if they mostly look the same, I will delete 1/4 of the images to reduce my faceset size.
What Images should be removed?
- This section to be completed when I get some screenshots

Extracting Faces from data_dst (pornstar) video
After finding a porn video where the actress looks like the celebrity, I edit the porn video and cut out any scenes that aren't required like intros, or scenes with odd angles that I know won't tun out well to save time. I then rename the file to "data_dst" and place it in the appropriate directory "/workspace".

  1. Run "3.2) extract PNG from video data_dst FULL FPS" - This takes the porn video and cuts it up into every frame.
  2. Next, run "5) data_dst extract faces DLIB (or MT) all GPU" - This will extract your pornstar face and align them using the DLIB or MTCNN depending on what you select.
  3. Next, run "5.2) data_dst sort by similar histogram" - Again, this will sort the pornstar faces by histogram. You should then go through the images and delete images that are not of the pornstar face. Every image that you delete will not be converted/swapped to the celebrity face.

Once everything is is cleaned up, you may begin to train your model.

Train your DeepFake model
There are several models to choose from. Please see post #1. Most of the time I run H128.

  1. Run "6) train H128 best GPU"
This process takes the longest. I usually let the training run until it reaches an Epoch higher then 100000.

Once training reaches this point and the preview looks good you can save the model by clicking "Enter" while on the preview screen.

Converting your model (swapping the faces)
Run the appropriate bat file. Again, for me I use H128 most of the time.

  1. Convert H128
You will then be promoted to select different settings.



TO BE CONTINUED
#4
I'll try to follow this now. Thanks!
#5
When I click the .bat files to extract the destination video nothing happens. There's a command run that pops out like a blink.

'C:\DeepFaceLab\DeepFaceLab' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

ffmpeg version N-89980-ge752da5464 Copyright © 2000-2018 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
libavutil 56. 7.100 / 56. 7.100
libavcodec 58. 10.100 / 58. 10.100
libavformat 58. 9.100 / 58. 9.100
libavdevice 58. 1.100 / 58. 1.100
libavfilter 7. 11.101 / 7. 11.101
libswscale 5. 0.101 / 5. 0.101
libswresample 3. 0.101 / 3. 0.101
libpostproc 55. 0.100 / 55. 0.100
C:\DeepFaceLab\DeepFaceLab: Permission denied
Press any key to continue . . .
#6
(10-24-2018, 09:32 AM)miketran Wrote: You are not allowed to view links. Register or Login to view.When I click the .bat files to extract the destination video nothing happens. There's a command run that pops out like a blink.

'C:\DeepFaceLab\DeepFaceLab' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

ffmpeg version N-89980-ge752da5464 Copyright © 2000-2018 the FFmpeg developers
 built with gcc 7.2.0 (GCC)
 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
 libavutil      56.  7.100 / 56.  7.100
 libavcodec     58. 10.100 / 58. 10.100
 libavformat    58.  9.100 / 58.  9.100
 libavdevice    58.  1.100 / 58.  1.100
 libavfilter     7. 11.101 /  7. 11.101
 libswscale      5.  0.101 /  5.  0.101
 libswresample   3.  0.101 /  3.  0.101
 libpostproc    55.  0.100 / 55.  0.100
C:\DeepFaceLab\DeepFaceLab: Permission denied
Press any key to continue . . .

hello mike
when you extract the file archive for  the install , reduce the name of this .
ex:
C:\DeepFaceLab\DFL\
The error diseapear Angel

You are not allowed to view links. Register or Login to view.



#7
Thanks Marss. But this also came out

'C:\DeepFaceLab\DFL\DeepFaceLab' is not recognized as an internal or external command,
operable program or batch file.
#8
(10-24-2018, 03:16 PM)miketran Wrote: You are not allowed to view links. Register or Login to view.Thanks Marss. But this also came out

'C:\DeepFaceLab\DFL\DeepFaceLab' is not recognized as an internal or external command,
operable program or batch file.

ok i explain better Big Grin 

rename the original name folder "DeepFaceLab Easy" to "DFL" for have this ...
"C:\DeepFaceLab\DFL\_internal" 
"C:\DeepFaceLab\DFL\workspace"
"C:\DeepFaceLab\DFL\*.bat"

You are not allowed to view links. Register or Login to view.



#9
OMG! It worked! Thanks a lot Marss! and ofcourse dpfks

Btw, can I use my faceset from fakeapp 1 to deepfacelab?

Btw, can I use my faceset from fakeapp 1 to deepfacelab?
#10
(10-24-2018, 03:33 PM)marss Wrote: You are not allowed to view links. Register or Login to view.
(10-24-2018, 03:16 PM)miketran Wrote: You are not allowed to view links. Register or Login to view.Thanks Marss. But this also came out

'C:\DeepFaceLab\DFL\DeepFaceLab' is not recognized as an internal or external command,
operable program or batch file.

ok i explain better Big Grin 

rename the original name folder "DeepFaceLab Easy" to "DFL" for have this ...
"C:\DeepFaceLab\DFL\_internal" 
"C:\DeepFaceLab\DFL\workspace"
"C:\DeepFaceLab\DFL\*.bat"

Thank you for identifying the issue! I'm going to rename the folders so there are no spaces.

(10-24-2018, 05:13 PM)miketran Wrote: You are not allowed to view links. Register or Login to view.OMG! It worked! Thanks a lot Marss! and ofcourse dpfks

Btw, can I use my faceset from fakeapp 1 to deepfacelab?

Btw, can I use my faceset from fakeapp 1 to deepfacelab?

Yes you can. Just copy the image files into the /data_src/aligned folder then run the extract bat file
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • ...
  • 16
  • Next 

Forum Jump:

Users browsing this thread: UwU_bots, 1 Guest(s)