Spaces:
Running
Running
Commit
·
b20457b
1
Parent(s):
e500b12
Add average of averages
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
|
|
4 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
5 |
from css_html_js import custom_css, trigger_plot
|
6 |
from parse import read_json, read_data
|
7 |
-
from utils import model_hyperlink, filter_RTLRepo, filter_bench, handle_special_cases
|
8 |
from typing import Union
|
9 |
from about import CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT
|
10 |
import numpy as np
|
@@ -13,15 +13,19 @@ import plotly.express as px
|
|
13 |
from gradio.themes.utils import colors
|
14 |
|
15 |
def filter_leaderboard(benchmark, model_type, search_query, max_params):
|
16 |
-
subset = df
|
|
|
|
|
17 |
if model_type != 'All':
|
18 |
subset = subset[subset['Model Type'] == model_type]
|
19 |
if search_query:
|
20 |
subset = subset[subset['Model'].str.contains(search_query, case=False, na=False)]
|
21 |
max_params = float(max_params)
|
22 |
subset = subset[subset['Params'] <= max_params]
|
23 |
-
|
24 |
-
if benchmark == '
|
|
|
|
|
25 |
return filter_RTLRepo(subset)
|
26 |
else:
|
27 |
return filter_bench(subset)
|
@@ -93,6 +97,7 @@ function refresh() {
|
|
93 |
|
94 |
with gr.Blocks(css=custom_css, js=js_func, theme=gr.themes.Default(primary_hue=colors.emerald)) as app:
|
95 |
df, benchmarks, metrics, default_metric = read_data()
|
|
|
96 |
# gr.Markdown("""# TuRTLe 🐢 Model Leaderboard""")
|
97 |
gr.HTML("""
|
98 |
<p align="center" style="margin-bottom: -10px;">
|
|
|
4 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
5 |
from css_html_js import custom_css, trigger_plot
|
6 |
from parse import read_json, read_data
|
7 |
+
from utils import model_hyperlink, filter_RTLRepo, filter_bench, filter_bench_all, handle_special_cases
|
8 |
from typing import Union
|
9 |
from about import CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT
|
10 |
import numpy as np
|
|
|
13 |
from gradio.themes.utils import colors
|
14 |
|
15 |
def filter_leaderboard(benchmark, model_type, search_query, max_params):
|
16 |
+
subset = df.copy()
|
17 |
+
if benchmark != 'All':
|
18 |
+
subset = df[df['Benchmark'] == benchmark]
|
19 |
if model_type != 'All':
|
20 |
subset = subset[subset['Model Type'] == model_type]
|
21 |
if search_query:
|
22 |
subset = subset[subset['Model'].str.contains(search_query, case=False, na=False)]
|
23 |
max_params = float(max_params)
|
24 |
subset = subset[subset['Params'] <= max_params]
|
25 |
+
|
26 |
+
if benchmark == 'All':
|
27 |
+
return filter_bench_all(subset)
|
28 |
+
elif benchmark == 'RTL-Repo':
|
29 |
return filter_RTLRepo(subset)
|
30 |
else:
|
31 |
return filter_bench(subset)
|
|
|
97 |
|
98 |
with gr.Blocks(css=custom_css, js=js_func, theme=gr.themes.Default(primary_hue=colors.emerald)) as app:
|
99 |
df, benchmarks, metrics, default_metric = read_data()
|
100 |
+
benchmarks = ["All"] + benchmarks
|
101 |
# gr.Markdown("""# TuRTLe 🐢 Model Leaderboard""")
|
102 |
gr.HTML("""
|
103 |
<p align="center" style="margin-bottom: -10px;">
|
utils.py
CHANGED
@@ -45,3 +45,23 @@ def filter_bench(subset: pd.DataFrame) -> pd.DataFrame:
|
|
45 |
pivot_df.insert(0, '', range(1, len(pivot_df) + 1))
|
46 |
return pivot_df
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
pivot_df.insert(0, '', range(1, len(pivot_df) + 1))
|
46 |
return pivot_df
|
47 |
|
48 |
+
def filter_bench_all(subset: pd.DataFrame) -> pd.DataFrame:
|
49 |
+
details = subset[['Model', 'Model URL', 'Model Type', 'Params']].drop_duplicates('Model')
|
50 |
+
pivot_df = subset.pivot_table(index='Model', columns='Metric', values='Score', aggfunc='mean').reset_index().round(2)
|
51 |
+
pivot_df['🐢 Score (Avg of all) ⬆️'] = pivot_df.mean(axis=1, numeric_only=True).round(2)
|
52 |
+
pivot_df = pd.merge(pivot_df, details, on='Model', how='left')
|
53 |
+
pivot_df['Model'] = pivot_df.apply(lambda row: model_hyperlink(row["Model URL"], row["Model"]), axis=1)
|
54 |
+
pivot_df['Type'] = pivot_df['Model Type'].map(lambda x: type_emoji.get(x, ""))
|
55 |
+
pivot_df.rename(columns={
|
56 |
+
'Syntax (STX)': 'Avg STX',
|
57 |
+
'Functionality (FNC)': 'Avg FNC',
|
58 |
+
'Synthesis (SYN)': 'Avg SYN',
|
59 |
+
'Power': 'Avg Power',
|
60 |
+
'Performance': 'Avg Perf',
|
61 |
+
'Area': 'Avg Area',
|
62 |
+
}, inplace=True)
|
63 |
+
columns_order = ['Type', 'Model', 'Params', '🐢 Score (Avg of all) ⬆️', 'Avg STX', 'Avg FNC', 'Avg SYN', 'Avg Power', 'Avg Perf', 'Avg Area']
|
64 |
+
pivot_df = pivot_df[[col for col in columns_order if col in pivot_df.columns]]
|
65 |
+
pivot_df = pivot_df.sort_values(by='🐢 Score (Avg of all) ⬆️', ascending=False).reset_index(drop=True)
|
66 |
+
pivot_df.insert(0, '', range(1, len(pivot_df) + 1))
|
67 |
+
return pivot_df
|