Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
library_name: diffusers
|
| 9 |
+
pipeline_tag: text-to-image
|
| 10 |
+
|
| 11 |
+
tags:
|
| 12 |
+
- Text-to-Image
|
| 13 |
+
- ControlNet
|
| 14 |
+
- Diffusers
|
| 15 |
+
- Flux.1-dev
|
| 16 |
+
- image-generation
|
| 17 |
+
- Stable Diffusion
|
| 18 |
+
base_model: black-forest-labs/FLUX.1-dev
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# FLUX.1-dev-ControlNet-Union-Pro-2.0
|
| 22 |
+
|
| 23 |
+
This repository contains an unified ControlNet for FLUX.1-dev model released by [Shakker Labs](https://huggingface.co/Shakker-Labs).
|
| 24 |
+
|
| 25 |
+
# Keynotes
|
| 26 |
+
In comparison with [Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro),
|
| 27 |
+
- Remove mode embedding. Smaller model size (6.6GB -> 4.0GB).
|
| 28 |
+
- Improve on canny and pose, better control and aesthetics.
|
| 29 |
+
- Add support for soft edge. Remove support for tile.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
# Model Cards
|
| 33 |
+
- This ControlNet consists of 6 double blocks and 0 single block as the same as [Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro). Mode embedding is removed.
|
| 34 |
+
- We train the model from scratch for 300k steps using a dataset of 20M high-quality general and human images. We train at 512x512 resolution in BFloat16, batch size = 128, learning rate = 2e-5, the guidance is uniformly sampled from [1, 7]. We set the text drop ratio to 0.20.
|
| 35 |
+
- This model supports multiple control modes, including canny, soft edge, depth, pose, gray.
|
| 36 |
+
- This model can be jointly used with other ControlNets.
|
| 37 |
+
|
| 38 |
+
# Inference
|
| 39 |
+
```python
|
| 40 |
+
import torch
|
| 41 |
+
from diffusers.utils import load_image
|
| 42 |
+
from diffusers import FluxControlNetPipeline, FluxControlNetModel
|
| 43 |
+
|
| 44 |
+
base_model = 'black-forest-labs/FLUX.1-dev'
|
| 45 |
+
controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
|
| 46 |
+
|
| 47 |
+
controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
|
| 48 |
+
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
|
| 49 |
+
pipe.to("cuda")
|
| 50 |
+
|
| 51 |
+
width, height = control_image_depth.size
|
| 52 |
+
|
| 53 |
+
image = pipe(
|
| 54 |
+
prompt,
|
| 55 |
+
control_image=control_image,
|
| 56 |
+
width=width,
|
| 57 |
+
height=height,
|
| 58 |
+
controlnet_conditioning_scale=0.7,
|
| 59 |
+
control_guidance_end=0.8,
|
| 60 |
+
num_inference_steps=24,
|
| 61 |
+
guidance_scale=3.5,
|
| 62 |
+
generator=torch.manual_seed(42),
|
| 63 |
+
).images[0]
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
# Recommended Parameters
|
| 67 |
+
You can adjust controlnet_conditioning_scale and control_guidance_end for stronger control and better detail preservation.
|
| 68 |
+
- Canny: use cv2.Canny, controlnet_conditioning_scale=0.7, control_guidance_end=0.8.
|
| 69 |
+
- Soft Edge: use [AnylineDetector](https://github.com/huggingface/controlnet_aux), controlnet_conditioning_scale=0.7, control_guidance_end=0.8.
|
| 70 |
+
- Depth: use [depth-anything](https://github.com/DepthAnything/Depth-Anything-V2), controlnet_conditioning_scale=0.8, control_guidance_end=0.8.
|
| 71 |
+
- Pose: use [DWPose](https://github.com/IDEA-Research/DWPose/tree/onnx), controlnet_conditioning_scale=0.9, control_guidance_end=0.65.
|
| 72 |
+
- Gray: use cv2.cvtColor, controlnet_conditioning_scale=0.9, control_guidance_end=0.8.
|
| 73 |
+
|
| 74 |
+
# Resources
|
| 75 |
+
- [InstantX/FLUX.1-dev-IP-Adapter](https://huggingface.co/InstantX/FLUX.1-dev-IP-Adapter)
|
| 76 |
+
- [InstantX/FLUX.1-dev-Controlnet-Canny](https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Canny)
|
| 77 |
+
- [Shakker-Labs/FLUX.1-dev-ControlNet-Depth](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Depth)
|
| 78 |
+
- [Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro)
|
| 79 |
+
|
| 80 |
+
# Acknowledgements
|
| 81 |
+
This model is developed by [Shakker Labs](https://huggingface.co/Shakker-Labs). The original idea is inspired by [xinsir/controlnet-union-sdxl-1.0](https://huggingface.co/xinsir/controlnet-union-sdxl-1.0). All copyright reserved.
|