Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDiscussion about gated convolution and its input #423
Labels
Comments
|
@tbuikr Thanks for your details information.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello all, I create the thread to discuss about the gated convolution and its input. Many questions in the repo. have been asked for the problem #405, #252.
First of all, the input of gated convolution are: uncompleted image
imgand itsmask. In which, the mask defined asHowever, the official code has some confusing, that is the reason why many questions has been asked. In the code,
generative_inpainting/inpaint_ops.py
Line 137 in cfc1d41
generative_inpainting/inpaint_ops.py
Line 140 in cfc1d41
From these lines, we can see that the mask defined as pixels
0for outside the box and1for inside the box. Hence, the paper has a typo, it should beSo, the above lines answered the question #405, #252
Secondly, the incompleted image
xdefined asgenerative_inpainting/inpaint_model.py
Line 151 in 7b1d72e
It shows that the incompleted input is obtained by multiply the original image and (1-mask). It means we want to keep the original pixels of the image outside of the mask and set to zero pixels inside of the mask
Now, we will concatenate the incompleted input
xandmaskto obtainBxHxWx(channel_x + channel+mask). For example, the channel of x is 3 (RGB) and the channel of the mask is 1 (binary image). We have the input for gated convolution isBxHxWx4. Now, we will feed it to the gated convolution.generative_inpainting/inpaint_ops.py
Line 46 in 7b1d72e
We can see that the concatenation of incompleted input and mask (defined as
x) will go to a conv2d. The output then splits into two components:xis for convolution result of incompletedx, andyis for convolution result of mask. Thenygoes to the sigmoid function to normalize it to [0,1] and multiply withactivation(x)to perform gating.Thanks for reading, please correct if I was wrong!