Koshti10 commited on
Commit
d886d56
β€’
1 Parent(s): a58897c

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +35 -24
  2. src/plot_utils.py +8 -3
app.py CHANGED
@@ -38,28 +38,24 @@ with main_app:
38
  show_label=False,
39
  elem_id="search-bar",
40
  )
 
 
 
 
 
 
 
 
41
 
42
- with gr.Row():
43
- leaderboard_table = gr.Dataframe(
44
- value=primary_leaderboard_df[0],
45
- elem_id="leaderboard-table",
46
- interactive=False,
47
- visible=True,
48
- height=dataframe_height
49
- )
50
-
51
-
52
- with gr.Row():
53
- gr.HTML(CLEMSCORE_TEXT)
54
 
55
  # Add a dummy leaderboard to handle search queries from the primary_leaderboard_df and not update primary_leaderboard_df
56
- with gr.Row():
57
- dummy_leaderboard_table = gr.Dataframe(
58
- value=primary_leaderboard_df[0],
59
- elem_id="leaderboard-table",
60
- interactive=False,
61
- visible=False
62
- )
63
 
64
  search_bar.submit(
65
  filter_search,
@@ -114,6 +110,14 @@ with main_app:
114
  elem_id="value-select-5",
115
  interactive=True,
116
  )
 
 
 
 
 
 
 
 
117
 
118
  with gr.Row():
119
  dummy_plot_df = gr.DataFrame(
@@ -128,35 +132,42 @@ with main_app:
128
 
129
  open_models_selection.change(
130
  compare_plots,
131
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
132
  plot_output,
133
  queue=True
134
  )
135
 
136
  closed_models_selection.change(
137
  compare_plots,
138
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
139
  plot_output,
140
  queue=True
141
  )
142
 
143
  show_all.change(
144
  compare_plots,
145
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
146
  plot_output,
147
  queue=True
148
  )
149
 
150
  show_names.change(
151
  compare_plots,
152
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
153
  plot_output,
154
  queue=True
155
  )
156
 
157
  show_legend.change(
158
  compare_plots,
159
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
 
 
 
 
 
 
 
160
  plot_output,
161
  queue=True
162
  )
 
38
  show_label=False,
39
  elem_id="search-bar",
40
  )
41
+
42
+ leaderboard_table = gr.Dataframe(
43
+ value=primary_leaderboard_df[0],
44
+ elem_id="leaderboard-table",
45
+ interactive=False,
46
+ visible=True,
47
+ height=dataframe_height
48
+ )
49
 
50
+ gr.HTML(CLEMSCORE_TEXT)
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  # Add a dummy leaderboard to handle search queries from the primary_leaderboard_df and not update primary_leaderboard_df
53
+ dummy_leaderboard_table = gr.Dataframe(
54
+ value=primary_leaderboard_df[0],
55
+ elem_id="leaderboard-table",
56
+ interactive=False,
57
+ visible=False
58
+ )
 
59
 
60
  search_bar.submit(
61
  filter_search,
 
110
  elem_id="value-select-5",
111
  interactive=True,
112
  )
113
+ with gr.Column():
114
+ mobile_view = gr.CheckboxGroup(
115
+ ["Mobile View"],
116
+ label ="View plot on smaller screens πŸ“ˆ ",
117
+ value=[],
118
+ elem_id="value-select-6",
119
+ interactive=True,
120
+ )
121
 
122
  with gr.Row():
123
  dummy_plot_df = gr.DataFrame(
 
132
 
133
  open_models_selection.change(
134
  compare_plots,
135
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
136
  plot_output,
137
  queue=True
138
  )
139
 
140
  closed_models_selection.change(
141
  compare_plots,
142
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
143
  plot_output,
144
  queue=True
145
  )
146
 
147
  show_all.change(
148
  compare_plots,
149
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
150
  plot_output,
151
  queue=True
152
  )
153
 
154
  show_names.change(
155
  compare_plots,
156
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
157
  plot_output,
158
  queue=True
159
  )
160
 
161
  show_legend.change(
162
  compare_plots,
163
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
164
+ plot_output,
165
+ queue=True
166
+ )
167
+
168
+ mobile_view.change(
169
+ compare_plots,
170
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
171
  plot_output,
172
  queue=True
173
  )
src/plot_utils.py CHANGED
@@ -3,7 +3,7 @@ import plotly.express as px
3
 
4
  from src.assets.text_content import SHORT_NAMES
5
 
6
- def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list):
7
  '''
8
  Takes in a list of models for a plotly plot
9
  Args:
@@ -12,6 +12,7 @@ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list):
12
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
13
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
14
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
 
15
  Returns:
16
  Fig: plotly figure
17
  '''
@@ -52,11 +53,14 @@ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list):
52
  fig.update_xaxes(range=[-5, 105])
53
  fig.update_yaxes(range=[-5, 105])
54
 
 
 
 
55
  return fig
56
 
57
 
58
  # ['Model', 'Clemscore', 'All(Played)', 'All(Quality Score)']
59
- def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:list, LEGEND: list):
60
  '''
61
  Quality Score v/s % Played plot by selecting models
62
  Args:
@@ -66,13 +70,14 @@ def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:li
66
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
67
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
68
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
 
69
  Returns:
70
  fig: The plot
71
  '''
72
 
73
  # Combine lists for Open source and commercial models
74
  LIST = LIST1 + LIST2
75
- fig = plotly_plot(df, LIST, ALL, NAMES, LEGEND)
76
 
77
  return fig
78
 
 
3
 
4
  from src.assets.text_content import SHORT_NAMES
5
 
6
+ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list, MOBILE:list ):
7
  '''
8
  Takes in a list of models for a plotly plot
9
  Args:
 
12
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
13
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
14
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
15
+ MOBILE: Either [] or ["Mobile View"] - toggle view to for smaller screens
16
  Returns:
17
  Fig: plotly figure
18
  '''
 
53
  fig.update_xaxes(range=[-5, 105])
54
  fig.update_yaxes(range=[-5, 105])
55
 
56
+ if MOBILE:
57
+ fig.update_layout(height=600)
58
+
59
  return fig
60
 
61
 
62
  # ['Model', 'Clemscore', 'All(Played)', 'All(Quality Score)']
63
+ def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:list, LEGEND: list, MOBILE: list):
64
  '''
65
  Quality Score v/s % Played plot by selecting models
66
  Args:
 
70
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
71
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
72
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
73
+ MOBILE: Either [] or ["Mobile View"] - toggle view to for smaller screens
74
  Returns:
75
  fig: The plot
76
  '''
77
 
78
  # Combine lists for Open source and commercial models
79
  LIST = LIST1 + LIST2
80
+ fig = plotly_plot(df, LIST, ALL, NAMES, LEGEND, MOBILE)
81
 
82
  return fig
83