Jellyfish042 commited on
Commit
5cd2be1
1 Parent(s): ed92462
Files changed (1) hide show
  1. app.py +28 -24
app.py CHANGED
@@ -120,7 +120,6 @@ def get_folders_matching_format(directory):
120
 
121
 
122
  def get_unique_column_names(all_data):
123
-
124
  # column_names = {}
125
  #
126
  # for folder_name, files in all_data.items():
@@ -132,7 +131,12 @@ def get_unique_column_names(all_data):
132
  #
133
  # return list(column_names.keys())
134
 
135
- return ['ao3_\u200benglish', 'bbc_\u200bnews', 'wikipedia_\u200benglish', 'arxiv_\u200bcomputer_\u200bscience', 'arxiv_\u200bphysics', 'github_\u200bcpp', 'github_\u200bpython']
 
 
 
 
 
136
 
137
 
138
  def update_table(period: str,
@@ -177,7 +181,8 @@ def update_table(period: str,
177
  if 'Average' in color_columns:
178
  target_color_columns.append('Average (lower=better)')
179
  if 'Individual Tests' in color_columns:
180
- target_color_columns.extend([col for col in filtered_data.columns if col not in ['Name', 'Parameters Count (B)', 'Average (lower=better)']])
 
181
 
182
  # styler = filtered_data.style.format(formatter).background_gradient(
183
  # cmap=cmap,
@@ -187,28 +192,26 @@ def update_table(period: str,
187
  # ).apply(color_column, subset=['Parameters Count (B)'])
188
 
189
  # for better visualization
190
- second_largest = filtered_data['Average (lower=better)'].nlargest(2).iloc[-1]
191
- min_value = filtered_data['Average (lower=better)'].min().min()
192
- if len(models) == 1 and '~7B' in models:
193
- max_value = second_largest
194
- else:
195
- max_value = filtered_data['Average (lower=better)'].max().max()
196
-
197
- specific_column = 'Average (lower=better)'
 
198
 
199
- styler_specific = filtered_data.style.background_gradient(
200
- cmap=cmap,
201
- subset=[specific_column],
202
- vmin=min_value,
203
- vmax=max_value
204
- )
205
-
206
- styler_other = filtered_data.style.background_gradient(
207
- cmap=cmap,
208
- subset=[col for col in target_color_columns if col != specific_column]
209
- )
210
 
211
- styler = styler_specific.use(styler_other.export()).format(formatter).apply(color_column, subset=['Parameters Count (B)'])
 
 
212
 
213
  return styler
214
  else:
@@ -307,7 +310,8 @@ with gr.Blocks(css=css) as demo:
307
  choices=get_unique_column_names(all_data),
308
  value=get_unique_column_names(all_data))
309
 
310
- table = gr.Dataframe(initial_data, column_widths=[125, 50, 50, 35, 35, 35, 35, 35, 35, 35], wrap=True)
 
311
 
312
  period_selector.change(update_table,
313
  inputs=[period_selector, model_selector, metric_selector, colfilter, color_selector],
 
120
 
121
 
122
  def get_unique_column_names(all_data):
 
123
  # column_names = {}
124
  #
125
  # for folder_name, files in all_data.items():
 
131
  #
132
  # return list(column_names.keys())
133
 
134
+ return ['ao3_\u200benglish', 'bbc_\u200bnews', 'wikipedia_\u200benglish', 'arxiv_\u200bcomputer_\u200bscience',
135
+ 'arxiv_\u200bphysics', 'github_\u200bcpp', 'github_\u200bpython']
136
+
137
+
138
+ def color_cell(value):
139
+ return 'background-color: #fffdd0' if pd.notna(value) else 'default'
140
 
141
 
142
  def update_table(period: str,
 
181
  if 'Average' in color_columns:
182
  target_color_columns.append('Average (lower=better)')
183
  if 'Individual Tests' in color_columns:
184
+ target_color_columns.extend([col for col in filtered_data.columns if
185
+ col not in ['Name', 'Parameters Count (B)', 'Average (lower=better)']])
186
 
187
  # styler = filtered_data.style.format(formatter).background_gradient(
188
  # cmap=cmap,
 
192
  # ).apply(color_column, subset=['Parameters Count (B)'])
193
 
194
  # for better visualization
195
+ vmin = {}
196
+ vmax = {}
197
+ for column in filtered_data.columns:
198
+ if column in ['Name', 'Parameters Count (B)']:
199
+ continue
200
+ col_values = filtered_data[column]
201
+ second_largest = col_values.nlargest(2).iloc[-1]
202
+ vmin[column] = col_values.min()
203
+ vmax[column] = second_largest
204
 
205
+ target_color_columns = []
206
+ if 'Average' in color_columns:
207
+ target_color_columns.append('Average (lower=better)')
208
+ if 'Individual Tests' in color_columns:
209
+ target_color_columns.extend([col for col in filtered_data.columns if
210
+ col not in ['Name', 'Parameters Count (B)', 'Average (lower=better)']])
 
 
 
 
 
211
 
212
+ styler = filtered_data.style.format(formatter).map(color_cell, subset=['Parameters Count (B)'])
213
+ for column in target_color_columns:
214
+ styler = styler.background_gradient(cmap=cmap, subset=[column], vmin=vmin[column], vmax=vmax[column])
215
 
216
  return styler
217
  else:
 
310
  choices=get_unique_column_names(all_data),
311
  value=get_unique_column_names(all_data))
312
 
313
+ table = gr.Dataframe(initial_data, column_widths=[125, 50, 50, 35, 35, 35, 35, 35, 35, 35], wrap=True,
314
+ height=750)
315
 
316
  period_selector.change(update_table,
317
  inputs=[period_selector, model_selector, metric_selector, colfilter, color_selector],