Views
No views yet
![]() |
![]() |
![]() |
![]() |
![]() |
1import torch
2from diffusers.utils import load_image
3from diffusers import FluxControlNetPipeline, FluxControlNetModel
4
5base_model = 'black-forest-labs/FLUX.1-dev'
6controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
7
8controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
9pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
10pipe.to("cuda")
11
12# replace with other conds
13control_image = load_image("./conds/canny.png")
14width, height = control_image.size
15
16prompt = "A young girl stands gracefully at the edge of a serene beach, her long, flowing hair gently tousled by the sea breeze. She wears a soft, pastel-colored dress that complements the tranquil blues and greens of the coastal scenery. The golden hues of the setting sun cast a warm glow on her face, highlighting her serene expression. The background features a vast, azure ocean with gentle waves lapping at the shore, surrounded by distant cliffs and a clear, cloudless sky. The composition emphasizes the girl's serene presence amidst the natural beauty, with a balanced blend of warm and cool tones."
17
18image = pipe(
19 prompt,
20 control_image=control_image,
21 width=width,
22 height=height,
23 controlnet_conditioning_scale=0.7,
24 control_guidance_end=0.8,
25 num_inference_steps=30,
26 guidance_scale=3.5,
27 generator=torch.Generator(device="cuda").manual_seed(42),
28).images[0]1import torch
2from diffusers.utils import load_image
3
4# https://github.com/huggingface/diffusers/pull/11350
5# You can directly import from diffusers by install the laster version from source
6# from diffusers import FluxControlNetPipeline, FluxControlNetModel
7
8# use local files for this moment
9from pipeline_flux_controlnet import FluxControlNetPipeline
10from controlnet_flux import FluxControlNetModel
11
12base_model = 'black-forest-labs/FLUX.1-dev'
13controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
14
15controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
16pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=[controlnet], torch_dtype=torch.bfloat16) # use [] to enable multi-CNs
17pipe.to("cuda")
18
19# replace with other conds
20control_image = load_image("./conds/canny.png")
21width, height = control_image.size
22
23prompt = "A young girl stands gracefully at the edge of a serene beach, her long, flowing hair gently tousled by the sea breeze. She wears a soft, pastel-colored dress that complements the tranquil blues and greens of the coastal scenery. The golden hues of the setting sun cast a warm glow on her face, highlighting her serene expression. The background features a vast, azure ocean with gentle waves lapping at the shore, surrounded by distant cliffs and a clear, cloudless sky. The composition emphasizes the girl's serene presence amidst the natural beauty, with a balanced blend of warm and cool tones."
24
25image = pipe(
26 prompt,
27 control_image=[control_image, control_image], # try with different conds such as canny&depth, pose&depth
28 width=width,
29 height=height,
30 controlnet_conditioning_scale=[0.35, 0.35],
31 control_guidance_end=[0.8, 0.8],
32 num_inference_steps=30,
33 guidance_scale=3.5,
34 generator=torch.Generator(device="cuda").manual_seed(42),
35).images[0]@misc{flux-cn-union-pro-2,
author = {Shakker-Labs},
title = {ControlNet-Union},
year = {2025},
howpublished={\url{https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0}},
}