Skip to content

Allow gr.Templates to take in arguments#2600

Merged
abidlabs merged 16 commits into
mainfrom
template-fix
Nov 4, 2022
Merged

Allow gr.Templates to take in arguments#2600
abidlabs merged 16 commits into
mainfrom
template-fix

Conversation

@abidlabs
Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread gradio/templates.py Outdated
@@ -97,7 +106,9 @@ class Pil(components.Image):
is_template = True

def __init__(self, **kwargs):
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

abidlabs commented Nov 4, 2022

Fixed now, thanks for the suggestion @freddyaboulton!

Copy link
Copy Markdown
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