custom-components#985
Conversation
- create template components - changes in PKG and requires comes from scripts/install_gradio.sh
- tweaks
|
A general point I want to make: Now that we have templates, we should remove the But we have an internal discrepancy, which is that
Also, we should create a separate template for |
The only reason we support string shortcuts is for backwards compatibility. So I wouldn't consider this as a discrepancy and would not hurt to leave it like this. That's why I dropped some of the shortcuts like |
- tweaks
- fix get_block_name
- add webcam demo
|
Good to merge if everything is ok! |
Not really -- string shortcuts for the Interface class will continue to be useful and we should continue supporting this. That being said, we can leave the |
| { | ||
| "id": _id, | ||
| "type": block.__class__.__name__.lower(), | ||
| "type": ( |
There was a problem hiding this comment.
This could be block.get_block_name() given the method that was just added to the Blocks class
There was a problem hiding this comment.
well I actually mainly created the function to use here, but it seems I forgot, thx for the careful review.
|
Sorry GitHub was being weird for me, and I think some of my comments above got duplicated. |
- make use of get_block_name function whenever possible
- tweaks
|
Good to go! Updating get_shortcut_implementations in another branch. |
| input_names = [type(inp).__name__ for inp in app.blocks.input_components] | ||
| output_names = [type(out).__name__ for out in app.blocks.output_components] | ||
| input_names = [inp.get_block_name() for inp in app.blocks.input_components] | ||
| output_names = [out.get_block_name() for out in app.blocks.output_components] |
|
Yeah, so this looks good. Though I still think we should change:
to
|
Adding @aliabid94 and @pngwn as it seems we cannot reach to an agreement :) I am not in favor of importing templates via Related comment. I prefer these Btw I am okay with |
|
Sorry for the late comment on this. I do not understand the purpose here. Are we trying to encourage the use of these Template components? I think it's going to be very confusing for a user to have both Components and Templates in the same namespace. When should they use gr.Image(type="pil"), and when should they use gr.PIL()? And if they use gr.PIL, how do they find the documentation for the other constructor arguments - do they go to gr.Image, or is the documentation duplicated entirely for this gr.PIL class? Using naming format gr.Template.PIL creates a distinction between Templates and regular Components, but having gr.Template.PIL() is such a long name, it does not save enough time compared to gr.Image(source="pil") to be worth it. It also just adds a lot of duplicate documentation. I really think having these Templates is going to create much more confusion down the line. If we want to support string shortcuts, then they should remain strings. Creating extended subclasses, when in most cases the extension only sets a single keyword argument is just making two ways to do the same thing, which only adds confusion. It's true that the original string shortcuts also introduced two ways to do the same thing, but because the strings were short and they could not be configured like classes, it was clear when to use the string shortcut and when the use the Component class. If we want to keep string shortcuts, I would be maybe be okay with something like gr.get("webcam"). Happy to discuss in person. |
|
Hmm, I actually agree with some of your points. Though the reason we have these templates is because we want to support previous use of string shortcuts in Blocks(which is I am against it actually, we should drop the shortcuts and make people use components like you mentioned because of the points you gave above). Other than we can't use string shortcuts in blocks,. Btw having shortcuts for |
|
Btw for shortcutting in Blocks we can make use of this function in the other PR: |
|
I'm persuaded as well. Ok so let's just stick to using the @farukozderim we can still keep the demos here, let's just update them to use |
|
Will update in #995 |
closes #731