Last Updated on March 6, 2023
Human segmentation model
By default the software uses the U2Net model. But it’s also possible to use alternative models with the -m
or --model
flag. There are four models available: U2Net, U2NetP, U2Net Cloth Segmentation, and U2Net Human Segmentation.
For example:
$ rembg i -m u2net_human_seg human-input.png human-output.png
U2Net and U2NetP have the same network architecture but differ in the number of input and output FeatureMaps. Essentially U2NetP is a lightweight version. The Cloth Segmentation offers a pre-trained model for cloths parsing from human portrait.
We want to remove the background from this image.
Using the default U2Net model, we issue the command:
$ rembg i people-3104635_960_720.jpg people-u2net.jpg
As you can see the results with U2Net are far from perfect.
Let’s rerun Rembg but this time use the model for human segmentation (u2net_human_seg).
$ rembg i -m u2net_human_seg people-3104635_960_720.jpg people-u2net-human-seg.jpg
Pages in this article:
Page 1 – Introduction / Getting Started
Page 2 – In Operation
Page 3 – Human segmentation model
Page 4 – Summary