FLUX.1 Dev ControlNet Union Pro 2.0
模型简介
该模型是一个用于文本生成图像任务的ControlNet,支持canny、soft edge、depth、pose、gray等多种控制模式,可与FLUX.1-dev基础模型配合使用生成高质量图像。
模型特点
多控制模式支持
支持canny、soft edge、depth、pose、gray等多种控制模式
改进的控制效果
相比前代版本,改进了canny和pose的控制效果和美学表现
体积优化
移除了模式嵌入,模型体积更小
多重控制支持
可与其他ControlNet联合使用,实现多重条件控制
模型能力
文本生成图像
图像条件控制
多条件联合控制
使用案例
创意设计
人像生成
根据姿势图生成高质量人像
生成符合姿势要求且具有美学价值的人像
场景生成
根据深度图生成3D场景
生成符合深度关系的逼真场景
艺术创作
艺术风格转换
根据边缘图生成不同艺术风格的图像
保持原始结构的同时应用不同艺术风格
🚀 FLUX.1-dev-ControlNet-Union-Pro-2.0
本仓库包含由 Shakker Labs 发布的用于 FLUX.1-dev 模型的统一 ControlNet。我们提供了一个 在线演示。社区提供的 FP8 量化版本可在 ABDALLALSWAITI/FLUX.1-dev-ControlNet-Union-Pro-2.0-fp8 中找到。
✨ 主要特性
与 Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro 相比:
- 移除了模式嵌入,模型尺寸更小。
- 在 Canny 和姿态控制方面有所改进,控制效果和美学表现更佳。
- 增加了对软边缘的支持,移除了对平铺模式的支持。
📚 详细文档
模型卡片
- 此 ControlNet 由 6 个双块和 0 个单块组成,移除了模式嵌入。
- 我们使用包含 2000 万张高质量通用和人物图像的数据集,从零开始对模型进行了 30 万步的训练。训练分辨率为 512x512,使用 BFloat16 格式,批量大小为 128,学习率为 2e-5,引导系数从 [1, 7] 中均匀采样。我们将文本丢弃率设置为 0.20。
- 该模型支持多种控制模式,包括 Canny、软边缘、深度、姿态和灰度。您可以像使用普通的 ControlNet 一样使用它。
- 此模型可以与其他 ControlNet 联合使用。
展示示例
控制模式 | 示例图片 |
---|---|
Canny | ![]() |
软边缘 | ![]() |
姿态 | ![]() |
深度 | ![]() |
灰度 | ![]() |
💻 使用示例
基础用法
import torch
from diffusers.utils import load_image
from diffusers import FluxControlNetModel, FluxControlNetPipeline
base_model = 'black-forest-labs/FLUX.1-dev'
controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
pipe.to("cuda")
# 替换为其他条件图像
control_image = load_image("./conds/canny.png")
width, height = control_image.size
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."
image = pipe(
prompt,
control_image=control_image,
width=width,
height=height,
controlnet_conditioning_scale=0.7,
control_guidance_end=0.8,
num_inference_steps=30,
guidance_scale=3.5,
generator=torch.Generator(device="cuda").manual_seed(42),
).images[0]
高级用法
import torch
from diffusers.utils import load_image
# https://github.com/huggingface/diffusers/pull/11350
# 您可以通过从源代码安装最新版本直接从 diffusers 导入
# from diffusers import FluxControlNetPipeline, FluxControlNetModel
# 目前使用本地文件
from pipeline_flux_controlnet import FluxControlNetPipeline
from controlnet_flux import FluxControlNetModel
base_model = 'black-forest-labs/FLUX.1-dev'
controlnet_model_union = 'Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0'
controlnet = FluxControlNetModel.from_pretrained(controlnet_model_union, torch_dtype=torch.bfloat16)
pipe = FluxControlNetPipeline.from_pretrained(base_model, controlnet=[controlnet], torch_dtype=torch.bfloat16) # 使用列表以启用多 ControlNet
pipe.to("cuda")
# 替换为其他条件图像
control_image = load_image("./conds/canny.png")
width, height = control_image.size
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."
image = pipe(
prompt,
control_image=[control_image, control_image], # 尝试使用不同的条件,如 Canny 和深度、姿态和深度
width=width,
height=height,
controlnet_conditioning_scale=[0.35, 0.35],
control_guidance_end=[0.8, 0.8],
num_inference_steps=30,
guidance_scale=3.5,
generator=torch.Generator(device="cuda").manual_seed(42),
).images[0]
推荐参数
您可以调整 controlnet_conditioning_scale
和 control_guidance_end
以获得更强的控制效果和更好的细节保留。为了获得更好的稳定性,我们强烈建议使用详细的提示词,在某些情况下,多条件控制会有所帮助。
- Canny:使用
cv2.Canny
,controlnet_conditioning_scale = 0.7
,control_guidance_end = 0.8
。 - 软边缘:使用 AnylineDetector,
controlnet_conditioning_scale = 0.7
,control_guidance_end = 0.8
。 - 深度:使用 depth-anything,
controlnet_conditioning_scale = 0.8
,control_guidance_end = 0.8
。 - 姿态:使用 DWPose,
controlnet_conditioning_scale = 0.9
,control_guidance_end = 0.65
。 - 灰度:使用
cv2.cvtColor
,controlnet_conditioning_scale = 0.9
,control_guidance_end = 0.8
。
📄 许可证
本项目使用 flux-1-dev-non-commercial-license 许可证。
🔗 相关资源
- InstantX/FLUX.1-dev-IP-Adapter
- InstantX/FLUX.1-dev-Controlnet-Canny
- Shakker-Labs/FLUX.1-dev-ControlNet-Depth
- Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro
🙏 致谢
本模型由 Shakker Labs 开发。最初的想法受到 xinsir/controlnet-union-sdxl-1.0 的启发。保留所有权利。
📑 引用
如果您在研究中发现本项目有用,请通过以下方式引用我们:
@misc{flux-cn-union-pro-2,
author = {Shakker-Labs},
title = {ControlNet-Union},
year = {2025},
howpublished={\url{https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0}},
}
Stable Diffusion V1 5
Openrail
稳定扩散是一种潜在的文本到图像扩散模型,能够根据任何文本输入生成逼真的图像。
图像生成
S
stable-diffusion-v1-5
3.7M
518
Stable Diffusion Inpainting
Openrail
基于稳定扩散的文本到图像生成模型,具备图像修复能力
图像生成
S
stable-diffusion-v1-5
3.3M
56
Stable Diffusion Xl Base 1.0
SDXL 1.0是基于扩散的文本生成图像模型,采用专家集成的潜在扩散流程,支持高分辨率图像生成
图像生成
S
stabilityai
2.4M
6,545
Stable Diffusion V1 4
Openrail
稳定扩散是一种潜在文本到图像扩散模型,能够根据任意文本输入生成逼真图像。
图像生成
S
CompVis
1.7M
6,778
Stable Diffusion Xl Refiner 1.0
SD-XL 1.0优化器模型是Stability AI开发的图像生成模型,专为提升SDXL基础模型生成的图像质量而设计,特别擅长最终去噪步骤处理。
图像生成
S
stabilityai
1.1M
1,882
Stable Diffusion 2 1
基于扩散的文本生成图像模型,支持通过文本提示生成和修改图像
图像生成
S
stabilityai
948.75k
3,966
Stable Diffusion Xl 1.0 Inpainting 0.1
基于Stable Diffusion XL的潜在文本到图像扩散模型,具备通过遮罩进行图像修复的功能
图像生成
S
diffusers
673.14k
334
Stable Diffusion 2 Base
基于扩散的文生图模型,可根据文本提示生成高质量图像
图像生成
S
stabilityai
613.60k
349
Playground V2.5 1024px Aesthetic
其他
开源文生图模型,能生成1024x1024分辨率及多种纵横比的美学图像,在美学质量上处于开源领域领先地位。
图像生成
P
playgroundai
554.94k
723
Sd Turbo
SD-Turbo是一款高速文本生成图像模型,仅需单次网络推理即可根据文本提示生成逼真图像。该模型作为研究原型发布,旨在探索小型蒸馏文本生成图像模型。
图像生成
S
stabilityai
502.82k
380
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98