Instructions to use ilkerzgi/face-swap with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use ilkerzgi/face-swap with Diffusers:
pip install -U diffusers transformers accelerate
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] - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
Dataset
What did you use to create the dataset? The prompt is literally the same as my model, the difference being that it says "face swap" but in the end it does a "head swap".
Hey, sorry I saw this a bit late.
I remember using FLUX to create the dataset too without any LoRA. The ground truth examples in the README are already examples of that pipeline. First I created the ground truth, then I changed only the face in the ground truth. I also took the original character from the ground truth and generated an image of them in a different scene. I created the dataset in the reverse direction too and trained.
I trained around 20+ different versions, and both the prompts and the trainer settings were different across many of them. I tried a lot of prompt formats including JSON prompts, prompts written only with commas, and several other styles. Since I had AI generate all of them automatically, I didn’t realize that this specific prompt style was yours. Sorry about that.
I can add a note about this at the bottom if you’d like.