import gradio as gr from transformers import pipeline classifier = pipeline(task="zero-shot-classification", model = "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli") def classify(text): candidate_labels = ["positive", "negative", "neutral"] output = classifier(text, candidate_labels) # Process the output to match Gradio's expected input format for gr.Label labels = output['labels'] scores = output['scores'] # Construct a simple string representation of top classifications top_classes = ', '.join([f"{labels[i]}: {scores[i]:.2f}" for i in range(len(labels))]) return top_classes demo = gr.Interface(fn=classify, inputs=gr.Textbox(label="Enter something"), outputs=gr.Label()) demo.launch()