Update README.md
Browse files
README.md
CHANGED
|
@@ -11,23 +11,18 @@ base_model: black-forest-labs/FLUX.1-dev
|
|
| 11 |
---
|
| 12 |
|
| 13 |
|
| 14 |
-
# FLUX.1-dev
|
| 15 |
-
|
| 16 |
-
|
| 17 |
|
| 18 |
<img src="./images/image_union.png" width = "1000" />
|
| 19 |
|
| 20 |
|
| 21 |
## Release
|
| 22 |
|
| 23 |
-
- [2024/08/
|
| 24 |
-
Until the next Diffusers pypi release,
|
| 25 |
-
please install Diffusers from source and use [this PR](https://github.com/huggingface/diffusers/pull/9175) to be able to use.
|
| 26 |
-
Before merging into the official main branch of diffusers, you can use this [diffusers_flux](https://github.com/instantX-research/diffusers_flux).
|
| 27 |
-
|
| 28 |
-
- [2024/08/14] Release the alpha version.
|
| 29 |
|
|
|
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
|
|
@@ -56,63 +51,27 @@ However, as training progresses, the performance of the Union model will continu
|
|
| 56 |
|6|lq|🟢high|
|
| 57 |
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
# Demo
|
| 62 |
```python
|
| 63 |
import torch
|
| 64 |
from diffusers.utils import load_image
|
| 65 |
-
from diffusers
|
| 66 |
-
from diffusers.models.controlnet_flux import FluxControlNetModel
|
| 67 |
|
| 68 |
-
# load
|
| 69 |
base_model = 'black-forest-labs/FLUX.1-dev'
|
| 70 |
controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Union'
|
|
|
|
| 71 |
controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
|
| 72 |
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
|
| 73 |
pipe.to("cuda")
|
| 74 |
|
| 75 |
-
|
| 76 |
-
width, height = 1024, 1024
|
| 77 |
controlnet_conditioning_scale = 0.5
|
| 78 |
-
seed = 6666
|
| 79 |
-
|
| 80 |
-
# canny
|
| 81 |
-
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/canny.jpg")
|
| 82 |
-
prompt = "A girl in city, 25 years old, cool, futuristic."
|
| 83 |
control_mode = 0
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
prompt =
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
# depth
|
| 91 |
-
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/depth.jpg")
|
| 92 |
-
prompt = "A girl in city, 25 years old, cool, futuristic."
|
| 93 |
-
control_mode = 2
|
| 94 |
-
|
| 95 |
-
# blur
|
| 96 |
-
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/blur.jpg")
|
| 97 |
-
prompt = "A girl, 25 years old."
|
| 98 |
-
control_mode = 3
|
| 99 |
-
|
| 100 |
-
# pose
|
| 101 |
-
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/pose.jpg")
|
| 102 |
-
prompt = "A girl in city, 25 years old, cool, futuristic."
|
| 103 |
-
control_mode = 4
|
| 104 |
-
|
| 105 |
-
# gray
|
| 106 |
-
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/gray.jpg")
|
| 107 |
-
prompt = "A girl, 25 years old."
|
| 108 |
-
control_mode = 5
|
| 109 |
-
|
| 110 |
-
# low quality
|
| 111 |
-
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/lq.jpg")
|
| 112 |
-
prompt = "A girl in city"
|
| 113 |
-
control_mode = 6
|
| 114 |
-
|
| 115 |
-
# go go go
|
| 116 |
image = pipe(
|
| 117 |
prompt,
|
| 118 |
control_image=control_image,
|
|
@@ -120,15 +79,55 @@ image = pipe(
|
|
| 120 |
width=width,
|
| 121 |
height=height,
|
| 122 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 123 |
-
num_inference_steps=
|
| 124 |
guidance_scale=3.5,
|
| 125 |
-
generator=torch.manual_seed(seed),
|
| 126 |
).images[0]
|
| 127 |
image.save("image.jpg")
|
| 128 |
```
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
|
|
|
|
| 133 |
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
|
| 14 |
+
# FLUX.1-dev-Controlnet-Union
|
|
|
|
|
|
|
| 15 |
|
| 16 |
<img src="./images/image_union.png" width = "1000" />
|
| 17 |
|
| 18 |
|
| 19 |
## Release
|
| 20 |
|
| 21 |
+
- [2024/08/26] 🔥 Release [FLUX.1-dev-ControlNet-Union-Pro](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro). Please install from [the source](https://github.com/huggingface/diffusers) before the next release. We have supported CN-Union and Multi-ControlNets via [this PR](https://github.com/huggingface/diffusers/pull/9175).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
- [2024/08/20] Release the beta version.
|
| 24 |
|
| 25 |
+
- [2024/08/14] Release the alpha version.
|
| 26 |
|
| 27 |
|
| 28 |
|
|
|
|
| 51 |
|6|lq|🟢high|
|
| 52 |
|
| 53 |
|
| 54 |
+
# Inference
|
|
|
|
|
|
|
| 55 |
```python
|
| 56 |
import torch
|
| 57 |
from diffusers.utils import load_image
|
| 58 |
+
from diffusers import FluxControlNetPipeline, FluxControlNetModel
|
|
|
|
| 59 |
|
|
|
|
| 60 |
base_model = 'black-forest-labs/FLUX.1-dev'
|
| 61 |
controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Union'
|
| 62 |
+
|
| 63 |
controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
|
| 64 |
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
|
| 65 |
pipe.to("cuda")
|
| 66 |
|
| 67 |
+
control_image_canny = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/images/canny.jpg")
|
|
|
|
| 68 |
controlnet_conditioning_scale = 0.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
control_mode = 0
|
| 70 |
|
| 71 |
+
width, height = control_image.size
|
| 72 |
+
|
| 73 |
+
prompt = 'A bohemian-style female travel blogger with sun-kissed skin and messy beach waves.'
|
| 74 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
image = pipe(
|
| 76 |
prompt,
|
| 77 |
control_image=control_image,
|
|
|
|
| 79 |
width=width,
|
| 80 |
height=height,
|
| 81 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 82 |
+
num_inference_steps=24,
|
| 83 |
guidance_scale=3.5,
|
|
|
|
| 84 |
).images[0]
|
| 85 |
image.save("image.jpg")
|
| 86 |
```
|
| 87 |
|
| 88 |
+
# Multi-Controls Inference
|
| 89 |
+
```python
|
| 90 |
+
import torch
|
| 91 |
+
from diffusers.utils import load_image
|
| 92 |
+
from diffusers import FluxControlNetPipeline, FluxControlNetModel, FluxMultiControlNetModel
|
| 93 |
|
| 94 |
+
base_model = 'black-forest-labs/FLUX.1-dev'
|
| 95 |
+
controlnet_model_union = './InstantX/FLUX.1-dev-Controlnet-Union'
|
| 96 |
|
| 97 |
+
controlnet_union = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
|
| 98 |
+
controlnet = FluxMultiControlNetModel([controlnet_union]) # we always recommend loading via FluxMultiControlNetModel
|
| 99 |
|
| 100 |
+
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
|
| 101 |
+
pipe.to("cuda")
|
| 102 |
+
|
| 103 |
+
prompt = 'A bohemian-style female travel blogger with sun-kissed skin and messy beach waves.'
|
| 104 |
+
control_image_depth = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/images/depth.jpg")
|
| 105 |
+
control_mode_depth = 2
|
| 106 |
+
|
| 107 |
+
control_image_canny = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union/resolve/main/images/canny.jpg")
|
| 108 |
+
control_mode_canny = 0
|
| 109 |
+
|
| 110 |
+
width, height = control_image.size
|
| 111 |
+
|
| 112 |
+
image = pipe(
|
| 113 |
+
prompt,
|
| 114 |
+
control_image=[control_image_depth, control_image_canny],
|
| 115 |
+
control_mode=[control_mode_depth, control_mode_canny],
|
| 116 |
+
width=width,
|
| 117 |
+
height=height,
|
| 118 |
+
controlnet_conditioning_scale=[0.2, 0.4],
|
| 119 |
+
num_inference_steps=24,
|
| 120 |
+
guidance_scale=3.5,
|
| 121 |
+
generator=torch.manual_seed(42),
|
| 122 |
+
).images[0]
|
| 123 |
+
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
# Resources
|
| 127 |
+
- [InstantX/FLUX.1-dev-Controlnet-Canny](https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Canny)
|
| 128 |
+
- [InstantX/FLUX.1-dev-Controlnet-Union](https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union)
|
| 129 |
+
- [Shakker-Labs/FLUX.1-dev-ControlNet-Depth](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Depth)
|
| 130 |
+
- [Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro)
|
| 131 |
+
|
| 132 |
+
# Acknowledgements
|
| 133 |
+
Thanks [zzzzzero](https://github.com/zzzzzero) for help us pointing out some bugs in the training.
|