File size: 439 Bytes
4fc0a20 29e2260 38eae67 0514662 29e2260 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli", device=1)
def classify(text, labels):
return classifier(text, candidate_labels=labels)
iface = gr.Interface(
fn=classify,
inputs=[gr.Text(label="Text"), gr.Textbox(lines=1, label="Candidate Labels (comma-separated)")],
outputs="json"
)
if __name__ == "__main__":
iface.launch() |