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

Allow gr.Templates to take in arguments #2600

Merged
merged 16 commits into from
Nov 4, 2022
Merged

Allow gr.Templates to take in arguments #2600

merged 16 commits into from
Nov 4, 2022

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Nov 3, 2022

A fix to gr.Templates so that they can take in arguments. Fixes: #2595

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2022

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

@abidlabs abidlabs marked this pull request as ready for review November 3, 2022 19:53
@@ -97,7 +106,9 @@ class Pil(components.Image):
is_template = True

def __init__(self, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better if we specified the kwargs the class supports as opposed to accepting arbitrary kwargs?

Right now you could do gr.Pil(type="numpy") which is confusing/defeats the purpose of the template. Also means devs won't get hints from their editors and makes it easy to make a typo and only be aware at runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah you're right. I think it's okay to override the template params but you're right it would be good to specify them explicitly

@abidlabs
Copy link
Member Author

abidlabs commented Nov 4, 2022

Fixed now, thanks for the suggestion @freddyaboulton!

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Thank you for the fix @abidlabs !

@abidlabs abidlabs merged commit 218fb9f into main Nov 4, 2022
@abidlabs abidlabs deleted the template-fix branch November 4, 2022 16:08
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.

gr.Sketchpad does not take arguments
2 participants