Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About the number of input channels #4

Closed
leijue222 opened this issue Mar 31, 2020 · 4 comments
Closed

About the number of input channels #4

leijue222 opened this issue Mar 31, 2020 · 4 comments

Comments

@leijue222
Copy link

leijue222 commented Mar 31, 2020

In paper 3.1 :

First, we increase the number of input channels from 3 to 9 to allow for
the extra trimap. We encode the trimap using Gaussian blurs of the definite
foreground and background masks at three different scales (in a similar way
to the method of [19] in interactive segmentation). This encoding differs from
existing approaches in deep image matting, as they usually encode the trimap as
a single channel with value 1 if foreground, 0.5 for unknown and 0 for background.

I know the output channels is 7 (a=1, F=3, B=3)
But why the input channels is 9?
In you code,I saw the input are image and trimap,then input channels will be 4.
So,why the input channels is 9 in paper 3.1?

@xymsh
Copy link

xymsh commented Mar 31, 2020

I think the input channel is 3 (rgb) + 6 (blurred trimap) = 9.

In code dataloader.py, the author defined a function called read_trimap. This function first reads the single-channel trimap, then transforms the pure foreground and pure background area into one-hot version. At this time, 1 channel trimap -> 2 channel one-hot trimap (indicating fg and bg area).

After that, trimap_transform function in transforms.py is used to blur the fg and bg at 3 scale levels separately. Thus, 2 channel trimap -> 6 channel trimap (3 for fg, and 3 for bg).

In the end, we can get 6 channel trimap + 3 channel RGB.

@leijue222
Copy link
Author

I got it.
Thanks!

@kartikwar
Copy link

I think the input channel is 3 (rgb) + 6 (blurred trimap) = 9.

In code dataloader.py, the author defined a function called read_trimap. This function first reads the single-channel trimap, then transforms the pure foreground and pure background area into one-hot version. At this time, 1 channel trimap -> 2 channel one-hot trimap (indicating fg and bg area).

After that, trimap_transform function in transforms.py is used to blur the fg and bg at 3 scale levels separately. Thus, 2 channel trimap -> 6 channel trimap (3 for fg, and 3 for bg).

In the end, we can get 6 channel trimap + 3 channel RGB.

how is the one hot encoding done in the code ?

are you referring to these lines ?

# trimap[trimap_im == 1, 1] = 1
# trimap[trimap_im == 0, 0] = 1

@kartikwar
Copy link

if yes wouldn't this binarize the trimap? Ideally trimap should be continous b/w 0 and 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants