Guide Fake Video Face Swap (moderate complexity, Rope)

  • Welcome to the Fakes / AI / Deepfakes category
    When posting AI generated content please include prompts used where possible.

softarchitect

Tier 3 Sub
May 16, 2022
55
419
512
0fya082315al84db03fa9bf467e3.png

DISCLAIMER: This guide is somewhat technical, there are probably cases / errors that are not included in this guide, and can cause you to waste time and effort without any success.​


0. Introduction​

This guide will provide steps to install Rope (
Please, Log in or Register to see links and images
) to create videos by face swapping a person's face onto another video.

1. Requirements​

This application works with both CPU and GPU setups.

When using Windows, this guide requires Windows 10 1709 (build 16299) or later (incl. Windows 11).

While a Nvidia graphics card (GPU) is not required, it will make the swapping process much faster.
If you have a GPU, install Nvidia's
Please, Log in or Register to see links and images
and
Please, Log in or Register to see links and images
if you have not already installed these.


2. Installation​


Please, Log in or Register to view spoilers

Please, Log in or Register to view spoilers

Please, Log in or Register to view spoilers

3. Preparation​

3.1. Source (Celeb/Influencer)​

First you have to decide with person you want to swap in to a video.

Select some high quality pictures where the face is visible, and where the part of the face is not too small. E.g. full face image (+- 300-400px image height), half body image (+- 750 - 1024px image height), full body image (1024+px image height, best to avoid these). The higher quality / size, the better.

It's also best to select several pictures where the person is looking to the left, front and right. The model will "merge" the different faces to get optimal results. Even selecting pictures with the teeth visible, closed eyes, etc can improve the result a little bit.


3.1. Destination (Porn star)​

This is the hardest part, finding a porn star that has a face that has the same "dimensions" / shape as the chosen person in the previous section.

Using "Face Match" tools will not (always) work, since these will most of the time look at the face itself, and not the shape. YMMV



3.2. Target Video​

Note: this method will give bad results if the video has frames with obstructions in front of the face.

When selecting a video, it's best to cut/slice the video and remove unwanted / filler scenes, scenes with obstructions in front of the face, etc.

There's a lot of software that can slice / edit videos, some free/opensource options:
Please, Log in or Register to see links and images
,
Please, Log in or Register to see links and images
,
Please, Log in or Register to see links and images

This guide will not include how to edit videos with the above software, there are enough guides on that elsewhere.

It's also a good idea when editing the video, to transcode to 720p and 24 frames / second, this is improve the speed of the process and not waste resources. But that's up to you :WeSmart:


4. UI​

265270793-fda0c05f-72a6-4935-a882-dc6d17cfc014.png


The UI has 3 "input" sections. From bottom to top:
  • Video selection
  • Source Faces
  • Destination Face

5. Start​

To start the process:
  • Select your Source Faces Folder
  • Select your Target Videos Folder
  • Select your Output Folder
  • Click Load Folders
  • Click on GFPGAN (used to improve / upscale the resulting face)
  • All other settings are optional and can either improve or degrade the result. E.g. you can use CLIP with "hands, penis" in the input box or Occluder/Mouth Parser to improve the result when there are obstructions in front of the face. But it will never be 100%, there will be a lot of distortion, etc. Best solution is to avoid frames with obstructions.
265268484-adbd042f-0a7b-4d3a-9f36-674d502965c3.png

  • 1. Select a Target Video (mousewheel scroll the Target Videos)
  • 2. Move to a video frame with faces in it and click Find
  • 3. Select a found Target Faces (mousewheel scroll the Target Faces)
  • 4. Select a Source Face (hold shift to select multiple Source Faces), (mousewheel scroll the Source Faces), (mousewheel scroll in the Video Player to iterate through the Source Faces)
  • 5. Click Swap to test the swap
  • 6. Move to the first frame in the video, click on the circle (Record) and then press the Play icon.

6. Additional Tips​

  • When asking for help, don't forget to add a screenshots of the console output if there are any errors
  • Whenever you see 'OOM (Out of Memory)' in the console output, it most of the time means that you do not have enough system RAM or (graphics) VRAM to run it
  • The mousewheel does not seem to work on Linux
 
Last edited:

Axelhart69

Casual
Feb 26, 2023
19
28
329
0fya082315al84db03fa9bf467e3.png
Rope is my new favourite tool since a few weeks. With the additional options you can even get some okeyish results with obstructions in front of the face
 

softarchitect

Tier 3 Sub
May 16, 2022
55
419
512
0fya082315al84db03fa9bf467e3.png
Please, Log in or Register to view quotes
Yeah, CLIP and Mouthparser are better than nothing, but it's highly dependent on the scene, etc. and most of the time not that good.

Where "real" deepfaking (DeepFaceLab, etc) takes days, weeks or months to master to get good results, Rope, and similar faceswap tools, are the lazy-mans deepfake tool :KEKW:

