You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to use Gradio-Lite with zero-shot-classification Transformer.js.py pipeline and providing potential classes (as with "classic" Transformer and Transformer.js pipelines). But it outputs only one probability.
Using gr.Interface.from_pipeline(pipe) works but user needs to provide potential classes manually.
I first try to define labels within the pipe at inference (as with "classic" Transformer pipeline). Wasn't working.
Then I tried at model initialization. Wasn't working either as expected.
Seems you have to define them separately from inference call.
It's working now.
Arigato !
from transformers_js import import_transformers_js
import gradio as gr
labels=['politics', 'music','police'] # works
transformers = await import_transformers_js()
pipeline = transformers.pipeline
model_path = 'Xenova/mobilebert-uncased-mnli'
pipe = await pipeline('zero-shot-classification', model_path) # Not here.
# labels=['politics', 'music','police'] # works
async def classify(text):
pred = await pipe(text, labels # Pass `labels` here.
# labels=['politics', 'music','police'] # doesn't work
)
return pred["scores"]
demo = gr.Interface(classify, "textbox", "textbox")
demo.launch()
Describe the bug
Hello,
I'm trying to use Gradio-Lite with zero-shot-classification Transformer.js.py pipeline and providing potential classes (as with "classic" Transformer and Transformer.js pipelines). But it outputs only one probability.
Using gr.Interface.from_pipeline(pipe) works but user needs to provide potential classes manually.
Am'I missing some arguments here ?
Have you searched existing issues? 🔎
Reproduction
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>Screenshot
No response
Logs
No response
System Info
Gradio-Lite (So I guess it's up to date!)
Severity
Blocking usage of gradio
The text was updated successfully, but these errors were encountered: