Skip to content
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

3248 image #3277

Merged
merged 13 commits into from
Feb 23, 2023
Merged

3248 image #3277

merged 13 commits into from
Feb 23, 2023

Conversation

pngwn
Copy link
Member

@pngwn pngwn commented Feb 22, 2023

Description

There was a bug which caused the Sketch to get stuck in a resize loop causing #3248.

Also added support for the shape kwarg on the frontend with sketches. I did look at image uploads too but that requires pretty significant changes, so will leave it for now.

I have added demos to blocks_mask. 2c and 5d. They should be testable in the PR preview.

Closes #3248. Closes #3166.

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 👋 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Feb 22, 2023

🎉 The demo notebooks match the run.py files! 🎉

@gradio-pr-bot
Copy link
Collaborator

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3277-all-demos

@abidlabs
Copy link
Member

This looks great! Can confirm demo 5d works as expected. For 2c, I think it would be helpful as a visual aid to users to know where the sketchpad starts and stops. Like maybe the component is grayed out outside of the boundaries of the sketchpad?

Here's how it currently looks:

image

Here's what I'm proposing (but without hiding the icons):

image

@pngwn
Copy link
Member Author

pngwn commented Feb 22, 2023

Yeah I agree, would a border work? I'm not a huge fan of the grey, looks very sad.

@freddyaboulton
Copy link
Collaborator

I like the border approach @pngwn !

@pngwn
Copy link
Member Author

pngwn commented Feb 22, 2023

Did the brush_radius thing for @apolinario too. Can now set a default size and update it via gr.update()

Can test like this when i push:

with gr.Blocks():
  gr.Image(source="canvas", tool="color-sketch")
  gr.Image(source="canvas", brush_radius=100, tool="color-sketch")
  img = gr.Image(source="canvas", interactive=True, tool="color-sketch")
  r = gr.Number(20, label="Change brush size", max="100")
  btn = gr.Button("Change Brush")

  def brushy(size):
    print(size)
    return img.update(brush_radius=size)

  btn.click(brushy, inputs=r, outputs=img)

@abidlabs
Copy link
Member

abidlabs commented Feb 22, 2023

Border is even better!

@pngwn
Copy link
Member Author

pngwn commented Feb 22, 2023

Brush size thing introduced some bugs will see if i can fix quickly.

@pngwn
Copy link
Member Author

pngwn commented Feb 22, 2023

Okay i think we're good. Updated changelog again and fixed bug and added border.

This was the brush change btw:

Screen.Recording.2023-02-22.at.18.42.55.mov

@pngwn
Copy link
Member Author

pngwn commented Feb 22, 2023

border:

Screenshot 2023-02-22 at 20 17 21

@pngwn
Copy link
Member Author

pngwn commented Feb 22, 2023

Will fix test

@@ -1398,7 +1399,9 @@ def __init__(
streaming: If True when used in a `live` interface, will automatically stream webcam feed. Only valid is source is 'webcam'.
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
mirror_webcam: If True webcam will be mirrored. Default is True.
brush_radius: Size of the brush for Sketch. Default is None which chooses a sensible default
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
brush_radius: Size of the brush for Sketch. Default is None which chooses a sensible default
brush_radius: Size of the brush for sketching (in pixels). Default is None which chooses a sensible default. Only applicable if `tool` is `sketch` or `color-sketch`

@@ -1398,7 +1399,9 @@ def __init__(
streaming: If True when used in a `live` interface, will automatically stream webcam feed. Only valid is source is 'webcam'.
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
mirror_webcam: If True webcam will be mirrored. Default is True.
brush_radius: Size of the brush for Sketch. Default is None which chooses a sensible default
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
brush_radius: Size of the brush for Sketch. Default is None which chooses a sensible default
brush_radius: Size of the brush for sketching (in pixels). Default is None which chooses a sensible default. Only applicable if `tool` is `sketch` or `color-sketch`

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

Tested and LGTM. Very cool PR @pngwn!

@pngwn pngwn merged commit 372a3cc into main Feb 23, 2023
@Charmandrigo
Copy link

Hey, not sure what's going on but my UI is on Gradio 3.31.0 and this issue still exist, at least for me, same description as other issues, it freezes the addon while loading then it crashes. It happens when I create a new 512,512 canvas with the Two Shot addon

@pngwn
Copy link
Member Author

pngwn commented Jul 1, 2023

Could you update to the latest version to see if the issues is still present?

If it is could you please create a new issue with a minimal reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants