Skip to content

Fixes flagging when allow_flagging is set to "auto"#2695

Merged
abidlabs merged 9 commits into
mainfrom
autoflag
Dec 20, 2022
Merged

Fixes flagging when allow_flagging is set to "auto"#2695
abidlabs merged 9 commits into
mainfrom
autoflag

Conversation

@abidlabs
Copy link
Copy Markdown
Member

@abidlabs abidlabs commented Nov 22, 2022

Turns out we didn't implement allow_flagging set to "auto" when we re-implemented Interface to be constructed from Blocks. This restores that functionality.

Test with a script like this:

import os
import gradio as gr

def calculator(num1, operation, num2):
    if operation == "add":
        return num1 + num2
    elif operation == "subtract":
        return num1 - num2
    elif operation == "multiply":
        return num1 * num2
    elif operation == "divide":
        return num1 / num2

iface = gr.Interface(
    calculator,
    ["number", gr.Radio(["add", "subtract", "multiply", "divide"]), "number"],
    "number",
    allow_flagging="auto",
)

iface.launch()

Fixes: #2603

After discussion with @aliabid94, modified the functionality of "auto" to only log the input data. This simplifies the implementation considerably because there's no easy way to flag the data "once the prediction has completed running", and we think approach is reasonable for this relatively rare use case. Updated the documentation to reflect this functionality

@github-actions
Copy link
Copy Markdown
Contributor

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

@abidlabs abidlabs marked this pull request as draft November 22, 2022 19:23
@abidlabs abidlabs self-assigned this Nov 28, 2022
@abidlabs abidlabs marked this pull request as ready for review December 20, 2022 05:23
Copy link
Copy Markdown
Contributor

@aliabid94 aliabid94 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread gradio/flagging.py
Comment thread test/test_flagging.py
@abidlabs
Copy link
Copy Markdown
Member Author

Thanks for the review @aliabid94!

@abidlabs abidlabs merged commit 0879f0a into main Dec 20, 2022
@abidlabs abidlabs deleted the autoflag branch December 20, 2022 21:27
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.

allow_flagging="auto" not working on hugging face

2 participants