Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: flux-1-dev-non-commercial-license
|
| 4 |
+
license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md
|
| 5 |
+
tags:
|
| 6 |
+
- Text-to-Image
|
| 7 |
+
- ControlNet
|
| 8 |
+
- Diffusers
|
| 9 |
+
- Stable Diffusion
|
| 10 |
+
base_model: black-forest-labs/FLUX.1-dev
|
| 11 |
+
---
|
| 12 |
+
# FLUX.1-dev Controlnet
|
| 13 |
+
|
| 14 |
+
Diffusers version:
|
| 15 |
+
until the next Diffusers pypi release, please install Diffusers from source and use [this PR](xxxxxx) to be able to use.
|
| 16 |
+
TODO: change when new version.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
<img src="./images/image_demo.jpg" width = "800" />
|
| 21 |
+
<img src="./images/image_demo_weight.png" width = "800" />
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# Demo
|
| 27 |
+
```python
|
| 28 |
+
import torch
|
| 29 |
+
from diffusers.utils import load_image
|
| 30 |
+
from diffusers.pipelines.flux.pipeline_flux_controlnet import FluxControlNetPipeline
|
| 31 |
+
from diffusers.models.controlnet_flux import FluxControlNetModel
|
| 32 |
+
|
| 33 |
+
# load
|
| 34 |
+
base_model = 'black-forest-labs/FLUX.1-dev'
|
| 35 |
+
controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Union-alpha '
|
| 36 |
+
controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
|
| 37 |
+
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
|
| 38 |
+
pipe.to("cuda")
|
| 39 |
+
|
| 40 |
+
# image cfg
|
| 41 |
+
width, height = 1024, 1024
|
| 42 |
+
controlnet_conditioning_scale = 0.6
|
| 43 |
+
seed = 2024
|
| 44 |
+
|
| 45 |
+
# canny
|
| 46 |
+
control_image = load_image("https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Union-alpha/resolve/main/canny.jpg")
|
| 47 |
+
prompt = "A girl in city, 25 years old, cool, futuristic."
|
| 48 |
+
control_mode = 0
|
| 49 |
+
image = pipe(
|
| 50 |
+
prompt,
|
| 51 |
+
control_image=control_image,
|
| 52 |
+
control_mode=control_mode,
|
| 53 |
+
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 54 |
+
num_inference_steps=28,
|
| 55 |
+
guidance_scale=3.5,
|
| 56 |
+
).images[0]
|
| 57 |
+
image.save("image.jpg")
|
| 58 |
+
```
|