File size: 3,484 Bytes
24ffd7f
 
 
 
 
 
 
 
 
 
 
98a22c5
 
a25439d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: other
license_name: flux-1-dev-non-commercial-license
license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md
language:
- en
base_model:
- black-forest-labs/FLUX.1-dev
pipeline_tag: image-to-image
tags:
- ComfyUI
- Inpainting
library_name: diffusers
---

<div style="display: flex; justify-content: center; align-items: center;">
  <img src="images/alibaba.png" alt="alibaba" style="width: 20%; height: auto; margin-right: 5%;">
  <img src="images/alimama.png" alt="alimama" style="width: 20%; height: auto;">
</div>

# FLUX.1-dev ControlNet Inpainting - Beta

This repository hosts an improved Inpainting ControlNet checkpoint for the [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) model, developed by the AlimamaCreative Team.

## Key Enhancements

Our latest inpainting model brings significant improvements compared to the previous version:

1. **1024 Resolution Support**: Capable of directly processing and generating 1024x1024 resolution images without additional upscaling steps, providing higher quality and more detailed output results.
2. **Enhanced Detail Generation**: Fine-tuned to capture and reproduce finer details in inpainted areas.
3. **Improved Prompt Control**: Offers more precise control over generated content through enhanced prompt interpretation.

## Showcase

The following images were generated using a ComfyUI workflow with these settings (click here to download):
`control-strength` = 1.0, `control-end-percent` = 1.0, `true_cfg` = 1.0

| Image & Prompt Input | Alpha Version | Beta Version |
|:---:|:---:|:---:|
| ![Input Image](path/to/original_image.jpg) A > B | ![Alpha](path/to/old_model_result.jpg) | ![Beta](path/to/new_model_result.jpg) |

### ComfyUI Usage Guidelines:

Download example ComfyUI workflow [here](https://huggingface.co/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Alpha/resolve/main/images/alimama-flux-controlnet-inpaint.json).

- Using `t5xxl-FP16` and `flux1-dev-fp8` models for 28-step inference:
  - GPU memory usage: 27GB
  - Inference time: 27 seconds (cfg=3.5), 15 seconds (cfg=1)
- For optimal results, experiment with lower values for `control-strength`, `control-end-percent`, and `cfg

| Parameter | Recommended Range | Effect |
|-----------|------------------|--------|
| control-strength | 0.0 - 1.0 | Controls how much influence the ControlNet has on the generation. Higher values result in stronger adherence to the control image. |
| control-end-percent | 0.0 - 1.0 | Determines at which point in the denoising process the ControlNet influence ends. Lower values allow for more creative freedom in later steps. |
| cfg (Classifier-Free Guidance Scale) | 1.0 - 30.0 | Influences how closely the generation follows the prompt. Higher values increase prompt adherence but may reduce image quality. |

## Model Specifications

- Training dataset: 15M images from LAION2B and proprietary sources
- Optimal inference resolution: 1024x1024

## Diffusers Integration

1. Install the required diffusers version:
```shell
pip install diffusers==0.30.2
```

2. Clone this repository:
````shell
git clone https://github.com/alimama-creative/FLUX-Controlnet-Inpainting.git
````

3. Configure `image_path`, `mask_path`, and `prompt` in `main.py`, then execute:
````shell
python main.py
````

## License

Our model weights are released under the [FLUX.1 [dev]](https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md) Non-Commercial License.