-
Notifications
You must be signed in to change notification settings - Fork 6k
Flux Control(Depth/Canny) + Inpaint #10192
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
Flux Control(Depth/Canny) + Inpaint #10192
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
Thanks for starting this! I have left some comments, LMK if they make sense.
else: | ||
masked_image_latents = retrieve_latents(self.vae.encode(masked_image), generator=generator) | ||
|
||
masked_image_latents = (masked_image_latents - self.vae.config.shift_factor) * self.vae.config.scaling_factor |
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.
We could allow passing precomputed masked_image_latents
but this is not a blocker for this PR.
if masked_image_latents is not None: | ||
masked_image_latents = masked_image_latents.to(latents.device) | ||
else: | ||
image = self.image_processor.preprocess(image, height=height, width=width) | ||
mask_image = self.mask_processor.preprocess(mask_image, height=height, width=width) | ||
|
||
masked_image = image * (1 - mask_image) | ||
masked_image = masked_image.to(device=device, dtype=prompt_embeds.dtype) | ||
|
||
height, width = image.shape[-2:] | ||
mask, masked_image_latents = self.prepare_mask_latents( | ||
mask_image, | ||
masked_image, | ||
batch_size, | ||
num_channels_latents, | ||
num_images_per_prompt, | ||
height, | ||
width, | ||
prompt_embeds.dtype, | ||
device, | ||
generator, | ||
) | ||
masked_image_latents = torch.cat((masked_image_latents, mask), dim=-1) |
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.
All of this could go to prepare_mask_latents
.
I believe I've addressed all your comments, @sayakpaul @hlky. Please let me know if there's anything I might have missed. |
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.
Left a suggestion and a couple comments but good to go on my end. Thanks!
# def test_flux_different_prompts(self): | ||
# pipe = self.pipeline_class(**self.get_dummy_components()).to(torch_device) | ||
|
||
# inputs = self.get_dummy_inputs(torch_device) | ||
# output_same_prompt = pipe(**inputs).images[0] | ||
|
||
# inputs = self.get_dummy_inputs(torch_device) | ||
# inputs["prompt_2"] = "a different prompt" | ||
# output_different_prompts = pipe(**inputs).images[0] | ||
|
||
# max_diff = np.abs(output_same_prompt - output_different_prompts).max() | ||
|
||
# # Outputs should be different here | ||
# # For some reasons, they don't show large differences | ||
# assert max_diff > 1e-6 |
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.
Possibly related, here's the effect it had on Redux #10056 (comment)
@affromero here's a couple example PRs for documentation https://github.com/huggingface/diffusers/pull/10021/files https://github.com/huggingface/diffusers/pull/10131/files files under docs/. Ping @stevhliu if you need help with the docs or when they're ready for review. |
I think this should be good, but not 100% sure @stevhliu, let me know what I can tweak or do next. |
Will let @hlky take care of the final merging. |
Failing test is unrelated, good to go, thanks @affromero! |
please update @yiyixuxu @sayakpaul @asomoza can we make this somehow part of the mandatory template? 90% of the time when any img2img or inpaint pipeline is added, autopipeline mapping is NOT updated. |
* flux_control_inpaint - failing test_flux_different_prompts * removing test_flux_different_prompts? * fix style * fix from PR comments * fix style * reducing guidance_scale in demo * Update src/diffusers/pipelines/flux/pipeline_flux_control_inpaint.py Co-authored-by: hlky <[email protected]> * make * prepare_latents is not copied from * update docs * typos --------- Co-authored-by: affromero <[email protected]> Co-authored-by: Sayak Paul <[email protected]> Co-authored-by: hlky <[email protected]>
* flux_control_inpaint - failing test_flux_different_prompts * removing test_flux_different_prompts? * fix style * fix from PR comments * fix style * reducing guidance_scale in demo * Update src/diffusers/pipelines/flux/pipeline_flux_control_inpaint.py Co-authored-by: hlky <[email protected]> * make * prepare_latents is not copied from * update docs * typos --------- Co-authored-by: affromero <[email protected]> Co-authored-by: Sayak Paul <[email protected]> Co-authored-by: hlky <[email protected]>
What does this PR do?
The Flux pipeline for image inpainting using Flux-dev-Depth/Canny
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul @yiyixuxu
Following this interaction about contributing this pipeline to main.