Views
No views yet

diffusers library1import torch
2from diffusers.utils import load_image
3from diffusers import FluxControlNetModel
4from diffusers.pipelines import FluxControlNetPipeline
5
6# Load pipeline
7controlnet = FluxControlNetModel.from_pretrained(
8 "jasperai/Flux.1-dev-Controlnet-Depth",
9 torch_dtype=torch.bfloat16
10)
11pipe = FluxControlNetPipeline.from_pretrained(
12 "black-forest-labs/FLUX.1-dev",
13 controlnet=controlnet,
14 torch_dtype=torch.bfloat16
15)
16pipe.to("cuda")
17
18# Load a control image
19control_image = load_image(
20 "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Depth/resolve/main/examples/depth.jpg"
21)
22
23prompt = "a statue of a gnome in a field of purple tulips"
24
25image = pipe(
26 prompt,
27 control_image=control_image,
28 controlnet_conditioning_scale=0.6,
29 num_inference_steps=28,
30 guidance_scale=3.5,
31 height=control_image.size[1],
32 width=control_image.size[0]
33).images[0]
34image
MidasDetector from the controlnet_aux library1from controlnet_aux import MidasDetector
2from diffusers.utils import load_image
3
4midas = MidasDetector.from_pretrained("lllyasviel/Annotators")
5
6midas.to("cuda")
7
8# Load an image
9im = load_image(
10 "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Depth/resolve/main/examples/output.jpg"
11)
12
13depth = midas(im)