cnealex commited on
Commit
8b4a6c9
1 Parent(s): 6fdfc99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -2,6 +2,8 @@ from transformers import pipeline
2
  import gradio as gr
3
  import pandas as pd
4
 
 
 
5
  def coding(model, text, codetext):
6
  classifier = pipeline("zero-shot-classification", model=model)
7
  codelist = codetext.split(';')
@@ -10,19 +12,16 @@ def coding(model, text, codetext):
10
 
11
  def upload_code_list(file):
12
  df = pd.read_excel(file.name, sheet_name='code')
13
- # Join the data in column B using ";" as the delimiter
14
  joined_data = ';'.join(df['label'].astype(str))
15
- #file_paths = [file.name for file in files]
16
-
17
  return joined_data
18
 
 
19
  demo = gr.Blocks()
20
 
21
  with demo:
22
  gr.Markdown(
23
  """
24
- # NuanceTree
25
- Coding test program
26
  """
27
  )
28
 
@@ -35,29 +34,23 @@ with demo:
35
  "MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7",
36
  "MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
37
  "MoritzLaurer/deberta-v3-large-zeroshot-v2.0",
38
- #"joeddav/xlm-roberta-large-xnli"
39
  ],
40
- #min_width=200,
41
- #scale=2,
42
- value="facebook/bart-large-mnli",
43
  label="Model"
44
  )
45
  comment_text = gr.TextArea(
46
  label='Comment',
47
- value='感覺性格溫和,適合香港人,特別係亞洲人的肌膚,不足之處就是感覺很少有優惠,價錢都比較貴'
48
  )
49
- # upload_btn = gr.UploadButton(
50
- # label="Upload the code list file"
51
- # )
52
  codelist_text = gr.Textbox(
53
  label='Code list (colon-separated)',
54
- value='非常好/很好/好滿意;價錢合理/實惠/不太貴/親民/價格適中/價格便宜/價錢大眾化;價錢貴/不合理/比日本台灣貴/可以再平d'
55
  )
56
  with gr.Row():
57
  clear_codelist_btn = gr.ClearButton(value="Clear Code List")
58
  clear_codelist_btn.click(lambda: None, outputs=[codelist_text])
59
  upload_btn = gr.UploadButton(
60
- label="Upload the code list file",
61
  variant='primary'
62
  )
63
  upload_btn.upload(upload_code_list, upload_btn, codelist_text)
 
2
  import gradio as gr
3
  import pandas as pd
4
 
5
+
6
+
7
  def coding(model, text, codetext):
8
  classifier = pipeline("zero-shot-classification", model=model)
9
  codelist = codetext.split(';')
 
12
 
13
  def upload_code_list(file):
14
  df = pd.read_excel(file.name, sheet_name='code')
 
15
  joined_data = ';'.join(df['label'].astype(str))
 
 
16
  return joined_data
17
 
18
+
19
  demo = gr.Blocks()
20
 
21
  with demo:
22
  gr.Markdown(
23
  """
24
+ # NuanceTree Coding Test
 
25
  """
26
  )
27
 
 
34
  "MoritzLaurer/mDeBERTa-v3-base-xnli-multilingual-nli-2mil7",
35
  "MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
36
  "MoritzLaurer/deberta-v3-large-zeroshot-v2.0",
 
37
  ],
38
+ value="MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli",
 
 
39
  label="Model"
40
  )
41
  comment_text = gr.TextArea(
42
  label='Comment',
43
+ value='感覺性格溫和,特別係亞洲人的肌膚,不足之處就是感覺很少有優惠,價錢都比較貴'
44
  )
 
 
 
45
  codelist_text = gr.Textbox(
46
  label='Code list (colon-separated)',
47
+ value='非常好;很好;好滿意;價錢合理;實惠'
48
  )
49
  with gr.Row():
50
  clear_codelist_btn = gr.ClearButton(value="Clear Code List")
51
  clear_codelist_btn.click(lambda: None, outputs=[codelist_text])
52
  upload_btn = gr.UploadButton(
53
+ label="Upload",
54
  variant='primary'
55
  )
56
  upload_btn.upload(upload_code_list, upload_btn, codelist_text)