Spaces:
Build error
Build error
Upload 7 files
Browse files- app.py +9 -3
- requirements.txt +1 -1
- src/plot_utils.py +20 -15
- src/trend_utils.py +18 -14
app.py
CHANGED
|
@@ -54,6 +54,12 @@ def select_version_df(name):
|
|
| 54 |
if v['name'] == name:
|
| 55 |
return versions_data['dataframes'][i]
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
"""
|
| 58 |
MAIN APPLICATION
|
| 59 |
"""
|
|
@@ -126,7 +132,7 @@ with hf_app:
|
|
| 126 |
show_all = gr.CheckboxGroup(
|
| 127 |
["Select All Models"],
|
| 128 |
label="Show plot for all models 🤖",
|
| 129 |
-
value=
|
| 130 |
elem_id="value-select-3",
|
| 131 |
interactive=True,
|
| 132 |
)
|
|
@@ -135,7 +141,7 @@ with hf_app:
|
|
| 135 |
show_names = gr.CheckboxGroup(
|
| 136 |
["Show Names"],
|
| 137 |
label="Show names of models on the plot 🏷️",
|
| 138 |
-
value=
|
| 139 |
elem_id="value-select-4",
|
| 140 |
interactive=True,
|
| 141 |
)
|
|
@@ -171,7 +177,7 @@ with hf_app:
|
|
| 171 |
with gr.Row():
|
| 172 |
with gr.Column():
|
| 173 |
# Output block for the plot
|
| 174 |
-
plot_output = gr.Plot()
|
| 175 |
|
| 176 |
"""
|
| 177 |
PLOT CHANGE ACTIONS
|
|
|
|
| 54 |
if v['name'] == name:
|
| 55 |
return versions_data['dataframes'][i]
|
| 56 |
|
| 57 |
+
|
| 58 |
+
models_list = multimodal_leaderboard.iloc[:, 0].unique().tolist()
|
| 59 |
+
open_models, commercial_models = split_models(models_list)
|
| 60 |
+
initial_plot = plotly_plot(df=multimodal_leaderboard, list_op=open_models, list_co=commercial_models,
|
| 61 |
+
show_all=["Show All Models"], show_names=["Show Names"], show_legend=[],
|
| 62 |
+
mobile_view=[], custom_width=1200)
|
| 63 |
"""
|
| 64 |
MAIN APPLICATION
|
| 65 |
"""
|
|
|
|
| 132 |
show_all = gr.CheckboxGroup(
|
| 133 |
["Select All Models"],
|
| 134 |
label="Show plot for all models 🤖",
|
| 135 |
+
value="Select All Models",
|
| 136 |
elem_id="value-select-3",
|
| 137 |
interactive=True,
|
| 138 |
)
|
|
|
|
| 141 |
show_names = gr.CheckboxGroup(
|
| 142 |
["Show Names"],
|
| 143 |
label="Show names of models on the plot 🏷️",
|
| 144 |
+
value="Show Names",
|
| 145 |
elem_id="value-select-4",
|
| 146 |
interactive=True,
|
| 147 |
)
|
|
|
|
| 177 |
with gr.Row():
|
| 178 |
with gr.Column():
|
| 179 |
# Output block for the plot
|
| 180 |
+
plot_output = gr.Plot(initial_plot)
|
| 181 |
|
| 182 |
"""
|
| 183 |
PLOT CHANGE ACTIONS
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio==
|
| 2 |
pandas==2.2.2
|
| 3 |
plotly==5.18.0
|
| 4 |
apscheduler==3.10.4
|
|
|
|
| 1 |
+
gradio==5.8.0
|
| 2 |
pandas==2.2.2
|
| 3 |
plotly==5.18.0
|
| 4 |
apscheduler==3.10.4
|
src/plot_utils.py
CHANGED
|
@@ -10,7 +10,7 @@ from src.leaderboard_utils import get_github_data
|
|
| 10 |
|
| 11 |
def plotly_plot(df: pd.DataFrame, list_op: list, list_co: list,
|
| 12 |
show_all: list, show_names: list, show_legend: list,
|
| 13 |
-
mobile_view: list):
|
| 14 |
"""
|
| 15 |
Takes in a list of models for a plotly plot
|
| 16 |
Args:
|
|
@@ -62,23 +62,28 @@ def plotly_plot(df: pd.DataFrame, list_op: list, list_co: list,
|
|
| 62 |
fig.update_yaxes(range=[-5, 105])
|
| 63 |
|
| 64 |
if mobile_view:
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
if mobile_view and show_legend:
|
| 68 |
-
fig.update_layout(height=450)
|
| 69 |
-
fig.update_layout(legend=dict(
|
| 70 |
-
yanchor="bottom",
|
| 71 |
-
y=-5.52,
|
| 72 |
-
xanchor="left",
|
| 73 |
-
x=0.01
|
| 74 |
-
))
|
| 75 |
-
|
| 76 |
fig.update_layout(
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
)
|
| 81 |
|
|
|
|
|
|
|
|
|
|
| 82 |
return fig
|
| 83 |
|
| 84 |
|
|
|
|
| 10 |
|
| 11 |
def plotly_plot(df: pd.DataFrame, list_op: list, list_co: list,
|
| 12 |
show_all: list, show_names: list, show_legend: list,
|
| 13 |
+
mobile_view: list, custom_width: int = None):
|
| 14 |
"""
|
| 15 |
Takes in a list of models for a plotly plot
|
| 16 |
Args:
|
|
|
|
| 62 |
fig.update_yaxes(range=[-5, 105])
|
| 63 |
|
| 64 |
if mobile_view:
|
| 65 |
+
# Fix plot dimensions for a cleaner view
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
fig.update_layout(
|
| 67 |
+
height=400, # shorter plot for mobile
|
| 68 |
+
margin=dict(l=10, r=10, t=30, b=40),
|
| 69 |
+
font=dict(size=5),
|
| 70 |
+
legend=dict(font=dict(size=7),
|
| 71 |
+
bgcolor='rgba(255,255,255,0.7)', # semi-transparent white for mobile
|
| 72 |
+
bordercolor='rgba(0,0,0,0.05)',
|
| 73 |
+
yanchor="bottom",
|
| 74 |
+
y=-5.52,
|
| 75 |
+
xanchor="left",
|
| 76 |
+
x=0.01
|
| 77 |
+
),
|
| 78 |
+
xaxis=dict(tickfont=dict(size=7)),
|
| 79 |
+
yaxis=dict(tickfont=dict(size=7)),
|
| 80 |
+
title=dict(font=dict(size=13)),
|
| 81 |
+
|
| 82 |
)
|
| 83 |
|
| 84 |
+
if custom_width:
|
| 85 |
+
fig.update_layout(width=custom_width)
|
| 86 |
+
|
| 87 |
return fig
|
| 88 |
|
| 89 |
|
src/trend_utils.py
CHANGED
|
@@ -274,7 +274,7 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
|
|
| 274 |
)
|
| 275 |
|
| 276 |
fig.update_traces(
|
| 277 |
-
hovertemplate='Model Name: %{customdata[0]}<br>Release Date (Model
|
| 278 |
)
|
| 279 |
|
| 280 |
# Sort dataframes for line plotting
|
|
@@ -305,14 +305,7 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
|
|
| 305 |
# Alternate <br> for benchmark ticks based on date difference (Eg. v1.6, v1.6.5 too close to each other for MM benchmark)
|
| 306 |
benchmark_tick_texts = []
|
| 307 |
for i in range(len(benchmark_tickvals)):
|
| 308 |
-
if i == 0:
|
| 309 |
benchmark_tick_texts.append(f"<br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
|
| 310 |
-
else:
|
| 311 |
-
date_diff = (benchmark_tickvals[i] - benchmark_tickvals[i - 1]).days
|
| 312 |
-
if date_diff <= 75:
|
| 313 |
-
benchmark_tick_texts.append(f"<br><br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
|
| 314 |
-
else:
|
| 315 |
-
benchmark_tick_texts.append(f"<br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
|
| 316 |
fig.update_xaxes(
|
| 317 |
tickvals=filtered_custom_tickvals + benchmark_tickvals, # Use filtered_custom_tickvals
|
| 318 |
ticktext=[f"{date.strftime('%b')}<br>{date.strftime('%y')}" for date in filtered_custom_tickvals] +
|
|
@@ -368,6 +361,22 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
|
|
| 368 |
print("Custom Seting the Width :")
|
| 369 |
fig.update_layout(width=width)
|
| 370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
return fig
|
| 372 |
|
| 373 |
def get_final_trend_plot(mobile_view: bool = False, custom_width: int = 0) -> go.Figure:
|
|
@@ -396,15 +405,10 @@ def get_final_trend_plot(mobile_view: bool = False, custom_width: int = 0) -> go
|
|
| 396 |
|
| 397 |
if mobile_view:
|
| 398 |
height = 450
|
| 399 |
-
width = 375
|
| 400 |
else:
|
| 401 |
height = 1000
|
| 402 |
-
width = None
|
| 403 |
-
|
| 404 |
-
if custom_width:
|
| 405 |
-
width = custom_width
|
| 406 |
|
| 407 |
-
plot_kwargs = {'height': height, 'width':
|
| 408 |
'mobile_view': mobile_view}
|
| 409 |
|
| 410 |
benchmark_ticks = {}
|
|
|
|
| 274 |
)
|
| 275 |
|
| 276 |
fig.update_traces(
|
| 277 |
+
hovertemplate='Model Name: %{customdata[0]}<br>Release Date (Model): %{customdata[1]|%Y-%m-%d}<br>Clemscore: %{customdata[2]}<br>Benchmark Version: %{customdata[3]}<br>'
|
| 278 |
)
|
| 279 |
|
| 280 |
# Sort dataframes for line plotting
|
|
|
|
| 305 |
# Alternate <br> for benchmark ticks based on date difference (Eg. v1.6, v1.6.5 too close to each other for MM benchmark)
|
| 306 |
benchmark_tick_texts = []
|
| 307 |
for i in range(len(benchmark_tickvals)):
|
|
|
|
| 308 |
benchmark_tick_texts.append(f"<br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
fig.update_xaxes(
|
| 310 |
tickvals=filtered_custom_tickvals + benchmark_tickvals, # Use filtered_custom_tickvals
|
| 311 |
ticktext=[f"{date.strftime('%b')}<br>{date.strftime('%y')}" for date in filtered_custom_tickvals] +
|
|
|
|
| 361 |
print("Custom Seting the Width :")
|
| 362 |
fig.update_layout(width=width)
|
| 363 |
|
| 364 |
+
if mobile_view:
|
| 365 |
+
# Fix plot dimensions for a cleaner view
|
| 366 |
+
fig.update_layout(
|
| 367 |
+
height=400, # shorter plot for mobile
|
| 368 |
+
margin=dict(l=10, r=10, t=30, b=40),
|
| 369 |
+
font=dict(size=5),
|
| 370 |
+
legend=dict(font=dict(size=7),
|
| 371 |
+
bgcolor='rgba(255,255,255,0.7)', # semi-transparent white for mobile
|
| 372 |
+
bordercolor='rgba(0,0,0,0.05)'),
|
| 373 |
+
xaxis=dict(tickfont=dict(size=7)),
|
| 374 |
+
yaxis=dict(tickfont=dict(size=7)),
|
| 375 |
+
title=dict(font=dict(size=13)),
|
| 376 |
+
|
| 377 |
+
)
|
| 378 |
+
|
| 379 |
+
|
| 380 |
return fig
|
| 381 |
|
| 382 |
def get_final_trend_plot(mobile_view: bool = False, custom_width: int = 0) -> go.Figure:
|
|
|
|
| 405 |
|
| 406 |
if mobile_view:
|
| 407 |
height = 450
|
|
|
|
| 408 |
else:
|
| 409 |
height = 1000
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
|
| 411 |
+
plot_kwargs = {'height': height, 'width': custom_width, 'open_dip': 0, 'comm_dip': 0,
|
| 412 |
'mobile_view': mobile_view}
|
| 413 |
|
| 414 |
benchmark_ticks = {}
|