Skip to content

Conversation

jere357
Copy link
Contributor

@jere357 jere357 commented Aug 5, 2023

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

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.

@jere357 jere357 changed the title changed code that converts tensors to PIL images changed code that converts tensors to PIL images in the write_your_own_pipeline notebook Aug 5, 2023
@jere357 jere357 changed the title changed code that converts tensors to PIL images in the write_your_own_pipeline notebook Changed code that converts tensors to PIL images in the write_your_own_pipeline notebook Aug 5, 2023
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 5, 2023

The documentation is not available anymore as the PR was closed or merged.

@sayakpaul sayakpaul merged commit 3c1b493 into huggingface:main Aug 9, 2023
@sayakpaul
Copy link
Member

@jere357 it's the other way around i.e., when you add [[open-in-colab]] in a markdown documentation, the doc builder automatically pushes the notebook version from it.

@stevhliu can shed more light.

@stevhliu
Copy link
Member

stevhliu commented Aug 9, 2023

Hi! The notebooks in the notebooks repo are all generated from the docs by the doc-builder when we add [[open-in-colab]] to it. Thanks for your feedback though, and I'll make a mention of it in the README.md! 😄

AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…n_pipeline notebook (huggingface#4489)

changed code that converts tensors to PIL images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants