zhuohan-7 commited on
Commit
f3cadf1
·
verified ·
1 Parent(s): 9d76dc2

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. app/content.py +1 -1
  2. app/draw_diagram.py +78 -52
  3. app/pages.py +1 -1
  4. app/show_examples.py +69 -51
app/content.py CHANGED
@@ -15,7 +15,7 @@ sqa_datasets = {'CN-College-Listen-MCQ-Test': 'Chinese College English Listening
15
  'DREAM-TTS-MCQ-Test': 'DREAM dataset for spoken question-answering, derived from textual data and synthesized speech.',
16
  'SLUE-P2-SQA5-Test': 'Spoken Language Understanding Evaluation (SLUE) dataset, part 2, focused on QA tasks.',
17
  'Public-SG-Speech-QA-Test': 'Public dataset for speech-based question answering, gathered from Singapore.',
18
- 'Spoken-Squad-v1': 'Spoken SQuAD dataset, based on the textual SQuAD dataset, converted into audio.'
19
  }
20
 
21
  si_datasets = {'OpenHermes-Audio-Test': 'Test set for spoken instructions. Synthesized from the OpenHermes dataset.',
 
15
  'DREAM-TTS-MCQ-Test': 'DREAM dataset for spoken question-answering, derived from textual data and synthesized speech.',
16
  'SLUE-P2-SQA5-Test': 'Spoken Language Understanding Evaluation (SLUE) dataset, part 2, focused on QA tasks.',
17
  'Public-SG-Speech-QA-Test': 'Public dataset for speech-based question answering, gathered from Singapore.',
18
+ 'Spoken-Squad-Test': 'Spoken SQuAD dataset, based on the textual SQuAD dataset, converted into audio.'
19
  }
20
 
21
  si_datasets = {'OpenHermes-Audio-Test': 'Test set for spoken instructions. Synthesized from the OpenHermes dataset.',
app/draw_diagram.py CHANGED
@@ -51,21 +51,24 @@ def draw(folder_name, category_name, dataset_name, metrics):
51
 
52
  # remap model names
53
  display_model_names = {key.strip() :val.strip() for key, val in zip(info_df['AudioBench'], info_df['Proper Display Name'])}
54
- chart_data['Model'] = chart_data['Model'].map(display_model_names)
55
 
56
  models = st.multiselect("Please choose the model",
57
- sorted(chart_data['Model'].tolist()),
58
- default = sorted(chart_data['Model'].tolist()))
59
 
60
- chart_data = chart_data[chart_data['Model'].isin(models)]
61
 
62
  chart_data = chart_data.sort_values(by=[new_dataset_name], ascending=True).dropna(axis=0)
63
 
 
 
 
64
  if len(chart_data) == 0:
65
  return
66
 
67
- min_value = round(chart_data.iloc[:, 1::].min().min() - 0.1*chart_data.iloc[:, 1::].min().min(), 1)
68
- max_value = round(chart_data.iloc[:, 1::].max().max() + 0.1*chart_data.iloc[:, 1::].max().max(), 1)
69
 
70
  options = {
71
  "title": {"text": f"{display_names[folder_name.upper()]}"},
@@ -82,7 +85,7 @@ def draw(folder_name, category_name, dataset_name, metrics):
82
  "type": "category",
83
  "boundaryGap": True,
84
  "triggerEvent": True,
85
- "data": chart_data['Model'].tolist(),
86
  }
87
  ],