It's a pity the original creators of the inswapper model (InsightFace) have fully closed it off from the public. The current inswapper model, used by all the latest faceswap tools, is a 128x128 resolution model. Meaning it will result in a maximum face size / resolution of 128 by 128 pixels, that's why you have to use upscaling (like GFPGAN) to get "good" results. Else the face will just be pixelated / blurry.
 
  • Like
Reactions: Axelhart69

softarchitect

Tier 3 Sub
May 16, 2022
55
419
512
0fya082315al84db03fa9bf467e3.png
Please, Log in or Register to view quotes
AFAIK, no, this requires a UI, and Colab doesn't do UIs.

You can try Refacer (
Please, Log in or Register to see links and images
), but I have not tested this, and not sure if it has NSFW checks.

But let me know if it works, so I can add it to the post.

Also, be aware that doing NSFW on Colab can get you banned.
 

stargateluffy

Lurker
Dec 16, 2022
5
12
313
0fya082315al84db03fa9bf467e3.png
thank you very much , everything worked fine until i tried to record, i can play the video frame by frame with face swaping being active , but when i pause the video and click on record then play it again, nothing happens , the video is stopped and cannot play it again , any help please?
 

gensei

Lurker
Jan 23, 2023
2
0
46
0fya082315al84db03fa9bf467e3.png
NO_SUCHFILE : Load model from .\models\det_10g.onnx failed:Load model .\models\det_10g.onnx failed. File doesn't exist

Once the video did start up now it doesn't aaand cant find source faces
 

softarchitect

Tier 3 Sub
May 16, 2022
55
419
512
0fya082315al84db03fa9bf467e3.png
Please, Log in or Register to view quotes
Rope devs hardcoded Windows style paths for some models.

I'm guessing you are using Linux ?

You'll need to open rope/external/insight/face_analysis.py with a text editor and remove the ".\" in front of all the model files, and change the '\' in to '/'.

So, open rope/external/insight/face_analysis.py , go to line 29 and change (replace) the next 4 lines to

Python:
Please, Log in or Register to view codes content!


To be clear, this is ONLY if you are using Linux, and probably only for Rope version Sapphire-Shard (2023-11-18)
 

stargateluffy

Lurker
Dec 16, 2022
5
12
313
0fya082315al84db03fa9bf467e3.png
Please, Log in or Register to view quotes
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\B\anaconda3\envs\rope\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "C:\Users\B\anaconda3\envs\rope\lib\tkinter\__init__.py", line 814, in callit
func(*args)
File "C:\0\0\Rope-main\rope\Coordinator.py", line 51, in coordinator
vm.play_video(action[0][1])
File "C:\0\0\Rope-main\rope\VideoManager.py", line 329, in play_video
self.sp = subprocess.Popen(args, stdin=subprocess.PIPE)
File "C:\Users\B\anaconda3\envs\rope\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\B\anaconda3\envs\rope\lib\subprocess.py", line 1436, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable


this is the code
 

joakimnoa

Tier 3 Sub
Jun 1, 2022
10
347
537
0fya082315al84db03fa9bf467e3.png
I get this error when downloading torch
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
torch==2.0.1+cu118 from
Please, Log in or Register to see links and images
(from -r .\requirements.txt (line 11)):
Expected sha256 b663a4ee744d574095dbd612644de345944247c0605692309fd9f6c7ccdea022
Got c7173d8bd1b4f9660102b5077ccb0fd1028fb28564b8bac226728d8e4a633203
 

thebadbone

Tier 2 Sub
Mar 17, 2022
19
197
384
0fya082315al84db03fa9bf467e3.png
Managed to get into the UI but when trying to add the Source folder it doesn't work. The console says: "onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [ONNXRuntimeError] : 3 : NO_SUCHFILE : Load model from .\models\det_10g.onnx failed:Load model .\models\det_10g.onnx failed. File doesn't exist" and indeed, there is no det_10g.onnx file within the models folder as it's missing from the models archive provided. Any suggestions?
 
Last edited:

thebadbone

Tier 2 Sub
Mar 17, 2022
19
197
384
0fya082315al84db03fa9bf467e3.png
The models zip doesn't contain all the models needed to use the tool, just by mindful of that. Found the models on a different page and it works. Any suggestions for bj videos? The face turns out all distorted
 

Axelhart69

Casual
Feb 26, 2023
19
28
329
0fya082315al84db03fa9bf467e3.png
Please, Log in or Register to view quotes
Just download models from the official gjthub:
Please, Log in or Register to see links and images

Read into the different options and experiment with them for bj videos.
Please, Log in or Register to see links and images

There is no good option for BJ videos.

The only way is to unmask the area of the mouth, so it don't get swapped in that area. Downside: original mouth, visible edge between orig and swapped face, due to movement, areas which need to be masked/unmasked are likely changing and orig/swapped aras will clip e.g. Sometimes you will see orig mouth ans swapped mouth. Sorry, not sure how to explain it better.
 
  • Like
Reactions: coins