Views
No views yet




diffusers from the source, as the PR has not been included in currently released version yet.1import torch
2from diffusers.utils import load_image
3
4from diffusers import FluxControlNetPipeline, FluxControlNetModel
5from diffusers.models import FluxMultiControlNetModel
6
7base_model = 'black-forest-labs/FLUX.1-dev'
8controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro'
9
10controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
11controlnet = FluxMultiControlNetModel([controlnet_union]) # we always recommend loading via FluxMultiControlNetModel
12
13pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
14pipe.to("cuda")
15
16prompt = 'A bohemian-style female travel blogger with sun-kissed skin and messy beach waves.'
17control_image_depth = load_image("https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro/resolve/main/assets/depth.jpg")
18control_mode_depth = 2
19
20control_image_canny = load_image("https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro/resolve/main/assets/canny.jpg")
21control_mode_canny = 0
22
23width, height = control_image_depth.size
24
25image = pipe(
26 prompt,
27 control_image=[control_image_depth, control_image_canny],
28 control_mode=[control_mode_depth, control_mode_canny],
29 width=width,
30 height=height,
31 controlnet_conditioning_scale=[0.2, 0.4],
32 num_inference_steps=24,
33 guidance_scale=3.5,
34 generator=torch.manual_seed(42),
35).images[0]1from diffusers import FluxControlNetModel
2from diffusers.models import FluxMultiControlNetModel
3
4controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro'
5controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
6
7controlnet_model_depth = 'Shakker-Labs/FLUX.1-dev-Controlnet-Depth'
8controlnet_depth = FluxControlNetModel.from_pretrained(controlnet_model_depth, torch_dtype=torch.bfloat16)
9
10controlnet = FluxMultiControlNetModel([controlnet_union, controlnet_depth])
11
12# set mode to None for other ControlNets
13control_mode=[2, None]