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

Render lists as lists instead of numerically-indexed dictionaries in gr.JSON #6949

Closed
1 task done
wdlm520 opened this issue Jan 4, 2024 · 1 comment · Fixed by #8932
Closed
1 task done

Render lists as lists instead of numerically-indexed dictionaries in gr.JSON #6949

wdlm520 opened this issue Jan 4, 2024 · 1 comment · Fixed by #8932
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@wdlm520
Copy link

wdlm520 commented Jan 4, 2024

Describe the bug

The following effect is the output of the JSON component of Gradio
How can I remove the Index such as 0,1
截屏2024-01-04 11 46 33

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

with gr.Blocks() as demo:
    res = {'uri': '/QueryAnalyseService/query_analyse', 'da_res_list': [{'norm': [{'query': '故宫', 'prob': 1}, {'query': '故宫', 'prob': 1}]}]}
    gr.JSON(res)

if __name__ == '__main__':
    demo.launch()

Screenshot

No response

Logs

No response

System Info

4.12.0

Severity

I can work around it

@wdlm520 wdlm520 added the bug Something isn't working label Jan 4, 2024
@abidlabs
Copy link
Member

abidlabs commented Jan 5, 2024

Hi @wdlm520, thanks for opening this issue. Lists are rendered as dictionaries by the gr.JSON() component with the index representing the key. I do feel like we should have option to keep the as lists, although we might not be able to get around to this soon. If you'd like to open a PR, we're happy to review!

As another option, we've 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's an example of a Gradio custom component: https://github.com/PhyscalX/gradio-image-prompter -- it lets you upload images and process points or draw boxes on top of the image.

If you'd like to create your own, we've put together a Guide: https://www.gradio.app/guides/five-minute-guide, and we're happy to help.

@abidlabs abidlabs added enhancement New feature or request and removed bug Something isn't working labels Jan 5, 2024
@abidlabs abidlabs changed the title JSON index bug Render lists as lists instead of dictionaries in gr.JSON Jan 5, 2024
@abidlabs abidlabs changed the title Render lists as lists instead of dictionaries in gr.JSON Render lists as lists instead of numerically-indexed dictionaries in gr.JSON Jan 11, 2024
@abidlabs abidlabs added this to the Gradio 5️⃣ milestone Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants