frankrobotics's picture
Update app.py
c248b5f verified
raw
history blame contribute delete
625 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}")
output = classifier(text_input, candidate_labels, multi_label=True)
return output
app = gr.Interface(fn=tagging, inputs=[
gr.Textbox(label="Input here"),
gr.Textbox(label="Mags here"),
gr.Checkbox(label="Multi_label", value=True)
], outputs="text")
app.launch()