This image is generated by AI

When you generate an image with Flux, you may not be satisfied with some parts of the image. For example, you may not be satisfied with the hair of the person in the image. You may try to modify the Prompt by adding red hair, and then regenerate the image. However, using this method, the hair of the person’s head becomes red, and other parts of the image may also change.

Or you may want to change the hair of a person in a person image to red, but you don’t want other parts of the image to change. Like this:

How can you use Flux to modify an image without affecting other parts? This requires using Flux’s image modification feature.

1. Download Flux Fill Model

We need to use the Flux fill model. You need to go to here to download the Flux fill dev model, and put it in the /models/diffusion_models/ directory.

2. Flux Inpainting Workflow

First, let’s talk about how to modify only a specific area without affecting other parts.

After downloading the model, you can connect the nodes according to the following screenshot. If you don’t want to manually connect, you can download this workflow template and import it into your local ComfyUI. (Additionally, if you don’t know how to download a Comflowy template, you can refer to this tutorial)

The workflow is very similar to the Stable Diffusion Inpainting workflow. Both convert images to Conditioning, and then input the Prompt and image together into the KSampler node.

Just load the basic Flux workflow, then select the Flux fill model in the Load Diffusion Model node (①), and replace the EmptySD3LatentImage node with the InpaintModelConditioning node (②), then connect it to the Load Image node (③).

Then you need to input the image you want to modify into the Load Image node. Then right-click and select Open in MaskEditor (①), and use it in the MaskEditor.

At this point, you can click the Brush button (②) on the left, then use the brush to paint on the image, the area you paint is the area you want to modify (④), if you think the painted area is too small, you can also modify it on the right (③). At the same time, there is an eraser tool on the left, which can erase the area you painted. After completing the painting, click the top Save button (⑤) to save your modifications.

After completing the painting, you only need to modify the Prompt. For example, in this case, set the Prompt to a girl with red hair. Then click the Generate button to generate the image.

3. Flux Outpainting Workflow

Flux Fill model can not only modify a part of the image, but also expand a part of the image. Like this:

You can build an Outpainting workflow by adjusting the Inpainting workflow. If you don’t want to manually connect, you can download this workflow template and import it into your local ComfyUI. (Additionally, if you don’t know how to download a Comflowy template, you can refer to this tutorial)

First, you need to add a Pad Image for Outpainting node (①), then connect it to the Load Image and InpaintModelConditioning nodes. Then you need to set the area you want to expand in the Pad Image for Outpainting node. For example, I want to expand the right side of the image by 104 pixels and the bottom side by 504 pixels. If you want to expand the top and left sides, you also need to set the Top and Left values. After setting, load the image you want to expand in the ②. Then remember to input the Prompt, my Prompt is An orange-haired girl with a bikini on top and jeans on bottom. Blue sky background. Then click the Generate button to generate the image.

After my testing, I personally feel that Flux Fill is not as good as inpainting in the outpainting scenario. So you may need to generate it a few times to get a satisfactory image.

4. Flux Fill API Workflow

If your computer performance is not sufficient to run the Flux Fill model, you can also try using Comflowy’s Fill API node in ComfyUI. Of course, you can also directly use the Flux Fill API node in Comflowy, with a simple connection method that requires just one node, and it also supports Flux Pro and Dev versions.

Note that since this node uses an API, you will need to pay the corresponding fees when using it.