Commit
•
38f4369
1
Parent(s):
903948a
Replace Gradio Dataframe with HTML table
Browse files- app.py +54 -23
- requirements.txt +2 -0
app.py
CHANGED
@@ -18,6 +18,22 @@ EXCLUDED_RESULTS_LEADERBOARDS_KEYS = {
|
|
18 |
"alias",
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
fs = HfFileSystem()
|
22 |
|
23 |
|
@@ -92,11 +108,23 @@ def filter_configs(df):
|
|
92 |
|
93 |
|
94 |
def concat_result_1(result_1, results):
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
|
98 |
def concat_result_2(result_2, results):
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
|
102 |
def render_result_1(model_id, *results):
|
@@ -127,29 +155,32 @@ with gr.Blocks(fill_height=True) as demo:
|
|
127 |
results = []
|
128 |
with gr.Row():
|
129 |
with gr.Tab("All"):
|
130 |
-
results.append(gr.Dataframe(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
))
|
|
|
137 |
with gr.Tab("Results"):
|
138 |
-
results.append(gr.Dataframe(
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
))
|
|
|
145 |
with gr.Tab("Configs"):
|
146 |
-
results.append(gr.Dataframe(
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
))
|
|
|
153 |
|
154 |
load_btn_1.click(
|
155 |
fn=render_result_1,
|
|
|
18 |
"alias",
|
19 |
}
|
20 |
|
21 |
+
DEFAULT_HTML_TABLE = """
|
22 |
+
<table>
|
23 |
+
<thead>
|
24 |
+
<tr>
|
25 |
+
<th>Parameters</th>
|
26 |
+
<th>Model-1</th>
|
27 |
+
<th>Model-2</th>
|
28 |
+
</tr>
|
29 |
+
</thead>
|
30 |
+
<tbody>
|
31 |
+
</tbody>
|
32 |
+
</table>
|
33 |
+
"""
|
34 |
+
|
35 |
+
latest_result_path_per_model = filter_latest_result_path_per_model(fetch_result_paths())
|
36 |
+
|
37 |
fs = HfFileSystem()
|
38 |
|
39 |
|
|
|
108 |
|
109 |
|
110 |
def concat_result_1(result_1, results):
|
111 |
+
results = pd.read_html(results)[0]
|
112 |
+
return (
|
113 |
+
pd.concat([result_1, results.iloc[:, [0, 2]].set_index("Parameters")], axis=1)
|
114 |
+
.reset_index()
|
115 |
+
.fillna("")
|
116 |
+
.to_html(index=False)
|
117 |
+
)
|
118 |
|
119 |
|
120 |
def concat_result_2(result_2, results):
|
121 |
+
results = pd.read_html(results)[0]
|
122 |
+
return (
|
123 |
+
pd.concat([results.iloc[:, [0, 1]].set_index("Parameters"), result_2], axis=1)
|
124 |
+
.reset_index()
|
125 |
+
.fillna("")
|
126 |
+
.to_html(index=False)
|
127 |
+
)
|
128 |
|
129 |
|
130 |
def render_result_1(model_id, *results):
|
|
|
155 |
results = []
|
156 |
with gr.Row():
|
157 |
with gr.Tab("All"):
|
158 |
+
# results.append(gr.Dataframe(
|
159 |
+
# label="Results",
|
160 |
+
# headers=["Parameters", "Model-1", "Model-2"],
|
161 |
+
# interactive=False,
|
162 |
+
# column_widths=["30%", "30%", "30%"],
|
163 |
+
# wrap=True,
|
164 |
+
# ))
|
165 |
+
results.append(gr.HTML(value=DEFAULT_HTML_TABLE))
|
166 |
with gr.Tab("Results"):
|
167 |
+
# results.append(gr.Dataframe(
|
168 |
+
# label="Results",
|
169 |
+
# headers=["Parameters", "Model-1", "Model-2"],
|
170 |
+
# interactive=False,
|
171 |
+
# column_widths=["30%", "30%", "30%"],
|
172 |
+
# wrap=True,
|
173 |
+
# ))
|
174 |
+
results.append(gr.HTML(value=DEFAULT_HTML_TABLE))
|
175 |
with gr.Tab("Configs"):
|
176 |
+
# results.append(gr.Dataframe(
|
177 |
+
# label="Results",
|
178 |
+
# headers=["Parameters", "Model-1", "Model-2"],
|
179 |
+
# interactive=False,
|
180 |
+
# column_widths=["30%", "30%", "30%"],
|
181 |
+
# wrap=True,
|
182 |
+
# ))
|
183 |
+
results.append(gr.HTML(value=DEFAULT_HTML_TABLE))
|
184 |
|
185 |
load_btn_1.click(
|
186 |
fn=render_result_1,
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
lxml
|
2 |
+
|