timudk sayakpaul HF Staff commited on
Commit
423eab2
·
verified ·
1 Parent(s): d5857a7

Update README.md to include diffusers usage (#2)

Browse files

- Update README.md (1575baf9f76dcf30b2138584f60023bbb3a5b65a)


Co-authored-by: Sayak Paul <[email protected]>

Files changed (1) hide show
  1. README.md +41 -0
README.md CHANGED
@@ -32,6 +32,47 @@ Developers and creatives looking to build on top of `FLUX.1 Canny [dev]` are enc
32
  ## API Endpoints
33
  `FLUX.1 Canny [pro]` is available in our API [bfl.ml](https://docs.bfl.ml/)
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ---
36
 
37
  # Limitations
 
32
  ## API Endpoints
33
  `FLUX.1 Canny [pro]` is available in our API [bfl.ml](https://docs.bfl.ml/)
34
 
35
+ ## Diffusers
36
+
37
+ To use FLUX.1-Depth-dev-lora with the 🧨 diffusers python library, first install or upgrade `diffusers`, `peft`, and `controlnet_aux`.
38
+
39
+ ```bash
40
+ pip install -U git+https://github.com/huggingface/diffusers
41
+ pip install -U controlnet-aux
42
+ pip install -U peft
43
+ ```
44
+
45
+ Then you can use the `FluxControlPipeline` to run it:
46
+
47
+ ```py
48
+ import torch
49
+ from controlnet_aux import CannyDetector
50
+ from diffusers import FluxControlPipeline
51
+ from diffusers.utils import load_image
52
+
53
+ pipe = FluxControlPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to("cuda")
54
+ pipe.load_lora_weights("black-forest-labs/FLUX.1-Canny-dev-lora", adapter_name="canny")
55
+ pipe.set_adapters("canny", 0.85)
56
+
57
+ prompt = "A robot made of exotic candies and chocolates of different kinds. The background is filled with confetti and celebratory gifts."
58
+ control_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/robot.png")
59
+
60
+ processor = CannyDetector()
61
+ control_image = processor(control_image, low_threshold=50, high_threshold=200, detect_resolution=1024, image_resolution=1024)
62
+
63
+ image = pipe(
64
+ prompt=prompt,
65
+ control_image=control_image,
66
+ height=1024,
67
+ width=1024,
68
+ num_inference_steps=50,
69
+ guidance_scale=30.0,
70
+ ).images[0]
71
+ image.save("output.png")
72
+ ```
73
+
74
+ To learn more, check out the [diffusers documentation](https://huggingface.co/docs/diffusers/main/en/api/pipelines/flux).
75
+
76
  ---
77
 
78
  # Limitations