File size: 7,183 Bytes
f7e397c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<div style="display: flex; justify-content: center; align-items: center;">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/alibaba.png" alt="alibaba" style="width: 20%; height: auto; margin-right: 5%;">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/alimama.png" alt="alimama" style="width: 20%; height: auto;">
</div>

# FLUX.1-dev ControlNet 图像修复 - Beta版

本仓库包含了由阿里妈妈创意团队开发的[alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha](https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha)模型的改进版图像修复ControlNet权重和推理代码。

## 主要改进

与之前版本相比,我们最新的图像修复模型带来了以下改进:

1. **支持1024分辨率**: 能够直接处理和生成1024x1024分辨率的图像,无需额外的放大步骤,提供更高质量和更详细的输出结果。
2. **增强细节生成**: 经过微调以捕捉和重现修复区域的更精细细节。
3. **改进提示词控制**: 通过增强的提示词解释,对生成内容提供更精确的控制。

## 展示示例

以下图像是使用ComfyUI工作流生成的([点击此处下载](https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/alimama-creative-flux-inapint-cn-beta.json)),设置如下:
`control-strength` = 1.0, `control-end-percent` = 1.0, `true_cfg` = 1.0

| 图像 & 提示词输入                                    | Alpha 版本                                         | Beta 版本                                        |
|-----------------------------------------------------|----------------------------------------------------|----------------------------------------------------|

<div align = "center">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/1_0.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/1_1.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/1_2.png" width = "30%" style="display:inline-block;"/>
<br>
  提示词 : <i>'在木板上写几行"alimama creative"字样'</i>
</div>

<div align = "center">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/2_0.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/2_1.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/2_2.png" width = "30%" style="display:inline-block;"/>
<br>
  提示词 : <i>"一个女孩,有漂亮的大白翅膀"</i>
</div>

<div align = "center">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/3_0.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/3_1.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/3_2.png" width = "30%" style="display:inline-block;"/>
<br>
  提示词 : <i>"红色头发"</i>
</div>

<div align = "center">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/4_0.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/4_1.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/4_2.png" width = "30%" style="display:inline-block;"/>
<br>
  提示词 : <i>" "</i>
</div>

<div align = "center">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/5_0.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/5_1.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/5_2.png" width = "30%" style="display:inline-block;"/>
<br>
  提示词 : <i>"阿尔伯特·爱因斯坦"</i>
</div>

<div align = "center">
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/6_0.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/6_1.png" width = "30%" style="display:inline-block;" />
  <img src="https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/6_2.png" width = "30%" style="display:inline-block;"/>
<br>
  提示词 : <i>"Ravello户外沙发组合配咖啡桌"</i>
</div>

### ComfyUI使用指南:

下载示例ComfyUI工作流[点击这里](https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/alimama-creative-flux-inapint-cn-beta.json)。

- 使用`t5xxl-FP16``flux1-dev-fp8`模型进行30步推理@1024px & H20 GPU:
  - GPU内存使用: 27GB
  - 推理时间: 48秒 (true_cfg=3.5), 26秒 (true_cfg=1)

- 通过调整以下参数可以获得不同的结果:

| 参数 | 推荐范围 | 效果 |
|-----------|------------------|--------|
| control-strength | 0.6 - 1.0 | 控制ControlNet对生成的影响程度。较高的值会使生成结果更严格地遵循控制图像。 |
| controlend-percent | 0.35 - 1.0 | 决定ControlNet影响在去噪过程中的哪一步结束。较低的值在后期步骤中允许更多的创意自由。 |
| true-cfg (无分类器引导尺度) | 1.0 或 3.5 | 影响生成结果对提示词的遵循程度。较高的值会增加对提示词的遵循,但可能降低图像质量。 |

- 更全面的整图提示词可以带来更好的整体效果。例如,除了描述需要修复的区域,你还可以描述整个图像的背景、氛围和风格。这种方法可以使生成的结果更加和谐自然。

## Diffusers 推理

1. 安装所需的diffusers版本:
```shell
pip install diffusers==0.30.2
```

2. 克隆此仓库:
```shell
git clone https://github.com/alimama-creative/FLUX-Controlnet-Inpainting.git
```

3.`main.py`中配置`image_path``mask_path``prompt`,然后执行:
```shell
python main.py
```

## 模型说明

- 训练数据集: 来自LAION2B和专有来源的1500万张图像
- 最佳推理分辨率: 1024x1024

## 许可证

我们的模型权重在[FLUX.1 [dev]](https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md)非商业许可下发布。