Spaces:
Running
on
Zero
Running
on
Zero
Lord-Raven
commited on
Commit
·
e83c60c
1
Parent(s):
19baab4
Trying zero-shot classification.
Browse files
app.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
import gradio
|
2 |
import json
|
3 |
from transformers import pipeline
|
|
|
4 |
|
5 |
def zero_shot_classification(data_string):
|
6 |
print(data_string)
|
7 |
data = json.loads(data_string)
|
8 |
print(data)
|
9 |
-
classifier = pipeline('zero-shot-classification', model='Xenova/mobilebert-uncased-mnli')
|
10 |
|
11 |
-
results = classifier(data.sequence, candidate_labels=data.candidate_labels
|
12 |
return {results}
|
13 |
|
14 |
gradio_interface = gradio.Interface(
|
|
|
1 |
import gradio
|
2 |
import json
|
3 |
from transformers import pipeline
|
4 |
+
from transformers import AutoTokenizer
|
5 |
|
6 |
def zero_shot_classification(data_string):
|
7 |
print(data_string)
|
8 |
data = json.loads(data_string)
|
9 |
print(data)
|
10 |
+
classifier = pipeline(task='zero-shot-classification', tokenizer=AutoTokenizer.from_pretrained('Xenova/mobilebert-uncased-mnli'), model='Xenova/mobilebert-uncased-mnli')
|
11 |
|
12 |
+
results = classifier(data.sequence, candidate_labels=data.candidate_labels) #, hypothesis_template=data.hypothesis_template, multi_label=data.multi_label)
|
13 |
return {results}
|
14 |
|
15 |
gradio_interface = gradio.Interface(
|