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
--model flag. There are four models available: U2Net, U2NetP, U2Net Cloth Segmentation, and U2Net Human Segmentation.
$ 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