Update README.md
#8
by
latentCall145
- opened
README.md
CHANGED
@@ -19,7 +19,40 @@ For more information, please read our [blog post](https://blackforestlabs.ai/ann
|
|
19 |
3. Released under the `apache-2.0` licence, the model can be used for personal, scientific, and commercial purposes.
|
20 |
|
21 |
# Usage
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
Developers and creatives looking to build on top of `FLUX.1 [schnell]` are encouraged to use this as a starting point.
|
24 |
|
25 |
## API Endpoints
|
|
|
19 |
3. Released under the `apache-2.0` licence, the model can be used for personal, scientific, and commercial purposes.
|
20 |
|
21 |
# Usage
|
22 |
+
```python
|
23 |
+
from diffusers import FluxPipeline
|
24 |
+
import torch
|
25 |
+
|
26 |
+
ckpt_id = "black-forest-labs/FLUX.1-schnell"
|
27 |
+
prompt = 'black forest gateau cake spelling out the words "FLUX SCHNELL", tasty, food photography, dynamic shot'
|
28 |
+
height, width = 1024, 1024
|
29 |
+
|
30 |
+
pipe = FluxPipeline.from_pretrained(
|
31 |
+
ckpt_id,
|
32 |
+
revision="refs/pr/1",
|
33 |
+
torch_dtype=torch.bfloat16,
|
34 |
+
)
|
35 |
+
pipe.enable_model_cpu_offload() # uses ~24 GB vram
|
36 |
+
# if you don't have >24GB vram, comment the line above and uncomment the lines below; see https://huggingface.co/docs/diffusers/v0.29.2/en/optimization/memory
|
37 |
+
#pipe.enable_sequential_cpu_offload()
|
38 |
+
#pipe.vae.enable_tiling()
|
39 |
+
#pipe.vae.enable_slicing()
|
40 |
+
|
41 |
+
images = pipe(
|
42 |
+
prompt,
|
43 |
+
num_inference_steps=1,
|
44 |
+
guidance_scale=0.0,
|
45 |
+
height=height,
|
46 |
+
width=width,
|
47 |
+
).images
|
48 |
+
|
49 |
+
import matplotlib.pyplot as plt
|
50 |
+
for image in images:
|
51 |
+
plt.imshow(image)
|
52 |
+
plt.show()
|
53 |
+
```
|
54 |
+
|
55 |
+
We also provide a reference implementation of `FLUX.1 [schnell]`, as well as sampling code, in a dedicated [github repository](https://github.com/black-forest-labs/flux).
|
56 |
Developers and creatives looking to build on top of `FLUX.1 [schnell]` are encouraged to use this as a starting point.
|
57 |
|
58 |
## API Endpoints
|