frankrobotics's picture
Update app.py
7fc3a05 verified
raw
history blame
620 Bytes
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()