-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[StableDiffusionInpaintPipeline] accept tensors for init and mask image #439
Conversation
The documentation is not available anymore as the PR was closed or merged. |
@patil-suraj There are problem here, in my opinion. If we send a FloatTensor, then there will be no preprocessing and the mask variable will not be declared, and secondly, there will be no transfer to the device.
With this, there should be no problems:
|
good catch! Updating it now |
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Question: if the user provides an image and a mask as tensors, should we verify that the number of channels match? The image should have R,G,B while the mask is only L. Is this something we should check or is it too much?
On second thought, we could just update the documentation and not the code:
mask_image (`torch.FloatTensor` or `PIL.Image.Image`):
`Image`, or tensor representing an image batch, to mask `init_image`. White pixels in the mask will be
replaced by noise and therefore repainted, while black pixels will be preserved. If `mask_image` is a
PIL image, it will be converted to a single channel (luminance) before use. If it's a tensor, it should
contain one color channel (L) instead of 3, so the expected shape would be `(B, H, W, 1)`.
Good point @pcuenca ! The pipeline is experimental and will be soon updated so just updated the docs for now. |
…ge (huggingface#439) * accept tensors * fix mask handling * make device placement cleaner * update doc for mask image
This PR updates
StableDiffusionInpaintPipeline
to accept bothtorch.FloatTensor
andPIL.Image.Image
forinit_image
andmask_image
.Fixes #370