gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.41k stars 2.53k forks source link

Nested spans with`HighlightedText` #559

Closed JulesBelveze closed 11 months ago

JulesBelveze commented 2 years ago

Is your feature request related to a problem? Please describe.

Hey all, I am trying to build a Gradio app with a named entity recognition model which supports nested spans (e.g. in "JFK Street" the model would return "JFK" as a person and "JFK Street" as a location). However (to the best of my knowledge) this isn't currently possible when using HighlightedText as it requires outputs to be of the following type: List[Tuple[str, Union[float, str]]].

Describe the solution you'd like

It would be great that tokens can have multiple labels. An idea could be to allow outputs of the following type: List[Tuple[str, List[Union[float, str]]]]

Thanks for the super cool library 😺

abidlabs commented 2 years ago

Makes sense! @dawoodkhan82 can you look into this?

abidlabs commented 11 months ago

Hi! We've now made it possible for Gradio users to create their own custom components -- meaning that you can write some Python and JavaScript (Svelte), and publish it as a Gradio component. You can use it in your own Gradio apps, or share it so that anyone can use it in their Gradio apps. Here are some examples of custom Gradio components:

You can see the source code for those components by clicking the "Files" icon and then clicking "src". The complete source code for the backend and frontend is visible. In particular, its very fast if you want to build off an existing component. We've put together a Guide: https://www.gradio.app/guides/five-minute-guide, and we're happy to help if you'd like to put together a custom component for this issue