Views
No views yet

| Control Mode | Description | Current Model Validity |
|---|---|---|
| 0 | canny | 🟢high |
| 1 | tile | 🟢high |
| 2 | depth | 🟢high |
| 3 | blur | 🟢high |
| 4 | pose | 🟢high |
| 5 | gray | 🔴low |
| 6 | lq | 🟢high |
1import torch
2from diffusers.utils import load_image
3from diffusers import FluxControlNetPipeline, FluxControlNetModel
4
5base_model = 'black-forest-labs/FLUX.1-dev'
6controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Union'
7
8controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
9pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
10pipe.to("cuda")
11
12control_image_canny = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/canny.jpg")
13controlnet_conditioning_scale = 0.5
14control_mode = 0
15
16width, height = control_image.size
17
18prompt = 'A bohemian-style female travel blogger with sun-kissed skin and messy beach waves.'
19
20image = pipe(
21 prompt,
22 control_image=control_image,
23 control_mode=control_mode,
24 width=width,
25 height=height,
26 controlnet_conditioning_scale=controlnet_conditioning_scale,
27 num_inference_steps=24,
28 guidance_scale=3.5,
29).images[0]
30image.save("image.jpg")1import torch
2from diffusers.utils import load_image
3from diffusers import FluxControlNetPipeline, FluxControlNetModel, FluxMultiControlNetModel
4
5base_model = 'black-forest-labs/FLUX.1-dev'
6controlnet_model_union = 'InstantX/FLUX.1-dev-Controlnet-Union'
7
8controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
9controlnet = FluxMultiControlNetModel([controlnet_union]) # we always recommend loading via FluxMultiControlNetModel
10
11pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
12pipe.to("cuda")
13
14prompt = 'A bohemian-style female travel blogger with sun-kissed skin and messy beach waves.'
15control_image_depth = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/images/depth.jpg")
16control_mode_depth = 2
17
18control_image_canny = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/images/canny.jpg")
19control_mode_canny = 0
20
21width, height = control_image.size
22
23image = pipe(
24 prompt,
25 control_image=[control_image_depth, control_image_canny],
26 control_mode=[control_mode_depth, control_mode_canny],
27 width=width,
28 height=height,
29 controlnet_conditioning_scale=[0.2, 0.4],
30 num_inference_steps=24,
31 guidance_scale=3.5,
32 generator=torch.manual_seed(42),
33).images[0]
34