Instructions to use linoyts/flux2-klein-bbox-drag-drop-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use linoyts/flux2-klein-bbox-drag-drop-lora 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-base-9B,black-forest-labs/FLUX.2-klein-9B", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("linoyts/flux2-klein-bbox-drag-drop-lora") prompt = "Turn this cat into a dog" 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] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
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-base-9B,black-forest-labs/FLUX.2-klein-9B", dtype=torch.bfloat16, device_map="cuda")
pipe.load_lora_weights("linoyts/flux2-klein-bbox-drag-drop-lora")
prompt = "Turn this cat into a dog"
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]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:
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
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.
- Downloads last month
- 53
Model tree for linoyts/flux2-klein-bbox-drag-drop-lora
Base model
black-forest-labs/FLUX.2-klein-9B