Code Monkey home page Code Monkey logo

sd-webui-segment-anything's Introduction

Segment Anything for Stable Diffusion WebUI

This extension aim for helping stable diffusion webui users to use segment anything to do stable diffusion inpainting.

News

  • 2023/04/12: [Feature] Mask expansion enabled. Thanks @jordan-barrett-jm for your great contribution!
  • 2023/04/12: [Feature] Experimental GroundingDINO support released in GroundingDINO branch. The current implementation is VERY unstable. I recommend waiting until it is merged into master branch to use it.

Plan

Thanks for suggestions from GitHub Issues, reddit and bilibili to make this extension better.

  • Support mask expansion
  • Support text->detection->segmentation from Grounded Segment Anything and merge to master branch
  • Support API as mentioned in #15
  • Support WebUI older commits (e.g. a9fed7c364061ae6efb37f797b6b522cb3cf7aa2)
  • Connect to ControlNet
  • Batch process to support LoRA/LyCORIS training

Update your WebUI version

If you are unable to add dot, observe list index out of range error on your terminal, or any other error, the most probable reason is that your WebUI is outdated (such as you are using this commitment: a9fed7c364061ae6efb37f797b6b522cb3cf7aa2).

In most cases, updating your WebUI can solve your problem. Before you submit your issue and before I release support for some old version of WebUI, I ask that you firstly check your version of your WebUI.

How to use

Step 1:

Download this extension to ${sd-webui}/extensions use whatever way you like (git clone or install from UI)

Step 2:

Download segment-anything model from here to ${sd-webui-segment-anything}/models/sam. Do not change model name, otherwise this extension may fail due to a bug inside segment anything.

To give you a reference, vit_h is 2.56GB, vit_l is 1.25GB, vit_b is 375MB. I myself tested vit_h on NVIDIA 3090 Ti which is good. If you encounter VRAM problem, you should switch to smaller models.

Step 3:

  • Launch webui and switch to img2img mode.
  • Upload your image and add prompts on the image (MUST). Left click for positive prompt (black dot), right click for negative prompt (red dot), left click any dot again to cancel the prompt. If you forgot to add prompts, there will be exceptions on your terminal.
  • Click Preview Segmentation button
  • Choose your favorite segmentation and check Copy to Inpaint Upload
  • Optionally check Expand Mask and specify the amount, then click Update Mask
  • Switch to Inpaint upload. There is no need to upload another image or mask, just leave them blank. Write your prompt, configurate and click Generate.

Demo

demo.mp4

Contribute

Disclaimer: I have not thoroughly tested this extension, so there might be bugs. Bear with me while I'm fixing them :)

If you encounter a bug, please submit a issue. Please at least provide your WebUI version, your extension version, your browser version, errors on your browser console log if there is any, error on your terminal log if there is any, to make sure that I can find a solution faster.

I welcome any contribution. Please submit a pull request if you want to contribute

sd-webui-segment-anything's People

Contributors

continue-revolution avatar jordan-barrett-jm avatar missionfloyd avatar sxy9699 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.