Views
No views yet
black-forest-labs/FLUX.1-Canny-devblack-forest-labs/FLUX.1-Canny-dev using our custom DFloat11 format. The outputs of this compressed model are bit-for-bit identical to the original BFloat16 model, while reducing GPU memory consumption by approximately 30%.1pip install -U dfloat11[cuda12]
2# or if you have CUDA version 11:
3# pip install -U dfloat11[cuda11]pip install -U diffusers controlnet_aux1import torch
2from controlnet_aux import CannyDetector
3from diffusers import FluxControlPipeline
4from diffusers.utils import load_image
5from dfloat11 import DFloat11Model
6
7pipe = FluxControlPipeline.from_pretrained("black-forest-labs/FLUX.1-Canny-dev", torch_dtype=torch.bfloat16)
8pipe.enable_model_cpu_offload()
9
10DFloat11Model.from_pretrained('DFloat11/FLUX.1-Canny-dev-DF11', device='cpu', bfloat16_model=pipe.transformer)
11
12prompt = "A robot made of exotic candies and chocolates of different kinds. The background is filled with confetti and celebratory gifts."
13control_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/robot.png")
14
15processor = CannyDetector()
16control_image = processor(control_image, low_threshold=50, high_threshold=200, detect_resolution=1024, image_resolution=1024)
17
18image = pipe(
19 prompt=prompt,
20 control_image=control_image,
21 height=1024,
22 width=1024,
23 num_inference_steps=50,
24 guidance_scale=30.0,
25).images[0]
26image.save("output.png")