Views
No views yet
torch.float8_e4m3fn![]() |
![]() |
![]() |
![]() |
![]() |
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_fp8 = 'ABDALLALSWAITI/FLUX.1-dev-ControlNet-Union-Pro-2.0-fp8'
7
8# Load using FP8 data type
9controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union_fp8, torch_dtype=torch.float8_e4m3fn)
10pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
11pipe.to("cuda")
12
13# replace with other conds
14control_image = load_image("./conds/canny.png")
15width, height = control_image.size
16
17prompt = "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."
18
19image = pipe(
20 prompt,
21 control_image=control_image,
22 width=width,
23 height=height,
24 controlnet_conditioning_scale=0.7,
25 control_guidance_end=0.8,
26 num_inference_steps=30,
27 guidance_scale=3.5,
28 generator=torch.Generator(device="cuda").manual_seed(42),
29).images[0]1import torch
2from diffusers.utils import load_image
3
4# use local files for this moment
5from pipeline_flux_controlnet import FluxControlNetPipeline
6from controlnet_flux import FluxControlNetModel
7
8base_model = 'black-forest-labs/FLUX.1-dev'
9controlnet_model_union_fp8 = 'ABDALLALSWAITI/FLUX.1-dev-ControlNet-Union-Pro-2.0-fp8'
10
11# Load using FP8 data type
12controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union_fp8, torch_dtype=torch.float8_e4m3fn)
13pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=[controlnet], torch_dtype=torch.bfloat16) # use [] to enable multi-CNs
14pipe.to("cuda")
15
16# replace with other conds
17control_image = load_image("./conds/canny.png")
18width, height = control_image.size
19
20prompt = "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."
21
22image = pipe(
23 prompt,
24 control_image=[control_image, control_image], # try with different conds such as canny&depth, pose&depth
25 width=width,
26 height=height,
27 controlnet_conditioning_scale=[0.35, 0.35],
28 control_guidance_end=[0.8, 0.8],
29 num_inference_steps=30,
30 guidance_scale=3.5,
31 generator=torch.Generator(device="cuda").manual_seed(42),
32).images[0]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_fp8 = 'ABDALLALSWAITI/FLUX.1-dev-ControlNet-Union-Pro-2.0-fp8'
7
8# Load using FP8 data type
9controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union_fp8, torch_dtype=torch.float8_e4m3fn)
10pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
11pipe.to("cuda")
12
13# The rest of the code is the same as with the original modelfp8_inference_example.py for a complete example.