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
Fix gr.Interface.from_pipeline()
to allow audio uploads and to display classification labels correctly
#8080
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/c7a99b6a98ebd8c1d30cb355bd371a87de8128b7/gradio-4.27.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@c7a99b6a98ebd8c1d30cb355bd371a87de8128b7#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@@ -66,7 +59,7 @@ def is_transformers_pipeline_type(pipeline, class_name: str): | |||
), | |||
"outputs": components.Label(label="Classification", render=False), | |||
"preprocess": lambda i: {"images": i}, | |||
"postprocess": lambda r: {i["label"].split(", ")[0]: i["score"] for i in r}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transforms a label name like "tiger, Panthera tigris" into just "tiger", which looks not good.
Sample code:
import gradio as gr
from transformers import pipeline
pipe = pipeline("image-classification", "google/vit-base-patch16-224")
demo = gr.Interface.from_pipeline(pipe)
demo.launch()
Sample file to test: https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/tiger.jpg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah in the general case better to leave the labels as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm @whitphx!
I would just suggest using a more precise name for this PR since that is what shows up in the changelog |
Oh 👀 |
gr.Interface.from_pipeline()
to allow audio uploads and to display classification labels correctly
Description
During #8052, I found something.
Reference: first commit of
from_pipeline