diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Add vae_roundtrip.py example

Open thomaseding opened this issue 2 years ago • 15 comments

What does this PR do?

Adds examples/inference/vae_roundtrip.py to demonstrate VAE inference without any other models or pipelines.

Before submitting

  • [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Did you read the contributor guideline?
  • [x] Did you read our philosophy doc (important for complex PRs)?
  • [ ] Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [ ] Did you write any new necessary tests?

This just introduces a new demo example file. No need to update documents or update tests.

thomaseding avatar Feb 26 '24 15:02 thomaseding

why do we need this?

cc @sayakpaul

yiyixuxu avatar Feb 26 '24 21:02 yiyixuxu

You dont need it. If you think this is not a worthwhile example script, we can just close the ticket. I just submitted this because it took me a while to figure out how to use the VAE due to its non-tensor return values. And I already wrote the script in the first place to evaluate how good/bad the standard SD VAEs are with heavily aliased images.

thomaseding avatar Feb 27 '24 01:02 thomaseding

I just submitted this because it took me a while to figure out how to use the VAE due to its non-tensor return values.

You can mitigate that by specifying return_dict=False in your VAE call.

I am okay accommodating this script under the research_projects folder, if you're down.

sayakpaul avatar Feb 27 '24 01:02 sayakpaul

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.

I am okay accommodating this script under the research_projects folder, if you're down.

Sure why not. Alternatively there is also examples/community if that is better than placing under examples/research_projects/vae

thomaseding avatar Feb 27 '24 02:02 thomaseding

examples/community are for pipelines that can be loaded with the "custom_pipeline" argument. So, I think research_projects is a better location.

sayakpaul avatar Feb 27 '24 03:02 sayakpaul

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Mar 28 '24 15:03 github-actions[bot]

Will merge after the CI is green. Sorry for the delay.

sayakpaul avatar Mar 29 '24 02:03 sayakpaul

We need to make sure the code quality test passes.

sayakpaul avatar Mar 29 '24 02:03 sayakpaul

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Apr 22 '24 15:04 github-actions[bot]

@asomoza WDYT about this example?

sayakpaul avatar Jun 30 '24 05:06 sayakpaul

I like the idea but maybe focus it to a more practical use case?

This is used a lot to store the embeddings of the images, so probably a encode and save and a decode functionality would help the community more.

But I also think it's fine as an example if people struggle on how to do this, since we now have the community scripts, maybe this can be simplified and put there?

asomoza avatar Jun 30 '24 12:06 asomoza

But I also think it's fine as an example if people struggle on how to do this, since we now have the community scripts, maybe this can be simplified and put there?

Yes exactly. I wouldn't mind having it under research_projects really.

@thomaseding, apologies for the delay on our side. Could you maybe fix the styling problems so that we can merge this?

sayakpaul avatar Jul 01 '24 01:07 sayakpaul

I can't figure out why the style linter is complaining about unsorted imports.

Anyway I fixed a scaling bug and also added TAESD support.

thomaseding avatar Jul 01 '24 03:07 thomaseding

You can either search for the solutions and use them for the codes provided there "F403", for example. Or you can do "no qa" like done here:

https://github.com/huggingface/diffusers/blob/7bfc1ee1b2cb0961ff111f50a9d096816e4dd921/benchmarks/base_classes.py#L24

sayakpaul avatar Jul 01 '24 03:07 sayakpaul

@asomoza could you give this a final review and merge?

sayakpaul avatar Jul 04 '24 03:07 sayakpaul

Thanks a lot!

asomoza avatar Jul 04 '24 05:07 asomoza