Skip to content

Conversation

@ruanrz
Copy link
Contributor

@ruanrz ruanrz commented Nov 8, 2022

  1. In img2img example. This code force change input image ratio. This is not a good practice, since the init image will be preprocessed and keep aspect ratio.

  2. Use init_image.thumbnail() can resize the image and keep its original aspect ratio, which avoid CUDA out of memory runtime error for large input image.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@patrickvonplaten
Copy link
Contributor

Hey @ruanrz,

I think the idea was here to indeed change the input image ration I believe so not sure if we should make this change, but let's ask the authors :-)

cc @pcuenca @patil-suraj what do you think here?

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original image has a size of (1024, 512). Our intention was to make it a bit smaller so we resized it to (768, 512). It does stretch the image, of course, but the result from the img2img pipeline is good nonetheless, in my opinion.

This new version resizes to (768, 384) instead by keeping the same aspect ratio. This reduces memory consumption to a bit under 11GB (vs a bit under 13GB for the previous example) according to my tests. Both versions would work on a free Colab TPU, but the new one should also work on 11 GB GPUs like the 2080 Ti or 1080 Ti. So I think this version is slightly better as an example because more people can play with it on their computers without having to touch the code.

Thank you!

@pcuenca pcuenca merged commit 8171566 into huggingface:main Nov 11, 2022
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.

5 participants