metadata
license: apache-2.0
FLUX.1-dev Controlnet
Diffusers version: until the next Diffusers pypi release, please install Diffusers from source and use this PR to be able to use FLUX controlnet. TODO: change when new version.
Demo
import torch
from diffusers.utils import load_image
from diffusers.pipelines.flux.pipeline_flux_controlnet import FluxControlNetPipeline
from diffusers.models.controlnet_flux import FluxControlNetModel
controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Canny-alpha'
controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
pipe.to("cuda")
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Canny-alpha/resolve/main/canny.jpg")
prompt = "A girl in city, 25 years old, cool, futuristic"
image = pipe(
prompt,
control_image=control_image,
controlnet_conditioning_scale=0.6,
num_inference_steps=28,
guidance_scale=3.5,
).images[0]
image.save("image.jpg")
Limitation
The current weights are trained on 512x512, but inference can still be performed on non-512 sizes. The latest 1024 + multi-scale model is under training, and it will be synchronized and open-sourced on HF afterwards.