Spaces:
Runtime error
Runtime error
Create app_v1.py
Browse files
app_v1.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Hugging Face's logo
|
2 |
+
Hugging Face
|
3 |
+
Search models, datasets, users...
|
4 |
+
Models
|
5 |
+
Datasets
|
6 |
+
Spaces
|
7 |
+
Posts
|
8 |
+
Docs
|
9 |
+
Solutions
|
10 |
+
Pricing
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
Spaces:
|
15 |
+
|
16 |
+
cnealex
|
17 |
+
/
|
18 |
+
demo
|
19 |
+
|
20 |
+
|
21 |
+
like
|
22 |
+
0
|
23 |
+
|
24 |
+
Logs
|
25 |
+
App
|
26 |
+
Files
|
27 |
+
Community
|
28 |
+
Settings
|
29 |
+
demo
|
30 |
+
/
|
31 |
+
app.py
|
32 |
+
|
33 |
+
cnealex's picture
|
34 |
+
cnealex
|
35 |
+
Update app.py
|
36 |
+
a2ea162
|
37 |
+
VERIFIED
|
38 |
+
about 23 hours ago
|
39 |
+
raw
|
40 |
+
history
|
41 |
+
blame
|
42 |
+
edit
|
43 |
+
delete
|
44 |
+
No virus
|
45 |
+
1.56 kB
|
46 |
+
from transformers import pipeline
|
47 |
+
import gradio as gr
|
48 |
+
|
49 |
+
def coding(model, text, codetext):
|
50 |
+
classifier = pipeline("zero-shot-classification", model=model)
|
51 |
+
codelist = codetext.split(';')
|
52 |
+
output = classifier(text, codelist, multi_label=True)
|
53 |
+
return output
|
54 |
+
|
55 |
+
iface = gr.Interface(
|
56 |
+
fn=coding,
|
57 |
+
inputs=[
|
58 |
+
gr.Radio(
|
59 |
+
[
|
60 |
+
"facebook/bart-large-mnli",
|
61 |
+
"MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli",
|
62 |
+
"MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7",
|
63 |
+
"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
|
64 |
+
"MoritzLaurer/deberta-v3-large-zeroshot-v2.0",
|
65 |
+
#"joeddav/xlm-roberta-large-xnli"
|
66 |
+
],
|
67 |
+
#min_width=200,
|
68 |
+
#scale=2,
|
69 |
+
value="facebook/bart-large-mnli",
|
70 |
+
label="Model"
|
71 |
+
),
|
72 |
+
gr.TextArea(
|
73 |
+
label='Comment',
|
74 |
+
value='感覺性格溫和,適合香港人,特別係亞洲人的肌膚,不足之處就是感覺很少有優惠,價錢都比較貴'
|
75 |
+
),
|
76 |
+
gr.Textbox(
|
77 |
+
label='Code list (colon-separated)',
|
78 |
+
value='非常好/很好/好滿意;價錢合理/實惠/不太貴/親民/價格適中/價格便宜/價錢大眾化;價錢貴/不合理/比日本台灣貴/可以再平d'
|
79 |
+
)
|
80 |
+
],
|
81 |
+
outputs=[
|
82 |
+
#gr.Textbox(label='Result')
|
83 |
+
gr.JSON()
|
84 |
+
#gr.BarPlot()
|
85 |
+
],
|
86 |
+
title="NuanceTree Coding Test",
|
87 |
+
description="Test Zero-Shot Classification",
|
88 |
+
allow_flagging='never'
|
89 |
+
)
|
90 |
+
|
91 |
+
iface.launch()
|
92 |
+
|