Koshti10 commited on
Commit
4d1312b
·
verified ·
1 Parent(s): 5ef05d0

Upload 7 files

Browse files
Files changed (2) hide show
  1. app.py +8 -4
  2. src/plot_utils.py +20 -15
app.py CHANGED
@@ -57,7 +57,11 @@ def select_version_df(name):
57
  if v['name'] == name:
58
  return versions_data['dataframes'][i]
59
 
60
-
 
 
 
 
61
  """
62
  MAIN APPLICATION
63
  """
@@ -179,7 +183,7 @@ with hf_app:
179
  show_all = gr.CheckboxGroup(
180
  ["Select All Models"],
181
  label="Show plot for all models 🤖",
182
- value=[],
183
  elem_id="value-select-3",
184
  interactive=True,
185
  )
@@ -188,7 +192,7 @@ with hf_app:
188
  show_names = gr.CheckboxGroup(
189
  ["Show Names"],
190
  label="Show names of models on the plot 🏷️",
191
- value=[],
192
  elem_id="value-select-4",
193
  interactive=True,
194
  )
@@ -224,7 +228,7 @@ with hf_app:
224
  with gr.Row():
225
  with gr.Column():
226
  # Output block for the plot
227
- plot_output = gr.Plot()
228
 
229
  """
230
  PLOT CHANGE ACTIONS
 
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
  """
 
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
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
- fig.update_layout(height=300)
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
- xaxis_title="",
78
- yaxis_title="",
79
- title="% Played v/s Quality Score"
 
 
 
 
 
 
 
 
 
 
 
 
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