wenjiao commited on
Commit
448407e
1 Parent(s): 359bb98

update scattor and modal

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py CHANGED
@@ -45,6 +45,10 @@ from src.tools.plots import (
45
  create_plot_df,
46
  create_scores_df,
47
  )
 
 
 
 
48
 
49
  # Start ephemeral Spaces on PRs (see config in README.md)
50
  #enable_space_ci()
@@ -278,6 +282,35 @@ def filter_models(
278
 
279
  return filtered_df
280
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  leaderboard_df = filter_models(
282
  df=leaderboard_df,
283
  type_query=[t.to_str(" : ") for t in QuantType],
@@ -377,6 +410,12 @@ with demo:
377
  #column_widths=["2%", "33%"]
378
  )
379
 
 
 
 
 
 
 
380
  # Dummy leaderboard for handling the case when the user uses backspace key
381
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
382
  value=original_df[COLS],
@@ -448,7 +487,11 @@ with demo:
448
  [filter_columns_type],
449
  [filter_columns_weightDtype]
450
  )
 
451
 
 
 
 
452
  for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, filter_columns_parameters, hide_models, filter_columns_computeDtype, filter_columns_weightDtype, filter_columns_doubleQuant, filter_columns_groupDtype]:
453
  selector.change(
454
  update_table,
 
45
  create_plot_df,
46
  create_scores_df,
47
  )
48
+ from gradio_modal import Modal
49
+ import plotly.graph_objects as go
50
+
51
+ selected_indices = []
52
 
53
  # Start ephemeral Spaces on PRs (see config in README.md)
54
  #enable_space_ci()
 
282
 
283
  return filtered_df
284
 
285
+ def select(df, data: gr.SelectData):
286
+ global selected_indices
287
+ selected_index = data.index[0]
288
+
289
+ if selected_index in selected_indices:
290
+ selected_indices.remove(selected_index)
291
+ else:
292
+ selected_indices.append(selected_index)
293
+
294
+ fig = go.Figure()
295
+ for i in selected_indices:
296
+ row = df.iloc[i, :]
297
+ fig.add_trace(go.Scatterpolar(
298
+ r=[row['Average ⬆️'], row['ARC-c'], row['ARC-e'], row['Boolq'], row['HellaSwag'], row['Lambada'], row['MMLU'], row['Openbookqa'], row['Piqa'], row['Truthfulqa'], row['Winogrande']],
299
+ theta=['Average ⬆️', 'ARC-c', 'ARC-e', 'Boolq', 'HellaSwag', 'Lambada', 'MMLU', 'Openbookqa', 'Piqa', 'Truthfulqa', 'Winogrande',],
300
+ fill='toself',
301
+ name=str(row['Model'])
302
+ ))
303
+ fig.update_layout(
304
+ polar=dict(
305
+ radialaxis=dict(
306
+ visible=True,
307
+ )),
308
+ showlegend=True
309
+ )
310
+
311
+
312
+ return fig
313
+
314
  leaderboard_df = filter_models(
315
  df=leaderboard_df,
316
  type_query=[t.to_str(" : ") for t in QuantType],
 
410
  #column_widths=["2%", "33%"]
411
  )
412
 
413
+ with Modal(visible=False) as modal:
414
+ map = gr.Plot()
415
+
416
+ leaderboard_table.select(select, leaderboard_table, map)
417
+ leaderboard_table.select(lambda: Modal(visible=True), None, modal)
418
+
419
  # Dummy leaderboard for handling the case when the user uses backspace key
420
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
421
  value=original_df[COLS],
 
487
  [filter_columns_type],
488
  [filter_columns_weightDtype]
489
  )
490
+
491
 
492
+
493
+
494
+
495
  for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, filter_columns_parameters, hide_models, filter_columns_computeDtype, filter_columns_weightDtype, filter_columns_doubleQuant, filter_columns_groupDtype]:
496
  selector.change(
497
  update_table,