Uh oh!
There was an error while loading. Please reload this page.
Flux Control(Depth/Canny) + Inpaint - #10192
Conversation
HuggingFaceDocBuilderDev
commented
Dec 12, 2024
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. |
sayakpaul
left a comment
There was a problem hiding this comment.
Thanks for starting this! I have left some comments, LMK if they make sense.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
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.
All of this could go to prepare_mask_latents.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
affromero
commented
Dec 12, 2024
I believe I've addressed all your comments, @sayakpaul@hlky. Please let me know if there's anything I might have missed. |
hlky
left a comment
There was a problem hiding this comment.
Left a suggestion and a couple comments but good to go on my end. Thanks!
Uh oh!
There was an error while loading. Please reload this page.
| # 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.
Possibly related, here's the effect it had on Redux #10056 (comment)
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: hlky <hlky@hlky.ac>
asomoza
commented
Dec 13, 2024
hlky
commented
Dec 13, 2024
@affromero here's a couple example PRs for documentation https://github.com/huggingface/diffusers/pull/10021/fileshttps://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. |
affromero
commented
Dec 18, 2024
I think this should be good, but not 100% sure @stevhliu, let me know what I can tweak or do next. |
sayakpaul
commented
Dec 18, 2024
Will let @hlky take care of the final merging. |
hlky
commented
Dec 18, 2024
Failing test is unrelated, good to go, thanks @affromero! |
vladmandic
commented
Dec 18, 2024
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 <hlky@hlky.ac> * make * prepare_latents is not copied from * update docs * typos --------- Co-authored-by: affromero <ubuntu@ip-172-31-17-146.ec2.internal> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> Co-authored-by: hlky <hlky@hlky.ac>
* 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 <hlky@hlky.ac> * make * prepare_latents is not copied from * update docs * typos --------- Co-authored-by: affromero <ubuntu@ip-172-31-17-146.ec2.internal> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> Co-authored-by: hlky <hlky@hlky.ac>


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.