openai / glide-text2im

GLIDE: a diffusion-based text-conditional image synthesis model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Created non-rectangular masks for inpainting

jdivis opened this issue · comments

In the paper, I see masks that are non-rectangular (white blob in the sky in the image below):

image

but I think the 'mask' in the inpaint notebook is being applied on this line:

source_mask_64[:, :, 20:] = 0

which produces an image with a gray rectangle. Is there an example of how to create more complex masks?

commented

The code is here.

# The mask should always be a boolean 64x64 mask, and then we
# can upsample it for the second stage.
source_mask_64 = th.ones_like(source_image_64)[:, :1]
source_mask_64[:, :, 20:] = 0
source_mask_256 = F.interpolate(source_mask_64, (256, 256), mode='nearest')

Basically, you can set whichever pixels you want to 0.
Try to replace the first two : and set the values of your choice to 0 for row and column.

Got it, and to set other pixels to 0, we can just add more arrays, like:

source_mask_64[:,:,0:22,0:3] = 0
source_mask_64[:,:,0:18,3:7] = 0
source_mask_64[:,:,0:15,7:8] = 0
source_mask_64[:,:,0:13,8:10] = 0

to make whatever pattern we need. I was trying to figure out how that would be done with the one line, manipulating the values of:
source_mask_64[:,:,0:22,0:3] = 0
But I see now that it should be a multilined approach.
Thanks!

commented

Good job! I see I was wrong when I said the first two :. It is actually the following ones, as you did.