-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat: add repaint #974
feat: add repaint #974
Conversation
The documentation is not available anymore as the PR was closed or merged. |
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.
Hi @Revist! Excited to see a working RePaint port, thank you so much for working on it!
Overall the implementation is super nice, just left a couple of suggestions to bring it closer to the Stable Diffusion inpainting API (which got added after my original repaint PR).
Now I wonder if it's possible to move the noising & masking logic from RePaintScheduler
to RePaintPipeline
, so that it can be used with other schedulers like PNDM or K-LMS? By using just step()
and add_noise()
, similar to the unsupervised inpainting pipeline for Stable Diffusion: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint_legacy.py#L46
What do you think, would that be possible to do here?
Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
Hi @anton-l ! Was doing some reading as i was not that familiar with these, but it seems that although theoretically that should be possible (after all RePaint just repeats some steps) in practice you have some problems like here: |
Reading further in to make a step with PNDM you do not need a single model_output at single time but at t, t+delta/2 and t+delta (from different inputs in fact so we have 4 passes) so that changes logic here: |
@anton-l I am not sure if you agree with the above comments. If so I could take a look at how to change the code to the PNDM (and possibly other) schedulers however that seems like significant changes across code. |
@Revist I've tried refactoring it a bit and completely share your concerns now, let's leave the scheduler as is for now! Pinging @patrickvonplaten @patil-suraj for a second review, as this is a new pipeline and scheduler :) |
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/" | ||
"repaint/celeba_hq_256_result.png" | ||
) | ||
expected_image = np.array(expected_image, dtype=np.float32) / 255.0 |
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.
Ok for now, but let's make sure to pass to numpy image tests in the very near future
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.
Will fetch the numpy images for all integration tests in a bulk PR 👍
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.
Looks good to me ! Before merging let's please make sure to add it to the docs as well and maybe reach out to the original author here?
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Added the docs for the pipeline: https://moon-ci-docs.huggingface.co/docs/diffusers/pr_974/en/api/pipelines/repaint Gently pinging the RePaint author @andreas128 for an optional review and any comments, in case out email thread gets lost 🤗 |
@Revist the pipeline will be included in today's If you're interested, maybe we could work together on a Spaces demo similar to SD-inpainting https://huggingface.co/spaces/runwayml/stable-diffusion-inpainting to promote the pipeline further, let me know what you think! |
@Revist ping me ( @anton-l ) on the HF discord: https://discord.gg/G7tWnz98XR |
* feat: add repaint * fix: fix quality check with `make fix-copies` * fix: remove old unnecessary arg * chore: change default to DDPM (looks better in experiments) * ".to(device)" changed to "device=" Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> * make generator device-specific Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> * make generator device-specific and change shape Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> * fix: add preprocessing for image and mask Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> * fix: update test Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> * Update src/diffusers/pipelines/repaint/pipeline_repaint.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Add docs and examples * Fix toctree Co-authored-by: fja <fja@zurich.ibm.com> Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Anton Lozhkov <anton@huggingface.co>
Added repaint pipeline based on https://arxiv.org/pdf/2201.09865.pdf @anton-l
In tests i was not sure where you take numbers to compare against from so I run the pipeline and pasted what it produces for me:
[0.14537135, 0.10728511, 0.08822048, 0.15828621, 0.11806837, 0.11007798, 0.15231332, 0.1214554, 0.15475643]