-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix ImageEditor Size Issues #10357
Fix ImageEditor Size Issues #10357
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/9d27e43d5aa44ecfb6df0f2d7540e767c55b52b5/gradio-5.12.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@9d27e43d5aa44ecfb6df0f2d7540e767c55b52b5#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/9d27e43d5aa44ecfb6df0f2d7540e767c55b52b5/gradio-client-1.10.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/9d27e43d5aa44ecfb6df0f2d7540e767c55b52b5/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
a5b1b83
to
bece029
Compare
Just a quick question, this looks like a pretty significant breaking change as previously the How do we want to handle this? |
Yea it's a good point. But I think the change in behavior is more of a bug fix and it's complimentary to the crop_size parameter instead of replacing it. What I gathered from the issues is that people find the current canvas size behavior confusing. I think developers find it more natural to control the canvas size via |
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 great! Thanks @freddyaboulton!
Description
Closes: #7685
Closes: #8667
Closes: #10265
Closes: #10255
Closes: #9889
Closes: #9305
Closes: #8556
Fixes the image editor sizing issues by taking the following approach:
canvas_size=None
(default) the canvas size is determined by the background image.canvas_size
is givem, then images are resized to fit within this canvas size while keeping their original aspect ratio.fixed_canvas
parameter. Iffixed_canvas
is True, then the canvas size will not change to match the resized image. The resized image will be centered in the larger canvas. This should support some outpainting demos. See example below.Example of uploading a 256 x 256 image to a image editor with
canvas_size=(500, 500), fixed_canvas=True
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Testing and Formatting Your Code
PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests:
bash scripts/run_backend_tests.sh
Please run these bash scripts to automatically format your code:
bash scripts/format_backend.sh
, and (if you made any changes to non-Python files)bash scripts/format_frontend.sh