Skip to content

piktid/swapid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwapID by PiktID logo

SwapID by PiktID

SwapID - v3.3.1

Official Website Discord Follow

Face Swap implementation by PiktID, also available online at studio.piktid.com

This implementation relies on the EraseID infrastructure and APIs.

Getting Started

Open In Colab

The following instructions suppose you have already installed a recent version of Python. For a general overview, please visit the API documentation. To use any PiktID API, an access token is required.

Step 0 - Register here. 10 credits are given for free to all new users.

Step 1 - Clone the SwapID library

# Installation commands
$ git clone https://github.com/piktid/swapid.git
$ cd swapid

Step 2 - Export the email and password as environmental variables

$ export PIKTID_EMAIL={Your email here}
$ export PIKTID_PASSWORD={Your password here}

or the authenticaton tokens - get them in https://studio.piktid.com/profile -> Tokens & Sessions

$ export ACCESS_TOKEN={Your access token}
$ export REFRESH_TOKEN={Your refresh token}

Step 3 - You can provide both the absolute path of the target and face image (containing a person). Add the arguments

...
--target_path 'mydir/mytarget.jpg'
or
--face_path 'mydir/mysource.jpg'
...

Alternatively, you can provide the url of the target and face image, as in the default example with the Einstein face on the Monalisa image.

...
--target_url 'https://images.piktid.com/frontend/studio/swapid/target/monalisa.jpg'
or
--face_url 'https://images.piktid.com/frontend/studio/swapid/face/einstein.jpg'
...

Step 4 - Run the main function with the selected images

$ python3 main_swap.py --target_path 'mydir/mytarget.jpg' --face_path 'mydir/mysource.jpg'

Without any additional argument, SwapID will upload both images into PiktID's servers and provide (read the logs) the codes for both images, which you can reuse for further re-generations, one for the target 'abc' and one for the face 'xyz'. The swap asynchronously elaborates your images. It reads the notifications, and once the swap process is over, it extracts the link of the swapped image.

Step 5 - Rerun the main function with PiktID's codes

$ python3 main_swap.py --target_name 'abc' --face_name 'xyz'

Step 6 - Play with the parameters

If the result is not satisfactory enough, we recommend either changing the seed or strength of the source image (lower strength results in low influence of the source on the output)

$ python3 main_swap.py --target_name 'abc' --face_name 'xyz' --seed 1234 --strength '0.55'

Step 7 - Multiple faces

If you have a target image with multiple subjects, you need to inform the system, via the idx_face integer argument, which face to swap. As an example:

$ python3 main_swap.py --target_path 'mydir/mytarget.jpg' --face_path 'mydir/mysource.jpg' --idx_face 0

Head Swap and Hair Transfer

It is also possible to include the hair in the swapping process. To do that, you need to run the command

$ python3 main_swap.py --target_path 'mydir/mytarget.jpg' --face_path 'mydir/mysource.jpg' --hair

If you want to completely transfer the hairstyle of the source to the target, you can use the following command (which works for a strength greater than 0.5)

$ python3 main_swap.py --target_path 'mydir/mytarget.jpg' --face_path 'mydir/mysource.jpg' --hair --transfer_hair

Skin Swap

If you want to adjust the body skin of the swapped image, you can use the following command

$ python3 main_swap.py --target_path 'mydir/mytarget.jpg' --face_path 'mydir/mysource.jpg' --skin

Please contact us for more details.

Contact

office@piktid.com

About

FaceSwap repository by PiktID

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages