Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,46 @@
|
|
1 |
-
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
iface
|
8 |
-
iface.launch()
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def coding(model, text, codetext):
|
5 |
+
classifier = pipeline("zero-shot-classification", model=model)
|
6 |
+
codelist = codetext.split(',')
|
7 |
+
output = classifier(text, codelist, multi_label=True)
|
8 |
+
return output
|
9 |
|
10 |
+
iface = gr.Interface(
|
11 |
+
fn=coding,
|
12 |
+
inputs=[
|
13 |
+
gr.Radio(
|
14 |
+
[
|
15 |
+
"facebook/bart-large-mnli",
|
16 |
+
"MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli",
|
17 |
+
"MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7",
|
18 |
+
"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
|
19 |
+
"MoritzLaurer/deberta-v3-large-zeroshot-v2.0",
|
20 |
+
#"joeddav/xlm-roberta-large-xnli"
|
21 |
+
],
|
22 |
+
#min_width=200,
|
23 |
+
#scale=2,
|
24 |
+
value="facebook/bart-large-mnli",
|
25 |
+
label="Model"
|
26 |
+
),
|
27 |
+
gr.TextArea(
|
28 |
+
label='Comment',
|
29 |
+
value='感覺性格溫和,適合香港人,特別係亞洲人的肌膚,不足之處就是感覺很少有優惠,價錢都比較貴'
|
30 |
+
),
|
31 |
+
gr.Textbox(
|
32 |
+
label='Code list',
|
33 |
+
value='非常好/很好/好滿意,價錢合理/實惠/不太貴/親民/價格適中/價格便宜/價錢大眾化,價錢貴/不合理/比日本台灣貴/可以再平d/Sasa 卓悅買會平啲'
|
34 |
+
)
|
35 |
+
],
|
36 |
+
outputs=[
|
37 |
+
#gr.Textbox(label='Result')
|
38 |
+
gr.JSON()
|
39 |
+
#gr.BarPlot()
|
40 |
+
],
|
41 |
+
title="NuanceTree Coding Test",
|
42 |
+
description="Test Zero-Shot Classification",
|
43 |
+
allow_flagging='never'
|
44 |
+
)
|
45 |
|
46 |
+
iface.launch()
|
|