From 4dd67c6c2c280a575b0755a0715446001ee6713b Mon Sep 17 00:00:00 2001 From: tiyn Date: Tue, 18 Aug 2026 09:41:21 +0200 Subject: [PATCH] Added rembg --- wiki/rembg.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 wiki/rembg.md diff --git a/wiki/rembg.md b/wiki/rembg.md new file mode 100644 index 0000000..1979fc5 --- /dev/null +++ b/wiki/rembg.md @@ -0,0 +1,45 @@ +# rembg + +[rembg](https://github.com/danielgatis/rembg) is a [command line](/wiki/linux/shell.md) tool and +Python library for removing image backgrounds using pretrained +[neural networks](/wiki/neural_network.md) executed through ONNX Runtime. + +## Setup + +rembg can be installed from source as described on the +[official GitHub repository](https://github.com/danielgatis/rembg). + +Alternatively a [Python package manager](/wiki/programming_language/python.md#package-management) +can be used to install rembg. +For the backend one must select CPU or GPU usage. +For command line usage an extra package has to be installed in addition to the inference backend. +Depending on that choice the name of the package will be `"rembg[cpu,cli]"` or `rembg[gpu,cli]`. + +## Usage + +This section addresses the usage of rembg. + +### Remove Background + +The following command removes the background from an image using a specific ``. +In this case `` is a placeholder for the input image path and `` for the output image +path. + +```sh +rembg i -m +``` + +Depending on the use-case other models may also be used. +`u2net` is a general purpose model and most of the time a good default. +`u2net_human_seg` is optimized for human subjects. +`isnet-general-use` is an alternative general-purpose model. + +The quality depends on the selected model and the input image. +For portraits with complex backgrounds such as bushes or trees, `u2net` often produces the best +overall results, while other models may perform better on different types of images. + +Additionally, alpha matting can improve difficult edges such as hair. + +```sh +rembg i -m -a +```