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

Bug in the image condition preprocessing step #59

Open
cmh1027 opened this issue May 30, 2024 · 0 comments
Open

Bug in the image condition preprocessing step #59

cmh1027 opened this issue May 30, 2024 · 0 comments

Comments

@cmh1027
Copy link

cmh1027 commented May 30, 2024

I guess that mask generation of preprocessing step in generate_pcd must be changed as follows

if w_in/h_in > 1.1 or h_in/w_in > 1.1: # if there is a large gap between height and width, do inpainting
    in_res = max(w_in, h_in)
    # image_in, mask_in = np.zeros((in_res, in_res, 3), dtype=np.uint8), 255*np.ones((in_res, in_res, 3), dtype=np.uint8)
    image_in, mask_in = np.zeros((in_res, in_res, 3), dtype=np.uint8), np.zeros((in_res, in_res, 3), dtype=np.uint8)
    image_in[int(in_res/2-h_in/2):int(in_res/2+h_in/2), int(in_res/2-w_in/2):int(in_res/2+w_in/2)] = np.array(rgb_cond)
    # mask_in[int(in_res/2-h_in/2):int(in_res/2+h_in/2), int(in_res/2-w_in/2):int(in_res/2+w_in/2)] = 0
    mask_in[int(in_res/2-h_in/2):int(in_res/2+h_in/2), int(in_res/2-w_in/2):int(in_res/2+w_in/2)] = 255
    Image.fromarray(image_in).save(f"outputs/temp/image_in.png")
    Image.fromarray(mask_in).save(f"outputs/temp/mask_in.png")
    image2 = np.array(Image.fromarray(image_in).resize((self.cam.W, self.cam.H))).astype(float) / 255.0
    mask2 = np.array(Image.fromarray(mask_in).resize((self.cam.W, self.cam.H))).astype(float) / 255.0

    image_curr = self.rgb(
        prompt=prompt,
        image=image2,
        negative_prompt=negative_prompt, generator=generator,
        mask_image=mask2,   
    )

It's because there is also mask inversion step in self.rgb function
mask_pil = Image.fromarray(np.round((1 - mask_image) * 255.).astype(np.uint8))

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

1 participant