Update README.md
#11
by
hlky
HF staff
- opened
README.md
CHANGED
@@ -36,9 +36,10 @@ Also, some generation results with input images are provided in "Files and versi
|
|
36 |
|
37 |
# Inference
|
38 |
|
39 |
-
To try our models, you have
|
40 |
1. Use main.py from our [official repo](https://github.com/XLabs-AI/x-flux)
|
41 |
2. Use our custom nodes for ComfyUI and test it with provided workflows (check out folder /workflows)
|
|
|
42 |
|
43 |
## Instruction for ComfyUI
|
44 |
1. Go to ComfyUI/custom_nodes
|
@@ -50,6 +51,50 @@ To try our models, you have 2 options:
|
|
50 |
7. Use `Flux Load IPAdapter` and `Apply Flux IPAdapter` nodes, choose right CLIP model and enjoy your genereations.
|
51 |
8. You can find example workflow in folder workflows in this repo.
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
If you get bad results, try to set to play with ip strength
|
54 |
### Limitations
|
55 |
The IP Adapter is currently in beta.
|
|
|
36 |
|
37 |
# Inference
|
38 |
|
39 |
+
To try our models, you have 3 options:
|
40 |
1. Use main.py from our [official repo](https://github.com/XLabs-AI/x-flux)
|
41 |
2. Use our custom nodes for ComfyUI and test it with provided workflows (check out folder /workflows)
|
42 |
+
3. Diffusers 🧨
|
43 |
|
44 |
## Instruction for ComfyUI
|
45 |
1. Go to ComfyUI/custom_nodes
|
|
|
51 |
7. Use `Flux Load IPAdapter` and `Apply Flux IPAdapter` nodes, choose right CLIP model and enjoy your genereations.
|
52 |
8. You can find example workflow in folder workflows in this repo.
|
53 |
|
54 |
+
## Diffusers 🧨
|
55 |
+
1. Install Diffusers 🧨 `pip install -U diffusers`
|
56 |
+
2. Run the example
|
57 |
+
```python
|
58 |
+
import torch
|
59 |
+
from diffusers import FluxPipeline
|
60 |
+
from diffusers.utils import load_image
|
61 |
+
|
62 |
+
pipe: FluxPipeline = FluxPipeline.from_pretrained(
|
63 |
+
"black-forest-labs/FLUX.1-dev",
|
64 |
+
torch_dtype=torch.bfloat16,
|
65 |
+
).to("cuda")
|
66 |
+
|
67 |
+
image = load_image("monalisa.jpg").resize((1024, 1024))
|
68 |
+
|
69 |
+
pipe.load_ip_adapter(
|
70 |
+
"XLabs-AI/flux-ip-adapter-v2",
|
71 |
+
weight_name="ip_adapter.safetensors",
|
72 |
+
image_encoder_pretrained_model_name_or_path="openai/clip-vit-large-patch14"
|
73 |
+
)
|
74 |
+
|
75 |
+
def LinearStrengthModel(start, finish, size):
|
76 |
+
return [
|
77 |
+
(start + (finish - start) * (i / (size - 1))) for i in range(size)
|
78 |
+
]
|
79 |
+
|
80 |
+
ip_strengths = LinearStrengthModel(0.4, 1.0, 19)
|
81 |
+
pipe.set_ip_adapter_scale(ip_strengths)
|
82 |
+
|
83 |
+
image = pipe(
|
84 |
+
width=1024,
|
85 |
+
height=1024,
|
86 |
+
prompt='wearing red sunglasses, golden chain and a green cap',
|
87 |
+
negative_prompt="",
|
88 |
+
true_cfg_scale=1.0,
|
89 |
+
generator=torch.Generator().manual_seed(0),
|
90 |
+
ip_adapter_image=image,
|
91 |
+
).images[0]
|
92 |
+
|
93 |
+
image.save('result.jpg')
|
94 |
+
```
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
If you get bad results, try to set to play with ip strength
|
99 |
### Limitations
|
100 |
The IP Adapter is currently in beta.
|