Inpaint Anything performs stable diffusion inpainting on a browser UI using masks from Segment Anything.
APACHE-2.0 License
Inpaint Anything performs stable diffusion inpainting on a browser UI using any mask selected from the output of Segment Anything.
Using Segment Anything enables users to specify masks by simply pointing to the desired areas, instead of manually filling them in. This can increase the efficiency and accuracy of the mask creation process, leading to potentially higher-quality inpainting results while saving time and effort.
Extension version for AUTOMATIC1111's Web UI
Please follow these steps to install the software:
conda create -n inpaint python=3.10
conda activate inpaint
git clone https://github.com/Uminosachi/inpaint-anything.git
cd inpaint-anything
pip install -r requirements.txt
pip install -r requirements_mac.txt
python iasam_app.py
--save-seg
: Save the segmentation image generated by SAM.--offline
: Execute inpainting using an offline network.--sam-cpu
: Perform the Segment Anything operation on CPU.Download model
button, located next to the Segment Anything Model ID. This includes the SAM 2, Segment Anything in High Quality Model ID, Fast Segment Anything, and Faster Segment Anything (MobileSAM).
models
directory of this application's repository.Padding options
, configuring the scale and balance, and then clicking on the Run Padding
button.Anime Style
checkbox enhances segmentation mask detection, particularly in anime style images, at the expense of a slight reduction in mask quality.Run Segment Anything
button.S
key for Fullscreen mode, or the R
key to Reset zoom.Create mask
button. The mask will appear in the selected mask image area.Expand mask region
button: Use this to slightly expand the area of the mask for broader coverage.Trim mask by sketch
button: Clicking this will exclude the sketched area from the mask.Add mask by sketch
button: Clicking this will add the sketched area to the mask.Run Inpainting
button (Please note that it may take some time to download the model for the first time).
Mask area Only
option, modifications will be confined to the designated mask area only.inpaint
(case-insensitive) in its repo_id, will also be added to the Inpainting Model ID dropdown list.
python
from diffusers import StableDiffusionInpaintPipeline
pipe = StableDiffusionInpaintPipeline.from_pretrained("Uminosachi/dreamshaper_5-inpainting")
exit()
/home/username/.cache/huggingface/hub
for Linux and MacOS users, or at C:\Users\username\.cache\huggingface\hub
for Windows users.
An error occurred while trying to fetch model name...
Run Cleaner
button (Please note that it may take some time to download the model for the first time).Get mask as alpha of image
button: Save the mask as RGBA image, with the mask put into the alpha channel of the input image.Get mask
button: Save the mask as RGB image.outputs
directory.With the Inpaint Anything library, you can perform segmentation and create masks using sketches from other applications.
The source code is licensed under the Apache 2.0 license.