From c27e1f3dd30ffe3da6404ab4aad1e4b507008e67 Mon Sep 17 00:00:00 2001 From: Taehun Kim Date: Wed, 24 May 2023 16:33:53 +0900 Subject: [PATCH] update type usage for command-line tool & update ReadMe --- README.md | 8 ++++++++ setup.py | 2 +- transparent_background/Remover.py | 3 +++ usage.py | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f90f726..4bc1daf 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Image | Video | Webcam :-:|:-:|:-: | | +## :newspaper: News + +Our package is currently not working properly on small images without `--fast` argument. Sorry for the inconvenience and we'll fix this issue with better algorithm coming out shortly. + ## :inbox_tray: Installation ### Dependencies (python packages) @@ -93,6 +97,8 @@ $ transparent-background --source [SOURCE] --dest [DEST] --type [TYPE] --ckpt [C * `rgba` will generate RGBA output regarding saliency score as an alpha map. Note that this will not work for video and webcam input. * `map` will output saliency map only. * `green` will change the background with green screen. + * `white` will change the background with white color. -> [2023.05.24] Contributed by [carpedm20](https://github.com/carpedm20) + * `'[255, 0, 0]'` will change the background with color code [255, 0, 0]. Please use with single quotes. -> [2023.05.24] Contributed by [carpedm20](https://github.com/carpedm20) * `blur` will blur the background. * `overlay` will cover the salient object with translucent green color, and highlight the edges. * Another image file (e.g., `samples/backgroud.png`) will be used as a background, and the object will be overlapped on it. @@ -119,6 +125,8 @@ out = remover.process(img) # default setting - transparent background out = remover.process(img, type='rgba') # same as above out = remover.process(img, type='map') # object map only out = remover.process(img, type='green') # image matting - green screen +out = remover.process(img, type='white') # change backround with white color -> [2023.05.24] Contributed by carpedm20 +out = remover.process(img, type=[255, 0, 0]) # change background with color code [255, 0, 0] -> [2023.05.24] Contributed by carpedm20 out = remover.process(img, type='blur') # blur background out = remover.process(img, type='overlay') # overlay object map onto the image out = remover.process(img, type='samples/background.jpg') # use another image as a background diff --git a/setup.py b/setup.py index dffa89a..9067765 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="transparent-background", - version="1.2.3", + version="1.2.4", author="Taehun Kim", author_email="taehoon1018@postech.ac.kr", description="Make images with transparent background", diff --git a/transparent_background/Remover.py b/transparent_background/Remover.py index 6a92484..f4f1cc0 100644 --- a/transparent_background/Remover.py +++ b/transparent_background/Remover.py @@ -116,6 +116,9 @@ def process(self, img, type='rgba'): pred = pred.numpy().squeeze() img = np.array(img) + + if type.startswith('['): + type = [int(i) for i in type[1:-1].split(',')] if type == 'map': img = (np.stack([pred] * 3, axis=-1) * 255).astype(np.uint8) diff --git a/usage.py b/usage.py index 7a71af5..b4355d9 100644 --- a/usage.py +++ b/usage.py @@ -14,6 +14,8 @@ out = remover.process(img, type='rgba') # same as above out = remover.process(img, type='map') # object map only out = remover.process(img, type='green') # image matting - green screen +out = remover.process(img, type='white') # change backround with white color +out = remover.process(img, type=[255, 0, 0]) # change background with color code [255, 0, 0] out = remover.process(img, type='blur') # blur background out = remover.process(img, type='overlay') # overlay object map onto the image out = remover.process(img, type='samples/background.jpg') # use another image as a background