sherzod-hakimov commited on
Commit
0d8f76e
·
verified ·
1 Parent(s): 7c7367d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -17,13 +17,13 @@ CONSTANTS
17
  # For restarting the gradio application every 24 Hrs
18
  TIME = 43200 # in seconds # Reload will not work locally - requires HFToken # The app launches locally as expected - only without the reload utility
19
 
20
-
21
  """
22
  AUTO RESTART HF SPACE
23
  """
24
  HF_TOKEN = os.environ.get("H4_TOKEN", None)
25
  api = HfApi()
26
 
 
27
  def restart_space():
28
  api.restart_space(repo_id=HF_REPO, token=HF_TOKEN)
29
 
@@ -40,7 +40,6 @@ multimodal_leaderboard = github_data["multimodal"]["dataframes"][0] # Get the l
40
  text_leaderboard = text_leaderboard.iloc[:, :4]
41
  multimodal_leaderboard = multimodal_leaderboard.iloc[:, :4]
42
 
43
-
44
  """
45
  VERSIONS UTILS
46
  """
@@ -51,17 +50,23 @@ version_names = [v['name'] for v in versions_data['versions']]
51
 
52
  global version_df
53
  version_df = versions_data['dataframes'][0]
 
 
54
  def select_version_df(name):
55
  for i, v in enumerate(versions_data['versions']):
56
  if v['name'] == name:
57
  return versions_data['dataframes'][i]
58
 
 
 
 
 
 
59
  """
60
  MAIN APPLICATION
61
  """
62
  hf_app = gr.Blocks()
63
  with hf_app:
64
-
65
  gr.HTML(TITLE)
66
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
67
 
@@ -178,7 +183,7 @@ with hf_app:
178
  show_all = gr.CheckboxGroup(
179
  ["Select All Models"],
180
  label="Show plot for all models 🤖",
181
- value=[],
182
  elem_id="value-select-3",
183
  interactive=True,
184
  )
@@ -187,7 +192,7 @@ with hf_app:
187
  show_names = gr.CheckboxGroup(
188
  ["Show Names"],
189
  label="Show names of models on the plot 🏷️",
190
- value=[],
191
  elem_id="value-select-4",
192
  interactive=True,
193
  )
@@ -223,7 +228,7 @@ with hf_app:
223
  with gr.Row():
224
  with gr.Column():
225
  # Output block for the plot
226
- plot_output = gr.Plot()
227
 
228
  """
229
  PLOT CHANGE ACTIONS
@@ -343,13 +348,14 @@ with hf_app:
343
  """
344
  with gr.TabItem("📈Trends", elem_id="trends-tab", id=3):
345
  with gr.Row():
346
- mkd_text = gr.Markdown("### Commercial v/s Open-Weight models - clemscore over time. The size of the circles represents the scaled value of the parameters of the models. Larger circles indicate higher parameter values.")
347
-
 
348
  with gr.Row():
349
  with gr.Column(scale=3):
350
  trend_select = gr.Dropdown(
351
  choices=["Text", "Multimodal"],
352
- value=None,
353
  label="Select Benchmark 🔍",
354
  elem_id="value-select-7",
355
  interactive=True,
@@ -364,7 +370,10 @@ with hf_app:
364
  )
365
 
366
  with gr.Row():
367
- trend_plot = gr.Plot(show_label=False)
 
 
 
368
 
369
  trend_select.change(
370
  get_final_trend_plot,
@@ -379,8 +388,7 @@ with hf_app:
379
  [trend_plot],
380
  queue=True
381
  )
382
-
383
-
384
  """
385
  ####################### FIFTH TAB - VERSIONS AND DETAILS #######################
386
  """
 
17
  # For restarting the gradio application every 24 Hrs
18
  TIME = 43200 # in seconds # Reload will not work locally - requires HFToken # The app launches locally as expected - only without the reload utility
19
 
 
20
  """
21
  AUTO RESTART HF SPACE
22
  """
23
  HF_TOKEN = os.environ.get("H4_TOKEN", None)
24
  api = HfApi()
25
 
26
+
27
  def restart_space():
28
  api.restart_space(repo_id=HF_REPO, token=HF_TOKEN)
29
 
 
40
  text_leaderboard = text_leaderboard.iloc[:, :4]
41
  multimodal_leaderboard = multimodal_leaderboard.iloc[:, :4]
42
 
 
43
  """
44
  VERSIONS UTILS
45
  """
 
50
 
51
  global version_df
52
  version_df = versions_data['dataframes'][0]
53
+
54
+
55
  def select_version_df(name):
56
  for i, v in enumerate(versions_data['versions']):
57
  if v['name'] == name:
58
  return versions_data['dataframes'][i]
59
 
60
+ models_list = text_leaderboard.iloc[:, 0].unique().tolist()
61
+ open_models, commercial_models = split_models(models_list)
62
+ initial_plot = plotly_plot(df=text_leaderboard, list_op=open_models, list_co=commercial_models,
63
+ show_all=["Show All Models"], show_names=["Show Names"], show_legend=[],
64
+ mobile_view=[], custom_width=1200)
65
  """
66
  MAIN APPLICATION
67
  """
68
  hf_app = gr.Blocks()
69
  with hf_app:
 
70
  gr.HTML(TITLE)
71
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
72
 
 
183
  show_all = gr.CheckboxGroup(
184
  ["Select All Models"],
185
  label="Show plot for all models 🤖",
186
+ value="Select All Models",
187
  elem_id="value-select-3",
188
  interactive=True,
189
  )
 
192
  show_names = gr.CheckboxGroup(
193
  ["Show Names"],
194
  label="Show names of models on the plot 🏷️",
195
+ value="Show Names",
196
  elem_id="value-select-4",
197
  interactive=True,
198
  )
 
228
  with gr.Row():
229
  with gr.Column():
230
  # Output block for the plot
231
+ plot_output = gr.Plot(initial_plot)
232
 
233
  """
234
  PLOT CHANGE ACTIONS
 
348
  """
349
  with gr.TabItem("📈Trends", elem_id="trends-tab", id=3):
350
  with gr.Row():
351
+ mkd_text = gr.Markdown(
352
+ "### Commercial v/s Open-Weight models - clemscore over time. The size of the circles represents the scaled value of the parameters of the models. Larger circles indicate higher parameter values.")
353
+
354
  with gr.Row():
355
  with gr.Column(scale=3):
356
  trend_select = gr.Dropdown(
357
  choices=["Text", "Multimodal"],
358
+ value="Text",
359
  label="Select Benchmark 🔍",
360
  elem_id="value-select-7",
361
  interactive=True,
 
370
  )
371
 
372
  with gr.Row():
373
+ trend_plot = gr.Plot(get_final_trend_plot(benchmark="Text",
374
+ mobile_view=False,
375
+ custom_width=1200),
376
+ show_label=False)
377
 
378
  trend_select.change(
379
  get_final_trend_plot,
 
388
  [trend_plot],
389
  queue=True
390
  )
391
+
 
392
  """
393
  ####################### FIFTH TAB - VERSIONS AND DETAILS #######################
394
  """