Img2img and inpainting with Flux AI model

Published Categorized as Tutorial Tagged , , , 5 Comments on Img2img and inpainting with Flux AI model

Image-to-image allows you to generate a new image based on an existing one. Inpainting lets you regenerate a small area of the image. The Flux AI model supports both img2img and inpainting.

In this article, you will learn how to use img2img and inpainting with the Flux AI model.

Software

The best software for using img2img and inpainting with Flux AI is Forge, an interactive GUI similar to AUTOMATIC1111. As of writing, AUTOMATIC1111 does not support Flux AI models so I recommend using Forge.

See the Flux AI installation Guide on Forge if you don’t have the Flux model on Forge.

If you are new to Stable Diffusion, check out the Quick Start Guide.

Take the Stable Diffusion course if you want to build solid skills and understanding.

What you will learn

Use Forge to do image-to-image and inpainting for Flux AI. The GUI has good support for Flux.

If you are already familiar with image-to-image and inpainting for Stable Diffusion, you can stop here because their usage with the Flux AI model is almost identical. 😄

In the rest of the article, I will walk you through how to use image-to-image and inpainting with Flux AI models in Forge.

Image-to-image with Flux AI model

You can use image-to-image to generate image variations.

Step 1: Generate an image on txt2img

On the txt2img page of SD Forge WebUI:

  1. Select flux in the UI profile.
  2. Select the flux1-dev-fp8.safetensors checkpoint.
  3. Enter a prompt, e.g.

Photo of a siberian cat in russian forest, national geographic winner, photo of the year, bokeh, winter

4. Set the desired image size, e.g. 1344 x 768 (16:9).

You can leave the rest of the settings as the default.

Press Generate to generate an image.

Step 2: Send the image to img2img

Click the send to img2img button under the image to send the image to the img2img page.

Step 3: Adjust img2img setting

The most important parameter is the denoising strength. Set it high to change more. Set it low to change less.

Press Generate to generate an image variation.

Denoising strength

Below are images generated with denoising strengths from 0.5 to 0.95. As the value increases, there are more changes.

Denoising strength: 0.5
Denoising strength: 0.9
Denoising strength: 0.95

Prompt

Another common technique is to change the prompt.

Let’s turn the cat into a lion by changing the prompt.

Photo of a lion in russian forest, national geographic winner, photo of the year, bokeh, winter

You will need to experiment with the denoising strength to get the right amount of change you want. Below is setting it to 0.8.

Changing the prompt to generate a lion in img2img.

Now, you know how to generate a different subject with a similar background!

Inpainting with Flux AI model

Inpainting is similar to image-to-image, except you only change a small part of the image. You can pick which part of the image to change.

Step 1: Generate an image with txt2img

On the txt2img page of SD Forge WebUI:

  1. Select flux in the UI profile.
  2. Select the flux1-dev-fp8.safetensors checkpoint.
  3. Enter a prompt, e.g.

Photo of a siberian cat in russian forest, national geographic winner, photo of the year, bokeh, winter

4. Set the desired image size, e.g. 1344 x 768 (16:9).

You can leave the rest of the settings as the default.

Press Generate to generate an image.

Step 2: Send the image to inpainting

Click the Send to inpaint button to send the image to inpainting.

You should now on the img2img page > inpaint tab.

Step 3: Select the inpaint area

Use the brush tool to paint over the area you want to regenerate.

Below is an example of regenerating the head of the cat.

Step 4: Enter inpainting settings

Similar to img2img, you can adjust the prompt and the denoising strength.

Let’s change the cat to the lion by adjusting the prompt.

Photo of a lion in russian forest, national geographic winner, photo of the year, bokeh, winter

Set the denoising strength to 0.8. Set it higher to change more. Set it lower to change less.

Press Generate.

Now you get a lion head with the rest of the image unchanged!

Avatar

By Andrew

Andrew is an experienced engineer with a specialization in Machine Learning and Artificial Intelligence. He is passionate about programming, art, photography, and education. He has a Ph.D. in engineering.

5 comments

Leave a comment

Your email address will not be published. Required fields are marked *