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

How to set up original image and mask for generation in controlnet's inpainting? #84

Open
panghea opened this issue Jun 11, 2023 · 1 comment

Comments

@panghea
Copy link

panghea commented Jun 11, 2023

The following is the code I'm using, where "a.png" is the original image and "b.png" is the image where I've applied a black mask over a white filled area. However, the generated result only outputs the masked image.


from PIL import Image
import webuiapi
api = webuiapi.WebUIApi()
PROMPT="""
masterpiece, best quality, 1girl, face, simple white background
""".strip()
NEGATIVE_PROMPT="""
easynegative
""".strip()
controlnet_units = []
controlnet_image0 = Image.open("a.png") # PIL Image
controlnet_image0mask = Image.open("b.png") # PIL Image

controlnet_unit0 = webuiapi.ControlNetUnit(
    input_image = controlnet_image0,
    module = "inpain_only",
    mask=controlnet_image0mask,
    pixel_perfect=True,
    model = "control_v11p_sd15_inpaint_fp16 [be8bc0ed]",
)
controlnet_units.append(controlnet_unit0)
result1 = api.txt2img(
        prompt=PROMPT, negative_prompt=NEGATIVE_PROMPT, controlnet_units=controlnet_units,
            width=512,
            height=832,)
result1.image.save("test3.png")
result1.images[0].save("test3_1.png")
result1.images[1].save("test3_2.png")
@panghea panghea changed the title How to Set Up Original Image and Mask for Generation in ControlNet's Inpainting? How to set up original image and mask for generation in controlnet's inpainting? Jun 12, 2023
@derekcbr
Copy link

derekcbr commented Nov 4, 2023

Same question.
Not sure if this one r.image is the mask image or not?
r = api.controlnet_detect(images=[img], module='canny')
r.image

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

2 participants