88
  "yAxis": [{"type": "value",
@@ -118,57 +121,80 @@ def draw(folder_name, category_name, dataset_name, metrics):
118
  with st.container():
119
  # st.write("")
120
  st.markdown('##### TABLE')
121
- custom_css = """
122
 
123
- """
124
- st.markdown(custom_css, unsafe_allow_html=True)
125
 
126
  model_link = {key.strip(): val for key, val in zip(info_df['Proper Display Name'], info_df['Link'])}
127
 
128
- s = ''
129
- for model in models:
130
- try:
131
- # <td align="center"><input type="checkbox" name="select"></td>
132
- s += f"""<tr>
133
- <td><a href={model_link[model]}>{model}</a></td>
134
- <td>{chart_data[chart_data['Model'] == model][new_dataset_name].tolist()[0]}</td>
135
- </tr>"""
136
- except:
137
- # print(f"{model} is not in {dataset_name}")
138
- continue
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
- # select all function
141
- select_all_function = """<script>
142
- function toggle(source) {
143
- var checkboxes = document.querySelectorAll('input[type="checkbox"]');
144
- for (var i = 0; i < checkboxes.length; i++) {
145
- if (checkboxes[i] != source)
146
- checkboxes[i].checked = source.checked;
147
- }
148
- }
149
- </script>"""
150
- st.markdown(f"""
151
- <div class="select_all">{select_all_function}</div>
152
- """, unsafe_allow_html=True)
153
-
154
- info_body_details = f"""
155
- <table style="width:80%">
156
- <thead>
157
- <tr style="text-align: center;">
158
- <th style="width:45%">MODEL</th>
159
- <th style="width:45%">{dataset_name}</th>
160
- </tr>
161
- {s}
162
- </thead>
163
- </table>
164
- """
165
- #<th style="width:10%"><input type="checkbox" onclick="toggle(this);"></th>
166
- # html_code = custom_css + select_all_function + info_body_details
167
- # html(html_code, height = 300)
168
 
169
- st.markdown(f"""
170
- <div class="my-data-table">{info_body_details}</div>
171
- """, unsafe_allow_html=True)
172
 
173
 
174
  # st.dataframe(chart_data,
 
51
 
52
  # remap model names
53
  display_model_names = {key.strip() :val.strip() for key, val in zip(info_df['AudioBench'], info_df['Proper Display Name'])}
54
+ chart_data['model_show'] = chart_data['Model'].map(display_model_names)
55
 
56
  models = st.multiselect("Please choose the model",
57
+ sorted(chart_data['model_show'].tolist()),
58
+ default = sorted(chart_data['model_show'].tolist()))
59
 
60
+ chart_data = chart_data[chart_data['model_show'].isin(models)]
61
 
62
  chart_data = chart_data.sort_values(by=[new_dataset_name], ascending=True).dropna(axis=0)
63
 
64
+ # import pdb
65
+ # pdb.set_trace()
66
+
67
  if len(chart_data) == 0:
68
  return
69
 
70
+ min_value = round(min(chart_data.iloc[:, 1]) - 0.1*min(chart_data.iloc[:, 1]), 1)
71
+ max_value = round(max(chart_data.iloc[:, 1]) + 0.1*max(chart_data.iloc[:, 1]), 1)
72
 
73
  options = {
74
  "title": {"text": f"{display_names[folder_name.upper()]}"},
 
85
  "type": "category",
86
  "boundaryGap": True,
87
  "triggerEvent": True,
88
+ "data": chart_data['model_show'].tolist(),
89
  }
90
  ],
91
  "yAxis": [{"type": "value",
 
121
  with st.container():
122
  # st.write("")
123
  st.markdown('##### TABLE')
124
+ # custom_css = """
125
 
126
+ # """
127
+ # st.markdown(custom_css, unsafe_allow_html=True)
128
 
129
  model_link = {key.strip(): val for key, val in zip(info_df['Proper Display Name'], info_df['Link'])}
130
 
131
+ chart_data['model_link'] = chart_data['model_show'].map(model_link)
132
+
133
+ # import pdb
134
+ # pdb.set_trace()
135
+
136
+ st.dataframe(
137
+ chart_data,
138
+ column_config={
139
+ 'model_show': "Model",
140
+ chart_data.columns[1]: {'alignment': 'center'},
141
+ "model_link": st.column_config.LinkColumn(
142
+ "Model Link",
143
+ # # # help="",
144
+ # validate=r"^https://(.*?)$",
145
+ # # max_chars=100,
146
+ # display_text=r"\[(.*?)\]"
147
+ ),
148
+ },
149
+ hide_index=True,
150
+ use_container_width=True
151
+ )
152
+
153
+
154
+ # s = ''
155
+ # for model in models:
156
+ # try:
157
+ # # <td align="center"><input type="checkbox" name="select"></td>
158
+ # s += f"""<tr>
159
+ # <td><a href={model_link[model]}>{model}</a></td>
160
+ # <td>{chart_data[chart_data['Model'] == model][new_dataset_name].tolist()[0]}</td>
161
+ # </tr>"""
162
+ # except:
163
+ # # print(f"{model} is not in {dataset_name}")
164
+ # continue
165
 
166
+ # # select all function
167
+ # select_all_function = """<script>
168
+ # function toggle(source) {
169
+ # var checkboxes = document.querySelectorAll('input[type="checkbox"]');
170
+ # for (var i = 0; i < checkboxes.length; i++) {
171
+ # if (checkboxes[i] != source)
172
+ # checkboxes[i].checked = source.checked;
173
+ # }
174
+ # }
175
+ # </script>"""
176
+ # st.markdown(f"""
177
+ # <div class="select_all">{select_all_function}</div>
178
+ # """, unsafe_allow_html=True)
179
+
180
+ # info_body_details = f"""
181
+ # <table style="width:80%">
182
+ # <thead>
183
+ # <tr style="text-align: center;">
184
+ # <th style="width:45%">MODEL</th>
185
+ # <th style="width:45%">{dataset_name}</th>
186
+ # </tr>
187
+ # {s}
188
+ # </thead>
189
+ # </table>
190
+ # """
191
+ # #<th style="width:10%"><input type="checkbox" onclick="toggle(this);"></th>
192
+ # # html_code = custom_css + select_all_function + info_body_details
193
+ # # html(html_code, height = 300)
194
 
195
+ # st.markdown(f"""
196
+ # <div class="my-data-table">{info_body_details}</div>
197
+ # """, unsafe_allow_html=True)
198
 
199
 
200
  # st.dataframe(chart_data,
app/pages.py CHANGED
@@ -143,7 +143,7 @@ def sqa():
143
 
144
  rest = ['SLUE-P2-SQA5-Test',
145
  'Public-SG-Speech-QA-Test',
146
- 'Spoken-Squad-v1']
147
 
148
  filters_levelone = binary + rest
149
 
 
143
 
144
  rest = ['SLUE-P2-SQA5-Test',
145
  'Public-SG-Speech-QA-Test',
146
+ 'Spoken-Squad-Test']
147
 
148
  filters_levelone = binary + rest
149
 
app/show_examples.py CHANGED
@@ -13,78 +13,94 @@ def show_examples(category_name, dataset_name, model_lists):
13
  st.markdown(f'##### EXAMPLE {index+1}')
14
  col1, col2 = st.columns([0.3, 0.7], vertical_alignment="center")
15
 
16
- with col1:
17
- st.audio(f'{sample_folder}/sample_{index}.wav', format="audio/wav")
18
 
19
- with col2:
20
- with st.container():
21
- custom_css = """
22
- <style>
23
- .my-container-question {
24
- background-color: #F5EEF8;
25
- padding: 10px;
26
- border-radius: 10px;
27
- height: auto;
28
- }
29
- </style>
30
- """
31
- st.markdown(custom_css, unsafe_allow_html=True)
32
 
33
- if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
34
 
35
- choices = dataset[index]['other_attributes']['choices']
36
- if isinstance(choices, str):
37
- choices_text = choices
38
- elif isinstance(choices, list):
39
- choices_text = ' '.join(i for i in choices)
40
 
41
- question_text = f"""<div class="my-container-question">
42
- <p>QUESTION: {dataset[index]['instruction']['text']}</p>
43
- <p>CHOICES: {choices_text}</p>
44
- </div>
45
- """
46
- else:
47
- question_text = f"""<div class="my-container-question">
48
- <p>QUESTION: {dataset[index]['instruction']['text']}</p>
49
- </div>"""
50
 
51
 
52
- st.markdown(question_text, unsafe_allow_html=True)
53
 
54
- with st.container():
55
- custom_css = """
56
- <style>
57
- .my-container-answer {
58
- background-color: #F9EBEA;
59
- padding: 10px;
60
- border-radius: 10px;
61
- height: auto;
62
- }
63
- </style>
64
- """
65
- st.markdown(custom_css, unsafe_allow_html=True)
66
- st.markdown(f"""<div class="my-container-answer">
67
- <p>CORRECT ANSWER: {dataset[index]['answer']['text']}</p>
68
- </div>""", unsafe_allow_html=True)
69
-
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  # st.divider()
72
  with st.container():
73
  custom_css = """
74
  <style>
75
  .my-container-table {
76
- background-color: #F2F3F4;
77
  padding: 10px;
78
  border-radius: 5px;
79
  # height: 50px;
 
80
  }
81
  </style>
82
  """
83
  st.markdown(custom_css, unsafe_allow_html=True)
84
 
85
  model_lists.sort()
86
-
87
- s = ''
 
 
 
 
88
  if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
89
  for model in model_lists:
90
  try:
@@ -107,8 +123,10 @@ def show_examples(category_name, dataset_name, model_lists):
107
  except:
108
  print(f"{model} is not in {dataset_name}")
109
  continue
 
 
110
 
111
- body_details = f"""<table style="width:100%">
112
  <thead>
113
  <tr style="text-align: center;">
114
  <th style="width:20%">MODEL</th>
 
13
  st.markdown(f'##### EXAMPLE {index+1}')
14
  col1, col2 = st.columns([0.3, 0.7], vertical_alignment="center")
15
 
16
+ # with col1:
17
+ st.audio(f'{sample_folder}/sample_{index}.wav', format="audio/wav")
18
 
19
+ # with col2:
20
+ # with st.container():
21
+ # custom_css = """
22
+ # <style>
23
+ # .my-container-question {
24
+ # background-color: #F5EEF8;
25
+ # padding: 10px;
26
+ # border-radius: 10px;
27
+ # height: auto;
28
+ # }
29
+ # </style>
30
+ # """
31
+ # st.markdown(custom_css, unsafe_allow_html=True)
32
 
33
+ # if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
34
 
35
+ # choices = dataset[index]['other_attributes']['choices']
36
+ # if isinstance(choices, str):
37
+ # choices_text = choices
38
+ # elif isinstance(choices, list):
39
+ # choices_text = ' '.join(i for i in choices)
40
 
41
+ # question_text = f"""<div class="my-container-question">
42
+ # <p>QUESTION: {dataset[index]['instruction']['text']}</p>
43
+ # <p>CHOICES: {choices_text}</p>
44
+ # </div>
45
+ # """
46
+ # else:
47
+ # question_text = f"""<div class="my-container-question">
48
+ # <p>QUESTION: {dataset[index]['instruction']['text']}</p>
49
+ # </div>"""
50
 
51
 
52
+ # st.markdown(question_text, unsafe_allow_html=True)
53
 
54
+ # with st.container():
55
+ # custom_css = """
56
+ # <style>
57
+ # .my-container-answer {
58
+ # background-color: #F9EBEA;
59
+ # padding: 10px;
60
+ # border-radius: 10px;
61
+ # height: auto;
62
+ # }
63
+ # </style>
64
+ # """
65
+ # st.markdown(custom_css, unsafe_allow_html=True)
66
+ # st.markdown(f"""<div class="my-container-answer">
67
+ # <p>CORRECT ANSWER: {dataset[index]['answer']['text']}</p>
68
+ # </div>""", unsafe_allow_html=True)
69
+
70
+ if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
71
+
72
+ choices = dataset[index]['other_attributes']['choices']
73
+ if isinstance(choices, str):
74
+ choices_text = choices
75
+ elif isinstance(choices, list):
76
+ choices_text = ' '.join(i for i in choices)
77
+
78
+ question_text = f"""{dataset[index]['instruction']['text']} {choices_text}"""
79
+ else:
80
+ question_text = f"""{dataset[index]['instruction']['text']}"""
81
 
82
  # st.divider()
83
  with st.container():
84
  custom_css = """
85
  <style>
86
  .my-container-table {
87
+ background-color: #cad8e7;
88
  padding: 10px;
89
  border-radius: 5px;
90
  # height: 50px;
91
+ word-wrap: break-word
92
  }
93
  </style>
94
  """
95
  st.markdown(custom_css, unsafe_allow_html=True)
96
 
97
  model_lists.sort()
98
+
99
+ s = f"""<tr>
100
+ <td>Reference</td>
101
+ <td>{question_text}</td>
102
+ <td>{dataset[index]['answer']['text']}</td>
103
+ </tr>"""
104
  if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
105
  for model in model_lists:
106
  try:
 
123
  except:
124
  print(f"{model} is not in {dataset_name}")
125
  continue
126
+ # import pdb
127
+ # pdb.set_trace()
128
 
129
+ body_details = f"""<table style="table-layout: fixed; width:100%">
130
  <thead>
131
  <tr style="text-align: center;">
132
  <th style="width:20%">MODEL</th>