SwapID - Full Body Person Swap is an advanced GenAI tool designed to perform comprehensive person swapping in images using a revolutionary two-step process that ensures superior skin tone matching and seamless integration.
SwapID utilizes a sophisticated two-step approach to achieve the most realistic person swaps possible:
-
Full Body Generation: The tool first identifies the person in your target image and generates a complete new body that matches the reference person's characteristics, including skin tone, build, and overall appearance.
-
Face/Head Swap: Using the newly generated body as the base, the tool then performs a precise face or head swap using the same reference image, ensuring perfect skin tone continuity and natural integration.
- Superior Skin Tone Matching: The two-step process ensures perfect skin tone continuity between face and body
- Cross-Ethnicity Swapping: Successfully swap between people of different ethnicities (e.g., dark skin on light skin photos and vice versa)
- Natural Integration: The full body generation creates a cohesive base for the final face swap
- Advanced AI Processing: Leverages cutting-edge generative AI for realistic results
- Single Person Images: Currently optimized for images containing only one person
- Target Person Detection: The tool automatically detects and processes the primary person in the image
The following instructions suppose you have already installed a recent version of Python. 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 - Full Body Person Swap repository
# Installation commands
$ git clone https://github.com/piktid/swapid-person.git
$ cd swapid-person
Step 2 - Export your 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 - Run the main function with target and reference images
# Using URLs for both target and reference images
$ python3 main_full.py --target_url 'your-target-image-url' --reference_url 'your-reference-image-url' --body
# Using local file paths
$ python3 main_full.py --target_path '/path/to/target/image.jpg' --reference_path '/path/to/reference/image.jpg' --body
# Face-only swap (without full body generation)
$ python3 main_full.py --target_path '/path/to/target/image.jpg' --reference_path '/path/to/reference/image.jpg'
You can customize the generation with advanced parameters:
# Full body swap with custom parameters (e.g. including hair transfer)
$ python3 main_full.py --target_path '/path/to/target.jpg' --reference_path '/path/to/reference.jpg' --body --hair --transfer_hair --seed 12345 --swap_strength 0.55 --person_strength 0.9
- target_path: Local path to the target image file
- target_url: URL of the target image (used if no target_path provided)
- reference_path: Local path to the reference image file
- reference_url: URL of the reference image (used if no reference_path provided)
- target_name: Target image code name (overrides target_path if provided)
- reference_name: Reference image code name (overrides reference_path if provided)
- seed: Random seed for reproducible results
- prompt: Target image description for enhanced generation
- controlnet_scale: Resemblance with target face (range 0-2)
- guidance_scale: Generation guidance scale (range 1-20)
- --hair: Include hair in the swap (head-swap mode)
- transfer_hair: Transfer source hair into target (transfer-hair mode)
- swap_strength: Face similarity level with reference (range 0-1)
- id_face: Index of the face to swap in target image (default: 0)
- --body: Enable full body swap (recommended for best results)
- person_strength: Similarity with reference person (range 0-1)
- var_strength: Creativity level in generation (range 0-1)
- id_person: Index of person to modify in target image (default: 0)
python3 main_full.py --target_path './images/target.jpg' --reference_path './images/reference.jpg' --body
python3 main_full.py --target_path './images/target.jpg' --reference_path './images/reference.jpg'
python3 main_full.py --target_path './images/target.jpg' --reference_path './images/reference.jpg' --body --hair --swap_strength 0.55 --person_strength 0.9 --controlnet_scale 0.1
python3 main_full.py --target_path './images/target.jpg' --reference_path './images/reference.jpg' --body --hair --transfer_hair --swap_strength 0.55 --person_strength 0.9 --controlnet_scale 0.1