Upload folder using huggingface_hub
Browse files- app/draw_diagram.py +25 -27
- app/pages.py +7 -4
- app/show_examples.py +99 -0
app/draw_diagram.py
CHANGED
@@ -5,6 +5,7 @@ from streamlit_echarts import st_echarts
|
|
5 |
# from streamlit_echarts import JsCode
|
6 |
from streamlit_javascript import st_javascript
|
7 |
# from PIL import Image
|
|
|
8 |
|
9 |
links_dic = {}
|
10 |
|
@@ -38,27 +39,16 @@ def draw(folder_name, category_name, dataset_name, metrics):
|
|
38 |
# else:
|
39 |
# ascend = False
|
40 |
|
41 |
-
|
42 |
-
chart_data = chart_data[['Model',
|
43 |
|
44 |
-
chart_data = chart_data.sort_values(by=[
|
45 |
|
46 |
if len(chart_data) == 0:
|
47 |
return
|
48 |
|
49 |
min_value = round(chart_data.iloc[:, 1::].min().min() - 0.1, 1)
|
50 |
-
max_value = round(chart_data.iloc[:, 1::].max().max() + 0.1, 1)
|
51 |
-
|
52 |
-
# columns = list(chart_data.columns)[1:]
|
53 |
-
# for col in columns:
|
54 |
-
# series.append(
|
55 |
-
# {
|
56 |
-
# "name": f"{col.replace('_', '-')}",
|
57 |
-
# "type": "line",
|
58 |
-
# "data": chart_data[f'{col}'].tolist(),
|
59 |
-
# }
|
60 |
-
# )
|
61 |
-
|
62 |
|
63 |
options = {
|
64 |
"title": {"text": f"{display_names[folder_name.upper()]}"},
|
@@ -84,9 +74,9 @@ def draw(folder_name, category_name, dataset_name, metrics):
|
|
84 |
# "splitNumber": 10
|
85 |
}],
|
86 |
"series": [{
|
87 |
-
"name": f"{dataset_name
|
88 |
"type": "line",
|
89 |
-
"data": chart_data[f'{
|
90 |
}],
|
91 |
}
|
92 |
|
@@ -103,14 +93,22 @@ def draw(folder_name, category_name, dataset_name, metrics):
|
|
103 |
# if value != None:
|
104 |
# highlight_table_line(value)
|
105 |
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
# chart_data['Link'] = chart_data['Model'].map(links_dic)
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# from streamlit_echarts import JsCode
|
6 |
from streamlit_javascript import st_javascript
|
7 |
# from PIL import Image
|
8 |
+
from app.show_examples import *
|
9 |
|
10 |
links_dic = {}
|
11 |
|
|
|
39 |
# else:
|
40 |
# ascend = False
|
41 |
|
42 |
+
new_dataset_name = dataset_name.replace('-', '_').lower()
|
43 |
+
chart_data = chart_data[['Model', new_dataset_name]]
|
44 |
|
45 |
+
chart_data = chart_data.sort_values(by=[new_dataset_name], ascending=True).dropna(axis=0)
|
46 |
|
47 |
if len(chart_data) == 0:
|
48 |
return
|
49 |
|
50 |
min_value = round(chart_data.iloc[:, 1::].min().min() - 0.1, 1)
|
51 |
+
max_value = round(chart_data.iloc[:, 1::].max().max() + 0.1, 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
options = {
|
54 |
"title": {"text": f"{display_names[folder_name.upper()]}"},
|
|
|
74 |
# "splitNumber": 10
|
75 |
}],
|
76 |
"series": [{
|
77 |
+
"name": f"{dataset_name}",
|
78 |
"type": "line",
|
79 |
+
"data": chart_data[f'{new_dataset_name}'].tolist(),
|
80 |
}],
|
81 |
}
|
82 |
|
|
|
93 |
# if value != None:
|
94 |
# highlight_table_line(value)
|
95 |
|
96 |
+
'''
|
97 |
+
Show table
|
98 |
+
'''
|
99 |
+
# st.divider()
|
100 |
+
with st.expander('TABLE'):
|
101 |
# chart_data['Link'] = chart_data['Model'].map(links_dic)
|
102 |
+
st.dataframe(chart_data,
|
103 |
+
# column_config = {
|
104 |
+
# "Link": st.column_config.LinkColumn(
|
105 |
+
# display_text= st.image(huggingface_image)
|
106 |
+
# ),
|
107 |
+
# },
|
108 |
+
hide_index = True,
|
109 |
+
use_container_width=True)
|
110 |
+
'''
|
111 |
+
show samples
|
112 |
+
'''
|
113 |
+
show_examples(category_name, dataset_name, chart_data['Model'].tolist())
|
114 |
+
|
app/pages.py
CHANGED
@@ -36,9 +36,9 @@ def dashboard():
|
|
36 |
|
37 |
st.markdown("###### :dart: Our Benchmark includes: ")
|
38 |
cols = st.columns(10)
|
39 |
-
cols[1].metric(label="Tasks", value="8"
|
40 |
-
cols[2].metric(label="Datasets", value="26"
|
41 |
-
cols[3].metric(label="Test
|
42 |
|
43 |
# st.markdown("###### :dart: Supported Models and Datasets: ")
|
44 |
|
@@ -53,7 +53,6 @@ def dashboard():
|
|
53 |
# st.data_editor(sup, num_rows="dynamic")
|
54 |
|
55 |
|
56 |
-
|
57 |
st.divider()
|
58 |
with st.container():
|
59 |
st.markdown("##### Citations")
|
@@ -112,6 +111,10 @@ def asr():
|
|
112 |
else:
|
113 |
draw('su', 'ASR', 'LibriSpeech-Test-Clean', 'wer')
|
114 |
|
|
|
|
|
|
|
|
|
115 |
def sqa():
|
116 |
st.title("Speech Question Answering")
|
117 |
|
|
|
36 |
|
37 |
st.markdown("###### :dart: Our Benchmark includes: ")
|
38 |
cols = st.columns(10)
|
39 |
+
cols[1].metric(label="Tasks", value="8") #delta="Tasks", delta_color="off"
|
40 |
+
cols[2].metric(label="Datasets", value="26")
|
41 |
+
cols[3].metric(label="Test Models", value="5")
|
42 |
|
43 |
# st.markdown("###### :dart: Supported Models and Datasets: ")
|
44 |
|
|
|
53 |
# st.data_editor(sup, num_rows="dynamic")
|
54 |
|
55 |
|
|
|
56 |
st.divider()
|
57 |
with st.container():
|
58 |
st.markdown("##### Citations")
|
|
|
111 |
else:
|
112 |
draw('su', 'ASR', 'LibriSpeech-Test-Clean', 'wer')
|
113 |
|
114 |
+
|
115 |
+
## examples
|
116 |
+
|
117 |
+
|
118 |
def sqa():
|
119 |
st.title("Speech Question Answering")
|
120 |
|
app/show_examples.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import datasets
|
3 |
+
import numpy as np
|
4 |
+
import soundfile as sf
|
5 |
+
|
6 |
+
|
7 |
+
def show_examples(category_name, dataset_name, model_lists):
|
8 |
+
st.divider()
|
9 |
+
sample_folder = f"./examples/{category_name}/{dataset_name}"
|
10 |
+
dataset = datasets.load_from_disk(sample_folder)
|
11 |
+
|
12 |
+
for index in range(len(dataset)):
|
13 |
+
|
14 |
+
with st.expander(f'EXAMPLE {index+1}'):
|
15 |
+
col1, col2 = st.columns([0.3, 0.7], vertical_alignment="center")
|
16 |
+
|
17 |
+
with col1:
|
18 |
+
st.audio(f'{sample_folder}/sample_{index}.wav', format="audio/wav")
|
19 |
+
|
20 |
+
with col2:
|
21 |
+
with st.container():
|
22 |
+
custom_css = """
|
23 |
+
<style>
|
24 |
+
.my-container-question {
|
25 |
+
background-color: #F5EEF8;
|
26 |
+
padding: 10px;
|
27 |
+
border-radius: 10px;
|
28 |
+
height: 50px;
|
29 |
+
}
|
30 |
+
</style>
|
31 |
+
"""
|
32 |
+
st.markdown(custom_css, unsafe_allow_html=True)
|
33 |
+
st.markdown(f"""<div class="my-container-question">
|
34 |
+
<p>QUESTION: {dataset[index]['instruction']['text']}</p>
|
35 |
+
</div>""", unsafe_allow_html=True)
|
36 |
+
|
37 |
+
with st.container():
|
38 |
+
custom_css = """
|
39 |
+
<style>
|
40 |
+
.my-container-answer {
|
41 |
+
background-color: #F9EBEA;
|
42 |
+
padding: 10px;
|
43 |
+
border-radius: 10px;
|
44 |
+
height: 50px;
|
45 |
+
}
|
46 |
+
</style>
|
47 |
+
"""
|
48 |
+
st.markdown(custom_css, unsafe_allow_html=True)
|
49 |
+
st.markdown(f"""<div class="my-container-answer">
|
50 |
+
<p>CORRECT ANSWER: {dataset[index]['answer']['text']}</p>
|
51 |
+
</div>""", unsafe_allow_html=True)
|
52 |
+
|
53 |
+
|
54 |
+
st.divider()
|
55 |
+
with st.container():
|
56 |
+
custom_css = """
|
57 |
+
<style>
|
58 |
+
.my-container-table {
|
59 |
+
background-color: #F8F9F9;
|
60 |
+
padding: 10px;
|
61 |
+
border-radius: 5px;
|
62 |
+
# height: 50px;
|
63 |
+
}
|
64 |
+
</style>
|
65 |
+
"""
|
66 |
+
st.markdown(custom_css, unsafe_allow_html=True)
|
67 |
+
|
68 |
+
model_lists.sort()
|
69 |
+
|
70 |
+
s = ''
|
71 |
+
for model in model_lists:
|
72 |
+
try:
|
73 |
+
s += f"""<tr>
|
74 |
+
<td>{model}</td>
|
75 |
+
<td>{dataset[index][model]['text']}</td>
|
76 |
+
<td>{dataset[index][model]['model_prediction']}</td>
|
77 |
+
</tr>"""
|
78 |
+
except:
|
79 |
+
print(f"{model} is not in {dataset_name}")
|
80 |
+
continue
|
81 |
+
|
82 |
+
body_details = f"""<table style="width:100%">
|
83 |
+
<thead>
|
84 |
+
<tr style="text-align: center;">
|
85 |
+
<th style="width:20%">MODEL</th>
|
86 |
+
<th style="width:40%">QUESTION</th>
|
87 |
+
<th style="width:40%">MODEL PREDICTION</th>
|
88 |
+
</tr>
|
89 |
+
{s}
|
90 |
+
</thead>
|
91 |
+
</table>"""
|
92 |
+
|
93 |
+
st.markdown(f"""<div class="my-container-table">
|
94 |
+
{body_details}
|
95 |
+
</div>""", unsafe_allow_html=True)
|
96 |
+
|
97 |
+
# st.markdown(body_details, unsafe_allow_html=True)
|
98 |
+
|
99 |
+
|