test2 / app.py
sbthesis's picture
Update app.py
add8153
from transformers import pipeline
import torch
import gradio as gr #this is in place of the streamlit of the HF video
title = "Saras second try categorizes statements [as business, education, law, politics]"
description = "Based on a zero-shot-classification model (default facebook/bart-large-mnli)"
examples = [["The president was elected last week then convicted of ten crimes and imprisoned, though he was paid $10,000 for his trouble"]]
classifier = pipeline("zero-shot-classification")
#heres the prediction function tp predict the response and add it to history
def predict(input):
# generate a response
response = classifier(
input,
candidate_labels=["education", "politics", "business","law"],
)
return response
#see https://www.gradio.app/guides/quickstart
gr.Interface(
fn=predict,
title=title,
description=description,
examples=examples,
inputs=["text"],
outputs=["text"],
theme="finlaymacklon/boxy_violet",
).launch()