-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2600-all-demos |
gradio/templates.py
Outdated
@@ -97,7 +106,9 @@ class Pil(components.Image): | |||
is_template = True | |||
|
|||
def __init__(self, **kwargs): |
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.
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.
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.
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
Fixed now, thanks for the suggestion @freddyaboulton! |
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.
Thank you for the fix @abidlabs !
A fix to
gr.Templates
so that they can take in arguments. Fixes: #2595