Spaces:
Sleeping
Sleeping
File size: 779 Bytes
2473cb3 298eb7e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from transformers import pipeline
import gradio as gr
# Initialize zero-shot-classification pipeline
zero_shot_classifier = pipeline("zero-shot-classification")
# Define classification function
def classify(text, labels):
classifier_labels = labels.split(",") # Split the comma-separated labels into a list
response = zero_shot_classifier(text, classifier_labels) # Perform the classification
return response
# Define Gradio interface elements
txt = gr.Textbox(lines=1, label="English", placeholder="Text to be classified")
labels = gr.Textbox(lines=1, label="Labels", placeholder="Comma-separated labels")
out = gr.Textbox(lines=1, label="Classification")
# Create the interface and launch it
gr.Interface(classify, inputs=[txt, labels], outputs=out).launch()
|