Skip to content

Preserve Labels In Interpretation Components#2166

Merged
freddyaboulton merged 3 commits into
mainfrom
2098-preserve-labels-through-interpretation
Sep 7, 2022
Merged

Preserve Labels In Interpretation Components#2166
freddyaboulton merged 3 commits into
mainfrom
2098-preserve-labels-through-interpretation

Conversation

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton commented Sep 2, 2022

Description

Fixes #2098

Before

image

After

image

import gradio as gr
import random


def is_greater_than_50(num: int) -> bool:
    return num > 50

def sum_all(audio, checkbox, checkboxgroup, dropdown, image, number, radio, slider, textbox):
    return sum(random.random() * 50 for _ in range(9))

inputs = [gr.Audio(label="My Audio", value="heath_ledger_2.mp3"), gr.Checkbox(label="My Checkbox"),
          gr.CheckboxGroup(choices=["a", "b", "c"], value="b", label="My Checkboxgroup"),
          gr.Dropdown(choices=["d", "e", "f"], value="f", label="My Dropdown"),
          gr.Image(value="lion.jpg", label="My Image"),
          gr.Number(value=5, label="My Number"),
          gr.Radio(choices=[1, 2, 3, 4], value=3, label="My Radio"),
          gr.Slider(minimum=0, maximum=10, value=2, step=1, label="My Slider"),
          gr.Textbox(value="I love apples", label="My Textbox")]

iface = gr.Interface(fn=sum_all, inputs=inputs,
                     outputs="number", interpretation="default")
iface.launch()

Checklist:

  • I have performed a self-review of my own code
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 2, 2022

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2166-all-demos

@freddyaboulton freddyaboulton marked this pull request as ready for review September 2, 2022 19:39
@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Sep 5, 2022

Nice Svelte@freddyaboulton!! I'll let @aliabid94 @dawoodkhan82 or @pngwn review this one :)

Copy link
Copy Markdown
Collaborator

@dawoodkhan82 dawoodkhan82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested. Looks good

@freddyaboulton freddyaboulton force-pushed the 2098-preserve-labels-through-interpretation branch from ad7a443 to ffa1576 Compare September 7, 2022 18:06
@freddyaboulton
Copy link
Copy Markdown
Collaborator Author

Thank you for the review @dawoodkhan82 !

@freddyaboulton freddyaboulton merged commit a69fd1d into main Sep 7, 2022
@freddyaboulton freddyaboulton deleted the 2098-preserve-labels-through-interpretation branch September 7, 2022 18:43
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.

Labels disappear when interpretation is clicked

3 participants