Spaces:
Running
on
Zero
Running
on
Zero
Lord-Raven
commited on
Commit
·
47a0109
1
Parent(s):
db18a94
Trying zero-shot classification.
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import gradio
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
def zero_shot_classification(
|
|
|
5 |
classifier = pipeline('zero-shot-classification', model='Xenova/mobilebert-uncased-mnli')
|
6 |
|
7 |
results = classifier(data.sequence, candidate_labels=data.candidate_labels, hypothesis_template=data.hypothesis_template, multi_label=data.multi_label)
|
@@ -9,7 +10,7 @@ def zero_shot_classification(data):
|
|
9 |
|
10 |
gradio_interface = gradio.Interface(
|
11 |
fn = zero_shot_classification,
|
12 |
-
inputs = "
|
13 |
outputs = "json"
|
14 |
)
|
15 |
gradio_interface.launch()
|
|
|
1 |
import gradio
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
def zero_shot_classification(data_string):
|
5 |
+
data = json.loads(data_string)
|
6 |
classifier = pipeline('zero-shot-classification', model='Xenova/mobilebert-uncased-mnli')
|
7 |
|
8 |
results = classifier(data.sequence, candidate_labels=data.candidate_labels, hypothesis_template=data.hypothesis_template, multi_label=data.multi_label)
|
|
|
10 |
|
11 |
gradio_interface = gradio.Interface(
|
12 |
fn = zero_shot_classification,
|
13 |
+
inputs = "text",
|
14 |
outputs = "json"
|
15 |
)
|
16 |
gradio_interface.launch()
|