Spaces:
Sleeping
Sleeping
File size: 620 Bytes
e0ca228 50ca8c0 506611c 50ca8c0 7fc3a05 506611c 50ca8c0 506611c 7fc3a05 506611c e0ca228 50ca8c0 506611c 50ca8c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
import json
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
def tagging(
text_input: str,
tags: str,
multi_label: bool
):
try:
candidate_labels = json.loads(tags)
except error:
raise gr.Error(f"Error {error}")
classifier(text_input, candidate_labels, multi_label)
return text
app = gr.Interface(fn=tagging, inputs=[
gr.Textbox(label="Your input here"),
gr.Textbox(label="Your input here"),
gr.Checkbox(label="multi_label", value=True)
], outputs="text")
app.launch() |