Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
def classify(text):
|
8 |
+
|
9 |
+
classifier = pipeline("zero-shot-classification")
|
10 |
+
|
11 |
+
candidate_labels = ["positive", "negative", "neutral"]
|
12 |
+
|
13 |
+
output = classifier(text, candidate_labels)
|
14 |
+
|
15 |
+
return output
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
demo = gr.Interface(fn=classify,
|
22 |
+
|
23 |
+
inputs=gr.Textbox(label="Enter something"),
|
24 |
+
|
25 |
+
outputs=gr.Label(num_top_classes=3))
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
demo.launch()
|