zhuohan-7 commited on
Commit
fb2bc19
1 Parent(s): 1fa71e4

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app/draw_diagram.py +95 -29
app/draw_diagram.py CHANGED
@@ -2,24 +2,24 @@ import streamlit as st
2
  import pandas as pd
3
  import numpy as np
4
  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
  from app.show_examples import *
9
-
10
- links_dic = {}
11
-
12
- links_dic = {k.lower().replace('_', '-') : v for k, v in links_dic.items()}
13
 
14
  # huggingface_image = Image.open('style/huggingface.jpg')
15
 
16
- def nav_to(value):
17
- try:
18
- url = links_dic[str(value).lower()]
19
- js = f'window.open("{url}", "_blank").then(r => window.parent.location.href);'
20
- st_javascript(js)
21
- except:
22
- pass
 
 
 
 
23
 
24
  def draw(folder_name, category_name, dataset_name, metrics):
25
 
@@ -44,7 +44,15 @@ def draw(folder_name, category_name, dataset_name, metrics):
44
  }
45
  </style>
46
  """, unsafe_allow_html=True)
47
- models = st.multiselect("Please choose the model", chart_data['Model'].tolist(), default = chart_data['Model'].tolist())
 
 
 
 
 
 
 
 
48
  chart_data = chart_data[chart_data['Model'].isin(models)]
49
 
50
  chart_data = chart_data.sort_values(by=[new_dataset_name], ascending=True).dropna(axis=0)
@@ -70,7 +78,7 @@ def draw(folder_name, category_name, dataset_name, metrics):
70
  "type": "category",
71
  "boundaryGap": True,
72
  "triggerEvent": True,
73
- "data": chart_data['Model'].tolist(),
74
  }
75
  ],
76
  "yAxis": [{"type": "value",
@@ -92,9 +100,9 @@ def draw(folder_name, category_name, dataset_name, metrics):
92
 
93
  value = st_echarts(options=options, events=events, height="500px")
94
 
95
- if value != None:
96
- # print(value)
97
- nav_to(value)
98
 
99
  # if value != None:
100
  # highlight_table_line(value)
@@ -103,17 +111,75 @@ def draw(folder_name, category_name, dataset_name, metrics):
103
  Show table
104
  '''
105
  # st.divider()
106
- st.write("")
107
- st.markdown('##### TABLE')
108
- # chart_data['Link'] = chart_data['Model'].map(links_dic)
109
- st.dataframe(chart_data,
110
- # column_config = {
111
- # "Link": st.column_config.LinkColumn(
112
- # display_text= st.image(huggingface_image)
113
- # ),
114
- # },
115
- hide_index = True,
116
- use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  '''
118
  show samples
119
  '''
 
2
  import pandas as pd
3
  import numpy as np
4
  from streamlit_echarts import st_echarts
5
+ from streamlit.components.v1 import html
 
6
  # from PIL import Image
7
  from app.show_examples import *
8
+ import pandas as pd
 
 
 
9
 
10
  # huggingface_image = Image.open('style/huggingface.jpg')
11
 
12
+ # other info
13
+ path = "/home/Collaborative_Projects/SpeechEval-Related/leadboard_st_audio/additional_info/Leaderboard-Rename.xlsx"
14
+ info_df = pd.read_excel(path)
15
+
16
+ # def nav_to(value):
17
+ # try:
18
+ # url = links_dic[str(value).lower()]
19
+ # js = f'window.open("{url}", "_blank").then(r => window.parent.location.href);'
20
+ # st_javascript(js)
21
+ # except:
22
+ # pass
23
 
24
  def draw(folder_name, category_name, dataset_name, metrics):
25
 
 
44
  }
45
  </style>
46
  """, unsafe_allow_html=True)
47
+
48
+ # remap model names
49
+ display_model_names = {key.strip() :val.strip() for key, val in zip(info_df['AudioBench'], info_df['Proper Display Name'])}
50
+ chart_data['Model'] = chart_data['Model'].map(display_model_names)
51
+
52
+ models = st.multiselect("Please choose the model",
53
+ chart_data['Model'].tolist(),
54
+ default = chart_data['Model'].tolist())
55
+
56
  chart_data = chart_data[chart_data['Model'].isin(models)]
57
 
58
  chart_data = chart_data.sort_values(by=[new_dataset_name], ascending=True).dropna(axis=0)
 
78
  "type": "category",
79
  "boundaryGap": True,
80
  "triggerEvent": True,
81
+ "data": chart_data['Model'].tolist(),
82
  }
83
  ],
84
  "yAxis": [{"type": "value",
 
100
 
101
  value = st_echarts(options=options, events=events, height="500px")
102
 
103
+ # if value != None:
104
+ # # print(value)
105
+ # nav_to(value)
106
 
107
  # if value != None:
108
  # highlight_table_line(value)
 
111
  Show table
112
  '''
113
  # st.divider()
114
+ with st.container():
115
+ # st.write("")
116
+ st.markdown('##### TABLE')
117
+ custom_css = """
118
+ <style>
119
+ .my-data-table {
120
+ background-color: #FFFFFF;
121
+ padding: 10px;
122
+ border-radius: 5px;
123
+ # height: 50px;
124
+ }
125
+ </style>
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
+ s = ''
132
+ for model in models:
133
+ try:
134
+ s += f"""<tr>
135
+ <td align="center"><input type="checkbox" name="select"></td>
136
+ <td><a href={model_link[model]}>{model}</a></td>
137
+ <td>{chart_data[chart_data['Model'] == model][new_dataset_name].tolist()[0]}</td>
138
+ </tr>"""
139
+ except:
140
+ # print(f"{model} is not in {dataset_name}")
141
+ continue
142
+
143
+ select_function = """<script>
144
+ function toggle(source) {
145
+ var checkboxes = document.querySelectorAll('input[type="checkbox"]');
146
+ for (var i = 0; i < checkboxes.length; i++) {
147
+ if (checkboxes[i] != source)
148
+ checkboxes[i].checked = source.checked;
149
+ }
150
+ }
151
+ </script>"""
152
+
153
+
154
+ info_body_details = select_function + f"""
155
+ <div class="my-data-table">
156
+ <table style="width:100%">
157
+ <thead>
158
+ <tr style="text-align: center;">
159
+ <th style="width:10%"><input type="checkbox" onclick="toggle(this);"></th>
160
+ <th style="width:45%">MODEL</th>
161
+ <th style="width:45%">{dataset_name}</th>
162
+ </tr>
163
+ {s}
164
+ </thead>
165
+ </table>
166
+ </div>
167
+ """
168
+ # html(info_body_details)
169
+
170
+ st.markdown(f"""
171
+ <div class="my-data-table">{info_body_details}</div>
172
+ """, unsafe_allow_html=True)
173
+
174
+
175
+ # st.dataframe(chart_data,
176
+ # # column_config = {
177
+ # # "Link": st.column_config.LinkColumn(
178
+ # # display_text= st.image(huggingface_image)
179
+ # # ),
180
+ # # },
181
+ # hide_index = True,
182
+ # use_container_width=True)
183
  '''
184
  show samples
185
  '''