explaingit

adeliox/klein-head-swap

Analysis updated 2026-05-18

4PythonAudience · designerComplexity · 3/5Setup · moderate

TLDR

A Forge-Neo extension that swaps an entire head (face and hair) from a reference photo onto a target image using the Flux.2 Klein model and a Faceswap LoRA, generating the result rather than pasting pixels.

Mindmap

mindmap
  root((Klein Head Swap))
    What it does
      Swaps face and hair
      AI generated result
      Matches lighting
    Two modes
      Empty prompt head swap
      Descriptive prompt creative edit
    Requirements
      Forge-Neo
      Flux.2 Klein model
      bfs_head_v1 LoRA
    Settings
      Denoise must be 1.0
      LoRA strength
      Reference image size
    Install
      Clone to extensions folder
      Restart Forge-Neo
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Replace the head in a portrait photo with a different person's face and hair using AI generation that matches lighting and skin tone.

USE CASE 2

Composite a character's head onto a different body or scene by providing a reference face and a target image.

USE CASE 3

Use the creative-edit mode with a descriptive prompt and reference image to change a person's hairstyle or clothing in a generated image.

What is it built with?

PythonStable DiffusionFlux.2 KleinLoRA

How does it compare?

adeliox/klein-head-swapats4321/ragitaudiohacking/audiogen.cpp
Stars444
LanguagePythonPythonPython
Setup difficultymoderatemoderatehard
Complexity3/52/54/5
Audiencedesignerdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires the Flux.2 Klein model checkpoint and the bfs_head_v1 LoRA file downloaded separately before the extension will function.

No license is stated in this repository.

In plain English

Klein Head Swap is an extension for Forge-Neo, a variant of the Stable Diffusion image generation web interface. Its purpose is to transplant the entire head, including both face and hair, from a reference photo onto a target image during the generation process. You upload a target photo (the body or scene you want the head placed onto) and a separate reference photo (the person whose head you want to copy), and the AI model generates the result with the two combined. The extension works specifically with the Flux.2 Klein model, not with general-purpose Stable Diffusion checkpoints. Klein has a built-in mechanism for referencing an input image during generation, and this extension hooks into that mechanism to feed the reference face into the process. A LoRA fine-tuning file called bfs_head_v1 is also required, you download it separately and place it in the LoRA folder of your Forge-Neo installation. Because the head is generated by the model rather than pasted on top as a post-processing step, the result adapts to the lighting and skin tones of the target scene. The README contrasts this with older face-swap tools that produce noticeable artifacts because they composite pixels rather than regenerating the head as part of the image. The extension has two modes. When you leave the prompt empty, the LoRA takes control and performs the head swap. When you write a descriptive prompt, the reference image acts as visual context while the prompt drives the generation, which the README describes as useful for compositing, style changes, and background modifications. Installation involves cloning the repository into the extensions folder of Forge-Neo and restarting the interface. The extension then appears as a panel in the img2img tab. Key settings include the denoise strength, which must be set to 1.0 for the head swap to work correctly, and a maximum pixel size for the reference image that controls how much detail is preserved versus how much video memory is consumed. No license is stated in the repository.

Copy-paste prompts

Prompt 1
I have Forge-Neo installed. Walk me through cloning klein-head-swap into the extensions folder, downloading the bfs_head_v1 LoRA, and running my first head swap.
Prompt 2
My klein-head-swap result looks blurry or off. I have denoise set to 0.7. What settings should I adjust for a proper head swap result?
Prompt 3
Explain the difference between head-swap mode and creative-edit mode in klein-head-swap and show me an example prompt for each.
Prompt 4
I want to use klein-head-swap for compositing a person into a different background. Walk me through setting up a descriptive prompt with the reference image as visual context.
Prompt 5
Show me how the reference face encoding works in the klein-head-swap Python code and what ref_latents does in the Flux.2 Klein model.

Frequently asked questions

What is klein-head-swap?

A Forge-Neo extension that swaps an entire head (face and hair) from a reference photo onto a target image using the Flux.2 Klein model and a Faceswap LoRA, generating the result rather than pasting pixels.

What language is klein-head-swap written in?

Mainly Python. The stack also includes Python, Stable Diffusion, Flux.2 Klein.

What license does klein-head-swap use?

No license is stated in this repository.

How hard is klein-head-swap to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is klein-head-swap for?

Mainly designer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub adeliox on gitmyhub

Verify against the repo before relying on details.