Case-Classification / app-zero.py
jorgefio's picture
Rename app.py to app-zero.py
d375532
raw
history blame
720 Bytes
import gradio as gr
from transformers import pipeline
classifier = pipeline("zero-shot-classification")
labels = ["No Connectivity", "Billing", "Setup", "Slow Connection"]
def predict(text):
preds = classifier(text, candidate_labels=labels)
return {label: float(pred) for label, pred in zip(preds["labels"], preds["scores"])}
input = gr.inputs.Textbox(label="Customer Sentence")
output = gr.outputs.Label(num_top_classes=4, label="Zero-Shot-Classification")
title = "Case Classification"
description = "Zero-Shot-Classification test"
gr.Interface(predict, input, output, live=False, live_update=False, title=title, analytics_enabled=False,
description=description, capture_session=True).launch()