sd-webui-replacer
sd-webui-replacer copied to clipboard
A tab for sd-webui for replacing objects in pictures or videos using detection prompt
Replacer
Note: AnimateDiff temporary requites this patch, untill it will be merged https://github.com/continue-revolution/sd-webui-animatediff/pull/499
Replacer is an extension for AUTOMATIC1111/stable-diffusion-webui. The goal of this extension is to automate objects masking by detection prompt, using sd-webui-segment-anything, and img2img inpainting in one easy to use tab. It also useful for batch inpaint, and inpaint in video with stable diffusion, animatediff and controlnet
You also can draw your mask instead of or in addition to detection, and take advantage of convenient HiresFix option, and ControlNet inpainting with preserving original image resolution and aspect ratio
If you find this project useful, please star it on GitHub!
Installation
- Install sd-webui-segment-anything extension. If it bothers you, you can hide it in the Replacer's settings. Go to tab
Extension
->Avaliable
-> clickLoad from
and search "sd-webui-segment-anything" - Download model sam_hq_vit_l.pth, or others from the list bellow, and put it into
extensions/sd-webui-segment-anything/models/sam
- For faster hires fix, download lcm-lora-sdv1-5, rename it into
lcm-lora-sdv1-5.safetensors
, put intomodels/Lora
. Or if you have already lcm lora, then change hires suffix in the extension options - Install this extension. Go to tab
Extension
->Available
-> clickLoad from
and search "Replacer". Be sure your sd-webui version is >= 1.5.0. For AMD and Intel GPUs, and maby something else, you need to enable CPU for detection in Replacer's settings. Go toSettings
->Replacer
and enable it - Reload UI
SAM models list:
SAM-HQ are the best for me. Choose it depending on your vram. Sum this model size with dino model size (694MB-938MB)
FastSAM and Matting-Anything aren't currently supported
Supported extensons:
How does it work?
First, grounding dino models detect objects you provided in the detection prompt. Then segment anything model generates contours of them. And then extension chooses randomly 1 of 3 generated masks, and inpaints it with regular inpainting method in a1111 webui
When you press the "Apply hires fix" button, the extension regenerates the image with exactly the same settings, excluding upscaler_for_img2img. Then it applies inpainting with "Original" masked content mode and lower denoising but higher resolution.
Docs:
- Usage of Replacer
- Video: AnimateDiff and Frame by frame
- Replacer Options
- Information about Replacer API
- Useful tips: how to change defaults, maximal value of sliders, and how to get inpainting model
Need to do:
- ☑️ cache mask
- ☑️ batch processing
- ☑️ "apply hires fix" button
- ☑️ additional options
- ☑️ progress bar + interrupt
- ☑️ option for pass into hires fix automatically
- ☑️ control net
- ☑️ pass previous frame into ControlNet for video
- tiled vae
- ☑️ "hide segment anything extention" option
- ☑️ txt2img script
- more video input types
- allow multiply instances
small todo:
- add hires fix args into metadata