import torch
from diffusers import DiffusionPipeline
from diffusers.utils import load_image
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.2-klein-9B", dtype=torch.bfloat16, device_map="cuda")
pipe.load_lora_weights("ilkerzgi/face-swap")
prompt = "face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting."
input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")
image = pipe(image=input_image, prompt=prompt).images[0]
license:otherlicense_name:flux-non-commercial-licensebase_model:-black-forest-labs/FLUX.2-klein-9Bbase_model_relation:adapterlibrary_name:diffuserspipeline_tag:image-to-imagetags:-lora-face-swap-flux-flux-2-klein-fal-safetensors-image-generationwidget:-text:>- face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.output:url:>- https://huggingface.co/ilkerzgi/face-swap/resolve/main/images/uptUNwXgA8EwG0z3nrU9D_xitedmd1.png-text:>- face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.output:url:>- https://huggingface.co/ilkerzgi/face-swap/resolve/main/images/p8VRilcpJwVfQMhhd1tcP_4XLB5cQm.png-text:>- face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.output:url:>- https://huggingface.co/ilkerzgi/face-swap/resolve/main/images/5GvzCmqBXxkiPtOUsD79u_txyQKwTR.png-text:>- face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.output:url:>- https://huggingface.co/ilkerzgi/face-swap/resolve/main/images/t4C2QjrNO20JMbf1zZooH_4TirbpGG.png-text:>- face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.output:url:>- https://huggingface.co/ilkerzgi/face-swap/resolve/main/images/4-XBoOuL1zkz-huT39gnP_QeDdCFoP.png-text:>- face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.output:url:>- https://huggingface.co/ilkerzgi/face-swap/resolve/main/images/IyzFIKmJvvym9GbwfN3KC_gifsjYqL.png
Face-Swap LoRA for FLUX 2 Klein 9B
Prompt
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
Prompt
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
Prompt
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
Prompt
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
Prompt
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
Prompt
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
A LoRA adapter for FLUX 2 Klein 9B fine-tuned for high-quality face swapping. Given a face source image and a body/scene image, the model produces a natural face swap preserving identity, lighting, and skin tone.
Prompt
Use the following prompt for best results:
face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. the result should show the exact face and features from Picture 1 on the body, pose, and scene from Picture 2, with natural skin tone blending and matching lighting.
Picture 1: Face source image (the identity to transfer)
Picture 2: Body/scene image (the target pose and environment)
import fal_client
defon_queue_update(update):
ifisinstance(update, fal_client.InProgress):
for log in update.logs:
print(log["message"])
result = fal_client.subscribe(
"fal-ai/flux-2-klein/9b/base/edit/lora",
arguments={
"prompt": "face_swap: take the face from Picture 1 and swap it onto the person in Picture 2. ""the result should show the exact face and features from Picture 1 on the body, pose, ""and scene from Picture 2, with natural skin tone blending and matching lighting.",
"model_name": None,
"loras": [{
"path": "https://huggingface.co/ilkerzgi/face-swap/resolve/main/FS2_V2_r32_800_pytorch_lora_weights.safetensors",
"scale": 1
}],
"embeddings": [],
"image_urls": [
"https://example.com/face_source.png",
"https://example.com/body_scene.png"
],
"num_images": 4
},
with_logs=True,
on_queue_update=on_queue_update,
)
print(result)
Evaluation Overview
Test Cases
LoRA Variants
Image Models
Total Generations
Dataset Sizes
25
9
3
300
300 / 800
9 LoRA variants were trained with different hyperparameters and evaluated against 3 image models across 25 diverse test subjects.
Training Configurations
Variant
Samples
Rank
Steps
LR
Guidance
Avg Latency
V1 r16 (300)
300
16
3000
5e-5
1
6.0s
V2 r32 (300)
300
32
3500
5e-5
1
6.1s
V3 r32+cfg (300)
300
32
3500
5e-5
3.5
6.6s
V1 r16 (800)
800
16
3000
5e-5
1
6.4s
V2 r32 (800)
800
32
3500
5e-5
1
6.3s
V3 r32+cfg (800)
800
32
3500
5e-5
3.5
6.2s
V4 r32 long (800)
800
32
5000
5e-5
1
6.4s
V5 r64 (800)
800
64
4000
3e-5
1
6.4s
V6 r32 slow (800)
800
32
5000
1e-5
1
6.4s
Image Models
Model
Avg Latency
Nano Banana 2
28.8s
Nano Banana Pro
33.3s
GPT Image 1.5
30.3s
Latency Comparison
Model
Avg Latency
V1 r16 (300)
6.0s
V2 r32 (300)
6.1s
V3 r32+cfg (800)
6.2s
V2 r32 (800)
6.3s
V6 r32 slow (800)
6.4s
V4 r32 long (800)
6.4s
V5 r64 (800)
6.4s
V1 r16 (800)
6.4s
V3 r32+cfg (300)
6.6s
Nano Banana 2
28.8s
GPT Image 1.5
30.3s
Nano Banana Pro
33.3s
All LoRA variants average ~6-7s, while image models average ~29-33s.