Changed code that converts tensors to PIL images in the write_your_own_pipeline notebook #4489
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Some weeks ago i had a PR merged on the notebooks repo. It had some changes to the write_your_own_pipeline notebook, but the hf docs builder bot has overwritten the changes in this commit
you can check the commit history
To me it seems that changing the notebooks on the notebooks repo does nothing, because you have to change to "source code" here in these markdown files. [citation required] If this is the case maybe this should be mentioned in the notebooks repo readme.md so it's clear.
The actual code changes
Hello, this PR rewrites two cells in the write_your_own_pipeline diffusers notebook.
It changes the code that converts the output tensor to a PIL image to run a bit faster. It uses squeeze on the tensor and then runs all possible operations on the GPU before transferring the tensor to the CPU and creating the PIL Image.
You can find the code i used to benchmark my changes in this colab , I'm unsure if this kind of benchmarking code is the "proper" way to do it
I think it's generally good pytorch practice to do as many things on the GPU before transferring things to the CPU
Feel free to discuss this change and maybe find an even faster way to write this code 🤗
Fixes # (issue)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@patrickvonplaten - Patrick has reviewed the PR that was merged 3 weeks ago, maybe you remember this PR, the changes aren't visible in the notebooks. I'm not sure where exactly i have to change my code for it to be visible both in the notebooks and in the docs files on the website
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.