Skip to content

Commit

Permalink
update type usage for command-line tool & update ReadMe
Browse files Browse the repository at this point in the history
  • Loading branch information
plemeri committed May 24, 2023
1 parent 61b0a01 commit c27e1f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Image | Video | Webcam
:-:|:-:|:-:
<img src=https://raw.githubusercontent.com/plemeri/transparent-background/main/figures/demo_aeroplane.gif height=200px> | <img src=https://raw.githubusercontent.com/plemeri/transparent-background/main/figures/demo_b5.gif height=200px> | <img src=https://raw.githubusercontent.com/plemeri/transparent-background/main/figures/demo_webcam.gif height=200px>

## :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)
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions transparent_background/Remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c27e1f3

Please sign in to comment.