KennyUTC commited on
Commit
c4911a9
β€’
1 Parent(s): c48f969

[Feature] Add name filtering

Browse files
Files changed (1) hide show
  1. app.py +37 -4
app.py CHANGED
@@ -51,6 +51,11 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
51
 
52
  headers = ['Rank'] + check_box['essential'] + checkbox_group.value
53
  with gr.Row():
 
 
 
 
 
54
  model_size = gr.CheckboxGroup(
55
  choices=MODEL_SIZE,
56
  value=MODEL_SIZE,
@@ -71,7 +76,7 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
71
  wrap=True,
72
  visible=True)
73
 
74
- def filter_df(fields, model_size, model_type):
75
  filter_list = ['Avg Score', 'Avg Rank', 'OpenSource']
76
  headers = ['Rank'] + check_box['essential'] + fields
77
 
@@ -86,6 +91,15 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
86
  df = df[df['flag']]
87
  df.pop('flag')
88
  df['Rank'] = list(range(1, len(df) + 1))
 
 
 
 
 
 
 
 
 
89
 
90
  comp = gr.components.DataFrame(
91
  value=df[headers],
@@ -97,7 +111,8 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
97
  return comp
98
 
99
  for cbox in [checkbox_group, model_size, model_type]:
100
- cbox.change(fn=filter_df, inputs=[checkbox_group, model_size, model_type], outputs=data_component)
 
101
 
102
  with gr.TabItem('πŸ” About', elem_id='about', id=1):
103
  gr.Markdown(urlopen(VLMEVALKIT_README).read().decode())
@@ -122,6 +137,11 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
122
  s.table['Rank'] = list(range(1, len(s.table) + 1))
123
 
124
  with gr.Row():
 
 
 
 
 
125
  s.model_size = gr.CheckboxGroup(
126
  choices=MODEL_SIZE,
127
  value=MODEL_SIZE,
@@ -143,7 +163,7 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
143
  visible=True)
144
  s.dataset = gr.Textbox(value=dataset, label=dataset, visible=False)
145
 
146
- def filter_df_l2(dataset_name, fields, model_size, model_type):
147
  s = structs[DATASETS.index(dataset_name)]
148
  headers = ['Rank'] + s.check_box['essential'] + fields
149
  df = cp.deepcopy(s.table)
@@ -155,6 +175,15 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
155
  df = df[df['flag']]
156
  df.pop('flag')
157
  df['Rank'] = list(range(1, len(df) + 1))
 
 
 
 
 
 
 
 
 
158
 
159
  comp = gr.components.DataFrame(
160
  value=df[headers],
@@ -168,8 +197,12 @@ with gr.Blocks(title="Open VLM Leaderboard", head=head_style) as demo:
168
  for cbox in [s.checkbox_group, s.model_size, s.model_type]:
169
  cbox.change(
170
  fn=filter_df_l2,
171
- inputs=[s.dataset, s.checkbox_group, s.model_size, s.model_type],
172
  outputs=s.data_component)
 
 
 
 
173
 
174
  with gr.Row():
175
  with gr.Accordion('Citation', open=False):
 
51
 
52
  headers = ['Rank'] + check_box['essential'] + checkbox_group.value
53
  with gr.Row():
54
+ model_name = gr.Textbox(
55
+ value='Input the Model Name (fuzzy, case insensitive)',
56
+ label='Model Name',
57
+ interactive=True,
58
+ visible=True)
59
  model_size = gr.CheckboxGroup(
60
  choices=MODEL_SIZE,
61
  value=MODEL_SIZE,
 
76
  wrap=True,
77
  visible=True)
78
 
79
+ def filter_df(fields, model_name, model_size, model_type):
80
  filter_list = ['Avg Score', 'Avg Rank', 'OpenSource']
81
  headers = ['Rank'] + check_box['essential'] + fields
82
 
 
91
  df = df[df['flag']]
92
  df.pop('flag')
93
  df['Rank'] = list(range(1, len(df) + 1))
94
+ default_val = 'Input the Model Name (fuzzy, case insensitive)'
95
+ if model_name != default_val:
96
+ print(model_name)
97
+ model_name = model_name.lower()
98
+ method_names = [x.split('</a>')[0].split('>')[-1].lower() for x in df['Method']]
99
+ flag = [model_name in name for name in method_names]
100
+ df['TEMP_FLAG'] = flag
101
+ df = df[df['TEMP_FLAG'] == True]
102
+ df.pop('TEMP_FLAG')
103
 
104
  comp = gr.components.DataFrame(
105
  value=df[headers],
 
111
  return comp
112
 
113
  for cbox in [checkbox_group, model_size, model_type]:
114
+ cbox.change(fn=filter_df, inputs=[checkbox_group, model_name, model_size, model_type], outputs=data_component)
115
+ model_name.submit(fn=filter_df, inputs=[checkbox_group, model_name, model_size, model_type], outputs=data_component)
116
 
117
  with gr.TabItem('πŸ” About', elem_id='about', id=1):
118
  gr.Markdown(urlopen(VLMEVALKIT_README).read().decode())
 
137
  s.table['Rank'] = list(range(1, len(s.table) + 1))
138
 
139
  with gr.Row():
140
+ s.model_name = gr.Textbox(
141
+ value='Input the Model Name (fuzzy, case insensitive)',
142
+ label='Model Name',
143
+ interactive=True,
144
+ visible=True)
145
  s.model_size = gr.CheckboxGroup(
146
  choices=MODEL_SIZE,
147
  value=MODEL_SIZE,
 
163
  visible=True)
164
  s.dataset = gr.Textbox(value=dataset, label=dataset, visible=False)
165
 
166
+ def filter_df_l2(dataset_name, fields, model_name, model_size, model_type):
167
  s = structs[DATASETS.index(dataset_name)]
168
  headers = ['Rank'] + s.check_box['essential'] + fields
169
  df = cp.deepcopy(s.table)
 
175
  df = df[df['flag']]
176
  df.pop('flag')
177
  df['Rank'] = list(range(1, len(df) + 1))
178
+ default_val = 'Input the Model Name (fuzzy, case insensitive)'
179
+ if model_name != default_val:
180
+ print(model_name)
181
+ model_name = model_name.lower()
182
+ method_names = [x.split('</a>')[0].split('>')[-1].lower() for x in df['Method']]
183
+ flag = [model_name in name for name in method_names]
184
+ df['TEMP_FLAG'] = flag
185
+ df = df[df['TEMP_FLAG'] == True]
186
+ df.pop('TEMP_FLAG')
187
 
188
  comp = gr.components.DataFrame(
189
  value=df[headers],
 
197
  for cbox in [s.checkbox_group, s.model_size, s.model_type]:
198
  cbox.change(
199
  fn=filter_df_l2,
200
+ inputs=[s.dataset, s.checkbox_group, s.model_name, s.model_size, s.model_type],
201
  outputs=s.data_component)
202
+ s.model_name.submit(
203
+ fn=filter_df_l2,
204
+ inputs=[s.dataset, s.checkbox_group, s.model_name, s.model_size, s.model_type],
205
+ outputs=s.data_component)
206
 
207
  with gr.Row():
208
  with gr.Accordion('Citation', open=False):