ChuuniZ commited on
Commit
ea97343
·
verified ·
1 Parent(s): e0a5075

Upload controlnet/FLUX.1/FLUX.1-dev-ControlNet-Union-Pro-2.0/README.md

Browse files
controlnet/FLUX.1/FLUX.1-dev-ControlNet-Union-Pro-2.0/README.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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). We provide an [online demo](https://huggingface.co/spaces/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0). A FP8 quantized version provided by community can be found in [ABDALLALSWAITI/FLUX.1-dev-ControlNet-Union-Pro-2.0-fp8](https://huggingface.co/ABDALLALSWAITI/FLUX.1-dev-ControlNet-Union-Pro-2.0-fp8).
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, has smaller model size.
28
+ - Improve on canny and pose, better control and aesthetics.
29
+ - Add support for soft edge. Remove support for tile.
30
+
31
+ # Model Cards
32
+ - This ControlNet consists of 6 double blocks and 0 single block. Mode embedding is removed.
33
+ - 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.
34
+ - This model supports multiple control modes, including canny, soft edge, depth, pose, gray. You can use it just as a normal ControlNet.
35
+ - This model can be jointly used with other ControlNets.
36
+
37
+ # Showcases
38
+
39
+ <table>
40
+ <tr>
41
+ <td><img src="./images/canny.png" alt="canny" style="height:100%"></td>
42
+ </tr>
43
+ <tr>
44
+ <td><img src="./images/softedge.png" alt="softedge" style="height:100%"></td>
45
+ </tr>
46
+ <tr>
47
+ <td><img src="./images/pose.png" alt="pose" style="height:100%"></td>
48
+ </tr>
49
+ <tr>
50
+ <td><img src="./images/depth.png" alt="depth" style="height:100%"></td>
51
+ </tr>
52
+ <tr>
53
+ <td><img src="./images/gray.png" alt="gray" style="height:100%"></td>
54
+ </tr>
55
+ </table>
56
+
57
+ # Inference
58
+ ```python
59
+ import torch
60
+ from diffusers.utils import load_image
61
+ from diffusers import FluxControlNetPipeline, FluxControlNetModel
62
+
63
+ base_model = 'black-forest-labs/FLUX.1-dev'
64
+ controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
65
+
66
+ controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
67
+ pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
68
+ pipe.to("cuda")
69
+
70
+ # replace with other conds
71
+ control_image = load_image("./conds/canny.png")
72
+ width, height = control_image.size
73
+
74
+ prompt = "A young girl stands gracefully at the edge of a serene beach, her long, flowing hair gently tousled by the sea breeze. She wears a soft, pastel-colored dress that complements the tranquil blues and greens of the coastal scenery. The golden hues of the setting sun cast a warm glow on her face, highlighting her serene expression. The background features a vast, azure ocean with gentle waves lapping at the shore, surrounded by distant cliffs and a clear, cloudless sky. The composition emphasizes the girl's serene presence amidst the natural beauty, with a balanced blend of warm and cool tones."
75
+
76
+ image = pipe(
77
+ prompt,
78
+ control_image=control_image,
79
+ width=width,
80
+ height=height,
81
+ controlnet_conditioning_scale=0.7,
82
+ control_guidance_end=0.8,
83
+ num_inference_steps=30,
84
+ guidance_scale=3.5,
85
+ generator=torch.Generator(device="cuda").manual_seed(42),
86
+ ).images[0]
87
+ ```
88
+
89
+ # Multi-Inference
90
+ ```python
91
+ import torch
92
+ from diffusers.utils import load_image
93
+
94
+ # https://github.com/huggingface/diffusers/pull/11350
95
+ # You can directly import from diffusers by install the laster version from source
96
+ # from diffusers import FluxControlNetPipeline, FluxControlNetModel
97
+
98
+ # use local files for this moment
99
+ from pipeline_flux_controlnet import FluxControlNetPipeline
100
+ from controlnet_flux import FluxControlNetModel
101
+
102
+ base_model = 'black-forest-labs/FLUX.1-dev'
103
+ controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
104
+
105
+ controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
106
+ pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=[controlnet], torch_dtype=torch.bfloat16) # use [] to enable multi-CNs
107
+ pipe.to("cuda")
108
+
109
+ # replace with other conds
110
+ control_image = load_image("./conds/canny.png")
111
+ width, height = control_image.size
112
+
113
+ prompt = "A young girl stands gracefully at the edge of a serene beach, her long, flowing hair gently tousled by the sea breeze. She wears a soft, pastel-colored dress that complements the tranquil blues and greens of the coastal scenery. The golden hues of the setting sun cast a warm glow on her face, highlighting her serene expression. The background features a vast, azure ocean with gentle waves lapping at the shore, surrounded by distant cliffs and a clear, cloudless sky. The composition emphasizes the girl's serene presence amidst the natural beauty, with a balanced blend of warm and cool tones."
114
+
115
+ image = pipe(
116
+ prompt,
117
+ control_image=[control_image, control_image], # try with different conds such as canny&depth, pose&depth
118
+ width=width,
119
+ height=height,
120
+ controlnet_conditioning_scale=[0.35, 0.35],
121
+ control_guidance_end=[0.8, 0.8],
122
+ num_inference_steps=30,
123
+ guidance_scale=3.5,
124
+ generator=torch.Generator(device="cuda").manual_seed(42),
125
+ ).images[0]
126
+ ```
127
+
128
+ # Recommended Parameters
129
+ You can adjust controlnet_conditioning_scale and control_guidance_end for stronger control and better detail preservation. For better stability, we highly suggest to use detailed prompt, for some cases, multi-conditions help.
130
+ - Canny: use cv2.Canny, controlnet_conditioning_scale=0.7, control_guidance_end=0.8.
131
+ - Soft Edge: use [AnylineDetector](https://github.com/huggingface/controlnet_aux), controlnet_conditioning_scale=0.7, control_guidance_end=0.8.
132
+ - Depth: use [depth-anything](https://github.com/DepthAnything/Depth-Anything-V2), controlnet_conditioning_scale=0.8, control_guidance_end=0.8.
133
+ - Pose: use [DWPose](https://github.com/IDEA-Research/DWPose/tree/onnx), controlnet_conditioning_scale=0.9, control_guidance_end=0.65.
134
+ - Gray: use cv2.cvtColor, controlnet_conditioning_scale=0.9, control_guidance_end=0.8.
135
+
136
+ # Resources
137
+ - [InstantX/FLUX.1-dev-IP-Adapter](https://huggingface.co/InstantX/FLUX.1-dev-IP-Adapter)
138
+ - [InstantX/FLUX.1-dev-Controlnet-Canny](https://huggingface.co/InstantX/FLUX.1-dev-Controlnet-Canny)
139
+ - [Shakker-Labs/FLUX.1-dev-ControlNet-Depth](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Depth)
140
+ - [Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro](https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro)
141
+
142
+ # Acknowledgements
143
+ 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.
144
+
145
+ # Citation
146
+ If you find this project useful in your research, please cite us via
147
+ ```
148
+ @misc{flux-cn-union-pro-2,
149
+ author = {Shakker-Labs},
150
+ title = {ControlNet-Union},
151
+ year = {2025},
152
+ howpublished={\url{https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0}},
153
+ }
154
+ ```