This extension is for AUTOMATIC1111's Stable Diffusion web UI, it allows to add a BiRefNet section to the original Stable Diffusion WebUI's Extras tab to benefit from BiRefNet background removal feature.
Find the UI for BiRefNet background removal in the Extras tab after installing the extension.
The available models are:
Model files go here (automatically downloaded if the folder is not present during first run): stable-diffusion-webui/models/birefnet
.
If necessary, they can be downloaded from:
model.safetensors
must be renamed General.safetensors
model.safetensors
must be renamed General-Lite.safetensors
model.safetensors
must be renamed Portrait.safetensors
model.safetensors
must be renamed DIS.safetensors
model.safetensors
must be renamed HRSOD.safetensors
model.safetensors
must be renamed COD.safetensors
model.safetensors
must be renamed DIS-TR_TEs.safetensors
Routes have been added to the Automatic1111's SD WebUI API:
/birefnet/single
: remove background of a single image./birefnet/multi
: remove background of a multiple images.Both endpoints share these parameters:
return_foreground
: whether to return foreground image (input image without its background).return_mask
: whether to return mask (can be used for inpainting).return_edge_mask
: whether to return edge mask (can be used to blend foreground image with another background).edge_mask_width
: edge mask width in pixels. Default to 64.model_name
: General
, General-Lite
, Portrait
, DIS
, HRSOD
, COD
or DIS-TR_TEs
. BiRefNet model to be used. Default to General
.output_dir
: directory to save output images.output_extension
: output image file extension (without leading dot, png
by default).device_id
: GPU device id.send_output
: true
if you want output images to be sent as base64 encoded strings, false
otherwise.save_output
: true
if you want output images to be saved in output_dir
, false
otherwise.use_model_cache
: true
if you want BiRefNet model to be cached for subsequent calls using same model name, false
otherwise.flag_force_cpu
: force cpu inference.Additional parameters for the /birefnet/single
endpoint are:
image
: source image. It can either be a path to an existing file or an url or a base64 encoded string.resolution
: source image resolution. Keep it empty to automatically detect source image size.Additional parameters for the /birefnet/multi
endpoint are:
inputs
: an array of objects with the following arguments:
image
: source image. It can either be a path to an existing file or an url or a base64 encoded string.resolution
: source image resolution. Keep it empty to automatically detect source image size.Original author's link: https://github.com/ZhengPeng7/BiRefNet