CoolFace
Modelpublic

linoyts/flux2-klein-bbox-drag-drop-lora

sourceHugging Faceotherupdated 6mo agoView on Hugging Face
9likes108downloads
Model Card

Flux.2 [Klein] 9B Bounding-Box Drag & Drop LoRA - linoyts/flux2-klein-bbox-drag-drop-lora

Model description

These are linoyts/flux2-klein-bbox-drag-drop-lora LoRA weights, compatiable with both black-forest-labs/FLUX.2-klein-9B and black-forest-labs/FLUX.2-klein-base-9B.

Given an input image with a red bounding box (source) and a green bounding box (target), the model moves and resizes the object from the red box to the green box, seamlessly blending the result into the scene.

Download model

Download the *.safetensors LoRA in the Files & versions tab.

Use it with the 🧨 diffusers library

Prompt Tip: it's reccomneded to specifiy the object/subject moved or resized.

Few steps (4–8) inference with Flux.2 [Klein] 9B

This LoRA also works well at 4–8 inference steps. When using fewer steps we recommend bumping the LoRA scale to 1.25:

py
pipeline = Flux2KleinPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein-9B", torch_dtype=torch.bfloat16
).to("cuda")

pipeline.load_lora_weights(
    "linoyts/flux2-klein-bbox-drag-drop-lora",
    weight_name="pytorch_lora_weights.safetensors",
    adapter_name="bbox",
)
pipeline.set_adapters("bbox", adapter_weights=1.25)

result = pipeline(
    prompt=prompt,
    image=image,
    num_inference_steps=4,
    guidance_scale=4.0,
).images[0]

run with Flux.2 [klein] Base 9b

py
from diffusers import Flux2KleinPipeline
from diffusers.utils import load_image
import torch

pipeline = Flux2KleinPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein-base-9B", torch_dtype=torch.bfloat16
).to("cuda")
pipeline.load_lora_weights(
    "linoyts/flux2-klein-bbox-drag-drop-lora",
    weight_name="pytorch_lora_weights.safetensors",
)

image = load_image("path-or-url-to-your-image")

prompt = (
    "Move the {object} inside the red bounding box to the position and size indicated by the green bounding box."
    "Remove the {object} from its original location in the red box, filling in the background naturally."
    "Remove the bounding boxes and seamlessly blend the repositioned {object} into the scene, preserving all other objects and the background exactly as they are."
)

result = pipeline(
    prompt=prompt,
    image=image,
    num_inference_steps=30,
    guidance_scale=4,
).images[0]
result.save("output.png")

For more details, including weighting, merging and fusing LoRAs, check the documentation on loading LoRAs in diffusers

License

Please adhere to the licensing terms as described here.