wenjiao commited on
Commit
e1043c1
1 Parent(s): 22b8709

add selected table in chart

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -433,10 +433,16 @@ def init_comparison_data():
433
  global selected_values
434
  return gr.CheckboxGroup(list(selected_values.keys()), value=list(selected_values.keys()))
435
 
 
 
 
 
 
436
  def generate_spider_chart(df, selected_keys):
437
  global selected_values
438
  current_selected_values = [selected_values[key] for key in selected_keys if key in selected_values]
439
  selected_rows = df[df.iloc[:, 1].isin(current_selected_values)]
 
440
 
441
 
442
  fig = go.Figure()
@@ -455,7 +461,7 @@ def generate_spider_chart(df, selected_keys):
455
  showlegend=True
456
  )
457
 
458
- return fig
459
 
460
  leaderboard_df = filter_models(
461
  df=leaderboard_df,
@@ -566,9 +572,11 @@ with demo:
566
 
567
  with Modal(visible=False) as modal:
568
  map = gr.Plot()
 
 
569
 
570
  leaderboard_table.select(select, leaderboard_table, model_comparison)
571
- spider_btn.click(generate_spider_chart, [leaderboard_table, model_comparison], map)
572
  spider_btn.click(lambda: Modal(visible=True), None, modal)
573
  demo.load(init_comparison_data, None, model_comparison)
574
 
 
433
  global selected_values
434
  return gr.CheckboxGroup(list(selected_values.keys()), value=list(selected_values.keys()))
435
 
436
+ def remove_html_tags(value):
437
+ if isinstance(value, str):
438
+ return re.sub(r'<[^>]*>', '', value)
439
+ return value
440
+
441
  def generate_spider_chart(df, selected_keys):
442
  global selected_values
443
  current_selected_values = [selected_values[key] for key in selected_keys if key in selected_values]
444
  selected_rows = df[df.iloc[:, 1].isin(current_selected_values)]
445
+ cleaned_rows = selected_rows.applymap(remove_html_tags)
446
 
447
 
448
  fig = go.Figure()
 
461
  showlegend=True
462
  )
463
 
464
+ return fig,cleaned_rows
465
 
466
  leaderboard_df = filter_models(
467
  df=leaderboard_df,
 
572
 
573
  with Modal(visible=False) as modal:
574
  map = gr.Plot()
575
+ data_table = gr.Dataframe()
576
+ gr.Column([map, data_table])
577
 
578
  leaderboard_table.select(select, leaderboard_table, model_comparison)
579
+ spider_btn.click(generate_spider_chart, [leaderboard_table, model_comparison], [map, data_table])
580
  spider_btn.click(lambda: Modal(visible=True), None, modal)
581
  demo.load(init_comparison_data, None, model_comparison)
582