File size: 537 Bytes
31a7455 5d00e2d 31a7455 656c4ee 5d00e2d 18418b8 5d00e2d d68ebfc 31a7455 656c4ee 31a7455 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
from transformers import pipeline
def do_action(text):
classifier = pipeline("zero-shot-classification",
model="facebook/bart-large-mnli")
candidate_labels = ['gun control', 'abortion', 'gender transition', 'freedom of speech', 'immigration', 'taxes']
result = classifier(text, candidate_labels)
sentence = f"{result['labels'][0]} with a score of {result['scores'][0]}"
return sentence
iface = gr.Interface(fn=do_action, inputs="text", outputs="text")
iface.launch()
|