rembg icon indicating copy to clipboard operation
rembg copied to clipboard

[FEATURE] Select Model

Open danielehrhardt opened this issue 3 years ago • 3 comments

Can you maybe add a new flag to select the model that should be used? And could you possibly also update the U-2 Models?

danielehrhardt avatar Aug 15 '22 07:08 danielehrhardt

Right now there's nothing explained about how to use different models, and I can't even find the .2unet directory

xdanielc avatar Aug 16 '22 11:08 xdanielc

I managed to do this by doing the following

from rembg.session_factory import new_session
from rembg import remove

# for the small model
remove(input, session=new_session("u2netp"))

I'm assuming you can just put in u2net_human_seg or u2net_cloth_seg for the other models

Shuvo-saha avatar Aug 16 '22 16:08 Shuvo-saha

I managed to do this by doing the following

from rembg.session_factory import new_session
from rembg import remove

# for the small model
remove(input, session=new_session("u2netp"))

I'm assuming you can just put in u2net_human_seg or u2net_cloth_seg for the other models

and with the cli?

danielehrhardt avatar Aug 16 '22 16:08 danielehrhardt

try this ;)

rembg i --help

danielgatis avatar Aug 17 '22 03:08 danielgatis

$ rembg i --help


Usage: rembg i [OPTIONS] INPUT OUTPUT

  for a file as input

Options:
  -m, --model [u2net|u2netp|u2net_human_seg|u2net_cloth_seg]
                                  model name  [default: u2net]
  -a, --alpha-matting             use alpha matting  [default: False]
  -af, --alpha-matting-foreground-threshold INTEGER
                                  trimap fg threshold  [default: 240]
  -ab, --alpha-matting-background-threshold INTEGER
                                  trimap bg threshold  [default: 10]
  -ae, --alpha-matting-erode-size INTEGER
                                  erode size  [default: 10]
  -om, --only-mask                output only the mask  [default: False]
  -ppm, --post-process-mask       post process the mask  [default: False]
  --help                          Show this message and exit.

jonaaix avatar Aug 22 '22 17:08 jonaaix

Were you able to change the model? I've tried -m and --model followed by the model name, but with no luck. Idk if it's a bug, but this needs to be streamlined better. And my newly added onnx files do not show up in the help menu either. I feel like they should. Anyway, if any of you know how to, it'd be great.

CHJ85 avatar Sep 01 '22 17:09 CHJ85