Spaces:
Runtime error
Runtime error
Commit
·
e8ad692
1
Parent(s):
7ee21c7
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the zero-shot classification pipeline
|
5 |
+
classifier = pipeline("zero-shot-classification")
|
6 |
+
|
7 |
+
# Define the Gradio interface
|
8 |
+
iface = gr.Interface(
|
9 |
+
fn=lambda text, candidate_labels: classifier(text, candidate_labels),
|
10 |
+
inputs=[gr.Textbox(label="Enter Text"), gr.Textbox(label="Enter Candidate Labels (comma-separated)")],
|
11 |
+
outputs=gr.Label(),
|
12 |
+
live=True,
|
13 |
+
interpretation="default",
|
14 |
+
title="Zero-Shot Classification",
|
15 |
+
description="Enter a text and candidate labels (comma-separated) to classify.",
|
16 |
+
)
|
17 |
+
|
18 |
+
# Launch the Gradio interface
|
19 |
+
iface.launch()
|