Spaces:
Sleeping
Sleeping
Commit
·
71c9e6d
1
Parent(s):
8213eaa
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as grad
|
3 |
+
|
4 |
+
zero_shot_classifier = pipeline("zero-shot-classification")
|
5 |
+
|
6 |
+
def classify(text, labels):
|
7 |
+
classifier_labels = labels.split(",")
|
8 |
+
#["software", "politics", "love", "movies", "emergency", "advertisment", "sports"]
|
9 |
+
response = zero_shot_classifier(text, classifier_labels)
|
10 |
+
|
11 |
+
return response
|
12 |
+
|
13 |
+
txt = grad.Textbox(lines = 1, label = "English", placeholder = "text to be classified")
|
14 |
+
labels = grad.Textbox(lines = 1, label = "Labels", placeholder = "comma separated labels")
|
15 |
+
out = grad.Textbox(lines = 1, label = "Classification")
|
16 |
+
|
17 |
+
grad.Interface(
|
18 |
+
classify,
|
19 |
+
inputs = [txt, labels],
|
20 |
+
outputs = out
|
21 |
+
).launch()
|