|
from transformers import pipeline |
|
import torch |
|
import gradio as gr |
|
|
|
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") |
|
|
|
|
|
def predict(input): |
|
|
|
response = classifier( |
|
input, |
|
candidate_labels=["education", "politics", "business","law"], |
|
) |
|
return response |
|
|
|
|
|
gr.Interface( |
|
fn=predict, |
|
title=title, |
|
description=description, |
|
examples=examples, |
|
inputs=["text"], |
|
outputs=["text"], |
|
theme="finlaymacklon/boxy_violet", |
|
).launch() |
|
|
|
|
|
|
|
|
|
|
|
|