U²-Net Cloth Segmentation (u2net_cloth_seg) clothing segmentation#
U²-Net trained to parse clothing on people into upper body, lower body and full body masks.
Run it: rembg i -m u2net_cloth_seg input.jpg output.png setup
How to run u2net_cloth_seg
u2net_cloth_seg ships with rembg as the session u2net_cloth_seg. The weights download on first use.
Command line
pip install "rembg[cpu,cli]"
rembg i -m u2net_cloth_seg input.jpg output.pngPython
from rembg import new_session, remove
from PIL import Image
session = new_session("u2net_cloth_seg") # load once, reuse for every image
output = remove(Image.open("input.jpg"), session=session)
output.save("output.png")Other sessions: all rembg models.
Quick take
- Best for: Cutting garments off a model photo, e.g. for fashion catalogs
- Avoid when: You want the whole subject cut out: use u2net_human_seg or birefnet-portrait
- Notes: Not a background remover, so it is not on Bench v0. rembg returns the cutouts stacked vertically; pass `cc` (`-x '{"cc": "upper"}'`) to pick one class.
When a hosted model is worth it
u2net_cloth_seg is free and runs on your machine; keep it if the results above are good enough. If you need finer hair and edges, or don't want to run large models locally, rembg also ships the withoutBG Pro Model as the withoutbg session, ranked #1 of 17 by accuracy on Bench v0. Images are sent to withoutBG's servers.
Same command, hosted model
export WITHOUTBG_API_KEY=sk_...
rembg i -m withoutbg input.jpg output.pngSign up for 50 free credits (no credit card) or See its results.