rembg icon indicating copy to clipboard operation
rembg copied to clipboard

How to set alpha matting from python code?

Open Vishnu-C opened this issue 3 years ago • 1 comments

Hello,

The alpha matting parameter is great but I need them to be used from python code to integrate with my existing app.

Thanks!

Vishnu-C avatar Nov 03 '22 03:11 Vishnu-C

You can call the remove function in your script with the parameters according to the one in the rembg/bg.py file. Example: output = remove(input,False,240,10,20,None,False,False)

`def remove(

data: Union[bytes, PILImage, np.ndarray],
alpha_matting: bool = False,
alpha_matting_foreground_threshold: int = 240,
alpha_matting_background_threshold: int = 10,
alpha_matting_erode_size: int = 10,
session: Optional[BaseSession] = None,
only_mask: bool = False,
post_process_mask: bool = False,

)`

echtme avatar Nov 04 '22 06:11 echtme