How to Use the Stable Diffusion WebUI Extension for Segment Anything Inpainting

Adair Lee
2 min readApr 13, 2023

--

Segment Anything for Stable Diffusion WebUI

Video

https://user-images.githubusercontent.com/63914308/230916163-af661008-5a50-496e-8b79-8be7f193f9e9.mp4

Repository

https://github.com/continue-revolution/sd-webui-segment-anything

Introduction

Stable Diffusion WebUI is a powerful tool for content creators and artists who want to perform image inpainting tasks. With the addition of the Segment Anything extension, users can easily integrate segmentation and inpainting, streamlining their workflow. This tutorial will guide you through the process of installing and using the extension with the Stable Diffusion WebUI.

Requirements

  • Stable Diffusion WebUI installed
  • Segment Anything extension
  • Segment Anything model (vit_h, vit_l, or vit_b, depending on your hardware)

Step-by-Step Guide

  1. Install the Segment Anything extension

Download the extension and place it in the ${sd-webui}/extensions folder. You can use git clone or install it directly from the WebUI.

  1. Download the Segment Anything model

Choose the appropriate model size (vit_h, vit_l, or vit_b) based on your hardware capabilities. Download the model from the provided link and place it in the ${sd-webui}/models/sam folder. Do not change the model name, as it may cause the extension to fail.

  1. Launch WebUI and configure settings

Launch the Stable Diffusion WebUI and switch to the “img2img” mode. Upload the image you want to work with and add prompts directly onto the image. To add positive prompts, use a left click (black dot); for negative prompts, use a right click (red dot). To remove a prompt, left-click on the dot again.

  1. Preview segmentation

Click the “Preview Segmentation” button to generate a segmented version of your image. Choose your preferred segmentation and check the “Copy to Inpaint Upload” option.

  1. Update mask settings (optional)

If you want to expand the mask, check the “Expand Mask” option and specify the desired amount. Then click the “Update Mask” button.

  1. Perform inpainting

Switch to the “Inpaint upload” tab. There’s no need to upload another image or mask — just leave them blank. Enter your prompt, configure the settings, and click the “Generate” button to start the inpainting process.

Conclusion

By following these simple steps, you can easily use the Segment Anything extension with the Stable Diffusion WebUI for efficient image inpainting tasks. Remember to update your WebUI regularly to ensure compatibility and smooth performance. Happy inpainting!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Adair Lee
Adair Lee

Written by Adair Lee

Experienced full-stack developer proficient in C#, Python, and web development, with 20+ years of Google SEO expertise and successful entrepreneurship.

No responses yet

Write a response