Spaces:
Running
Running
kennymckormick
commited on
Commit
•
0eff2ef
1
Parent(s):
4980c41
update gradio
Browse files- .pre-commit-config.yaml +33 -0
- README.md +2 -2
- app.py +160 -7
- gen_table.py +196 -0
- meta_data.py +227 -0
- requirements.txt +3 -1
- templates/index.html +0 -35
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
exclude: |
|
2 |
+
(?x)^(
|
3 |
+
meta_data.py
|
4 |
+
)
|
5 |
+
repos:
|
6 |
+
- repo: https://github.com/PyCQA/flake8
|
7 |
+
rev: 5.0.4
|
8 |
+
hooks:
|
9 |
+
- id: flake8
|
10 |
+
args: ["--max-line-length=120", "--ignore=F401,F403,F405,E402"]
|
11 |
+
exclude: ^configs/
|
12 |
+
- repo: https://github.com/PyCQA/isort
|
13 |
+
rev: 5.11.5
|
14 |
+
hooks:
|
15 |
+
- id: isort
|
16 |
+
- repo: https://github.com/pre-commit/mirrors-yapf
|
17 |
+
rev: v0.30.0
|
18 |
+
hooks:
|
19 |
+
- id: yapf
|
20 |
+
args: ["--style={column_limit=120}"]
|
21 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
22 |
+
rev: v3.1.0
|
23 |
+
hooks:
|
24 |
+
- id: trailing-whitespace
|
25 |
+
- id: check-yaml
|
26 |
+
- id: end-of-file-fixer
|
27 |
+
- id: requirements-txt-fixer
|
28 |
+
- id: double-quote-string-fixer
|
29 |
+
- id: check-merge-conflict
|
30 |
+
- id: fix-encoding-pragma
|
31 |
+
args: ["--remove"]
|
32 |
+
- id: mixed-line-ending
|
33 |
+
args: ["--fix=lf"]
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🚀
|
4 |
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: true
|
10 |
license: apache-2.0
|
|
|
1 |
---
|
2 |
+
title: MMBench Leaderboard
|
3 |
emoji: 🚀
|
4 |
colorFrom: blue
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.36.1
|
8 |
app_file: app.py
|
9 |
pinned: true
|
10 |
license: apache-2.0
|
app.py
CHANGED
@@ -1,12 +1,165 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import abc
|
2 |
|
3 |
+
import gradio as gr
|
4 |
|
5 |
+
from gen_table import *
|
6 |
+
from meta_data import *
|
7 |
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
struct = load_results()
|
10 |
+
timestamp = struct['time']
|
11 |
+
EVAL_TIME = format_timestamp(timestamp)
|
12 |
+
results = struct['results']
|
13 |
+
N_MODEL = len(results)
|
14 |
+
N_DATA = len(results['LLaVA-v1.5-7B']) - 1
|
15 |
+
DATASETS = list(results['LLaVA-v1.5-7B'])
|
16 |
+
DATASETS.remove('META')
|
17 |
+
print(DATASETS)
|
18 |
|
19 |
+
gr.Markdown(LEADERBORAD_INTRODUCTION.format(N_MODEL, N_DATA, EVAL_TIME))
|
20 |
+
structs = [abc.abstractproperty() for _ in range(N_DATA)]
|
21 |
|
22 |
+
with gr.Tabs(elem_classes='tab-buttons') as tabs:
|
23 |
+
with gr.TabItem('🏅 OpenVLM Main Leaderboard', elem_id='main', id=0):
|
24 |
+
gr.Markdown(LEADERBOARD_MD['MAIN'])
|
25 |
+
_, check_box = BUILD_L1_DF(results, MAIN_FIELDS)
|
26 |
+
table = generate_table(results, DEFAULT_BENCH)
|
27 |
+
table['Rank'] = list(range(1, len(table) + 1))
|
28 |
+
|
29 |
+
type_map = check_box['type_map']
|
30 |
+
type_map['Rank'] = 'number'
|
31 |
+
|
32 |
+
checkbox_group = gr.CheckboxGroup(
|
33 |
+
choices=check_box['all'],
|
34 |
+
value=check_box['required'],
|
35 |
+
label='Evaluation Dimension',
|
36 |
+
interactive=True,
|
37 |
+
)
|
38 |
+
|
39 |
+
headers = ['Rank'] + check_box['essential'] + checkbox_group.value
|
40 |
+
with gr.Row():
|
41 |
+
model_size = gr.CheckboxGroup(
|
42 |
+
choices=MODEL_SIZE,
|
43 |
+
value=MODEL_SIZE,
|
44 |
+
label='Model Size',
|
45 |
+
interactive=True
|
46 |
+
)
|
47 |
+
model_type = gr.CheckboxGroup(
|
48 |
+
choices=MODEL_TYPE,
|
49 |
+
value=MODEL_TYPE,
|
50 |
+
label='Model Type',
|
51 |
+
interactive=True
|
52 |
+
)
|
53 |
+
data_component = gr.components.DataFrame(
|
54 |
+
value=table[headers],
|
55 |
+
type='pandas',
|
56 |
+
datatype=[type_map[x] for x in headers],
|
57 |
+
interactive=False,
|
58 |
+
visible=True)
|
59 |
+
|
60 |
+
def filter_df(fields, model_size, model_type):
|
61 |
+
filter_list = ['Avg Score', 'Avg Rank', 'OpenSource', 'Verified']
|
62 |
+
headers = ['Rank'] + check_box['essential'] + fields
|
63 |
+
|
64 |
+
new_fields = [field for field in fields if field not in filter_list]
|
65 |
+
df = generate_table(results, new_fields)
|
66 |
+
|
67 |
+
df['flag'] = [model_size_flag(x, model_size) for x in df['Param (B)']]
|
68 |
+
df = df[df['flag']]
|
69 |
+
df.pop('flag')
|
70 |
+
if len(df):
|
71 |
+
df['flag'] = [model_type_flag(df.iloc[i], model_type) for i in range(len(df))]
|
72 |
+
df = df[df['flag']]
|
73 |
+
df.pop('flag')
|
74 |
+
df['Rank'] = list(range(1, len(df) + 1))
|
75 |
+
|
76 |
+
comp = gr.components.DataFrame(
|
77 |
+
value=df[headers],
|
78 |
+
type='pandas',
|
79 |
+
datatype=[type_map[x] for x in headers],
|
80 |
+
interactive=False,
|
81 |
+
visible=True)
|
82 |
+
return comp
|
83 |
+
|
84 |
+
for cbox in [checkbox_group, model_size, model_type]:
|
85 |
+
cbox.change(fn=filter_df, inputs=[checkbox_group, model_size, model_type], outputs=data_component)
|
86 |
+
|
87 |
+
with gr.TabItem('🔍 About', elem_id='about', id=1):
|
88 |
+
gr.Markdown(urlopen(VLMEVALKIT_README).read().decode())
|
89 |
+
|
90 |
+
for i, dataset in enumerate(DATASETS):
|
91 |
+
with gr.TabItem(f'📊 {dataset} Leaderboard', elem_id=dataset, id=i + 2):
|
92 |
+
if dataset in LEADERBOARD_MD:
|
93 |
+
gr.Markdown(LEADERBOARD_MD[dataset])
|
94 |
+
|
95 |
+
s = structs[i]
|
96 |
+
s.table, s.check_box = BUILD_L2_DF(results, dataset)
|
97 |
+
s.type_map = s.check_box['type_map']
|
98 |
+
s.type_map['Rank'] = 'number'
|
99 |
+
|
100 |
+
s.checkbox_group = gr.CheckboxGroup(
|
101 |
+
choices=s.check_box['all'],
|
102 |
+
value=s.check_box['required'],
|
103 |
+
label=f'{dataset} CheckBoxes',
|
104 |
+
interactive=True,
|
105 |
+
)
|
106 |
+
s.headers = ['Rank'] + s.check_box['essential'] + s.checkbox_group.value
|
107 |
+
s.table['Rank'] = list(range(1, len(s.table) + 1))
|
108 |
+
|
109 |
+
with gr.Row():
|
110 |
+
s.model_size = gr.CheckboxGroup(
|
111 |
+
choices=MODEL_SIZE,
|
112 |
+
value=MODEL_SIZE,
|
113 |
+
label='Model Size',
|
114 |
+
interactive=True
|
115 |
+
)
|
116 |
+
s.model_type = gr.CheckboxGroup(
|
117 |
+
choices=MODEL_TYPE,
|
118 |
+
value=MODEL_TYPE,
|
119 |
+
label='Model Type',
|
120 |
+
interactive=True
|
121 |
+
)
|
122 |
+
s.data_component = gr.components.DataFrame(
|
123 |
+
value=s.table[s.headers],
|
124 |
+
type='pandas',
|
125 |
+
datatype=[s.type_map[x] for x in s.headers],
|
126 |
+
interactive=False,
|
127 |
+
visible=True)
|
128 |
+
s.dataset = gr.Textbox(value=dataset, label=dataset, visible=False)
|
129 |
+
|
130 |
+
def filter_df_l2(dataset_name, fields, model_size, model_type):
|
131 |
+
s = structs[DATASETS.index(dataset_name)]
|
132 |
+
headers = ['Rank'] + s.check_box['essential'] + fields
|
133 |
+
df = cp.deepcopy(s.table)
|
134 |
+
df['flag'] = [model_size_flag(x, model_size) for x in df['Param (B)']]
|
135 |
+
df = df[df['flag']]
|
136 |
+
df.pop('flag')
|
137 |
+
if len(df):
|
138 |
+
df['flag'] = [model_type_flag(df.iloc[i], model_type) for i in range(len(df))]
|
139 |
+
df = df[df['flag']]
|
140 |
+
df.pop('flag')
|
141 |
+
df['Rank'] = list(range(1, len(df) + 1))
|
142 |
+
|
143 |
+
comp = gr.components.DataFrame(
|
144 |
+
value=df[headers],
|
145 |
+
type='pandas',
|
146 |
+
datatype=[s.type_map[x] for x in headers],
|
147 |
+
interactive=False,
|
148 |
+
visible=True)
|
149 |
+
return comp
|
150 |
+
|
151 |
+
for cbox in [s.checkbox_group, s.model_size, s.model_type]:
|
152 |
+
cbox.change(
|
153 |
+
fn=filter_df_l2,
|
154 |
+
inputs=[s.dataset, s.checkbox_group, s.model_size, s.model_type],
|
155 |
+
outputs=s.data_component)
|
156 |
+
|
157 |
+
with gr.Row():
|
158 |
+
with gr.Accordion('Citation', open=False):
|
159 |
+
citation_button = gr.Textbox(
|
160 |
+
value=CITATION_BUTTON_TEXT,
|
161 |
+
label=CITATION_BUTTON_LABEL,
|
162 |
+
elem_id='citation-button')
|
163 |
+
|
164 |
+
if __name__ == '__main__':
|
165 |
+
demo.launch(server_name='0.0.0.0')
|
gen_table.py
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import copy as cp
|
2 |
+
import json
|
3 |
+
from collections import defaultdict
|
4 |
+
from urllib.request import urlopen
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
import numpy as np
|
8 |
+
import pandas as pd
|
9 |
+
|
10 |
+
from meta_data import DEFAULT_BENCH, META_FIELDS, URL
|
11 |
+
|
12 |
+
|
13 |
+
def listinstr(lst, s):
|
14 |
+
assert isinstance(lst, list)
|
15 |
+
for item in lst:
|
16 |
+
if item in s:
|
17 |
+
return True
|
18 |
+
return False
|
19 |
+
|
20 |
+
|
21 |
+
def load_results():
|
22 |
+
data = json.loads(urlopen(URL).read())
|
23 |
+
return data
|
24 |
+
|
25 |
+
|
26 |
+
def nth_large(val, vals):
|
27 |
+
return sum([1 for v in vals if v > val]) + 1
|
28 |
+
|
29 |
+
|
30 |
+
def format_timestamp(timestamp):
|
31 |
+
date = timestamp[:2] + '.' + timestamp[2:4] + '.' + timestamp[4:6]
|
32 |
+
time = timestamp[6:8] + ':' + timestamp[8:10] + ':' + timestamp[10:12]
|
33 |
+
return date + ' ' + time
|
34 |
+
|
35 |
+
|
36 |
+
def model_size_flag(sz, FIELDS):
|
37 |
+
if pd.isna(sz) and 'Unknown' in FIELDS:
|
38 |
+
return True
|
39 |
+
if pd.isna(sz):
|
40 |
+
return False
|
41 |
+
if '<4B' in FIELDS and sz < 4:
|
42 |
+
return True
|
43 |
+
if '4B-10B' in FIELDS and sz >= 4 and sz < 10:
|
44 |
+
return True
|
45 |
+
if '10B-20B' in FIELDS and sz >= 10 and sz < 20:
|
46 |
+
return True
|
47 |
+
if '20B-40B' in FIELDS and sz >= 20 and sz < 40:
|
48 |
+
return True
|
49 |
+
if '>40B' in FIELDS and sz >= 40:
|
50 |
+
return True
|
51 |
+
return False
|
52 |
+
|
53 |
+
|
54 |
+
def model_type_flag(line, FIELDS):
|
55 |
+
if 'OpenSource' in FIELDS and line['OpenSource'] == 'Yes':
|
56 |
+
return True
|
57 |
+
if 'API' in FIELDS and line['OpenSource'] == 'No' and line['Verified'] == 'Yes':
|
58 |
+
return True
|
59 |
+
if 'Proprietary' in FIELDS and line['OpenSource'] == 'No' and line['Verified'] == 'No':
|
60 |
+
return True
|
61 |
+
return False
|
62 |
+
|
63 |
+
|
64 |
+
def BUILD_L1_DF(results, fields):
|
65 |
+
check_box = {}
|
66 |
+
check_box['essential'] = ['Method', 'Param (B)', 'Language Model', 'Vision Model']
|
67 |
+
# revise there to set default dataset
|
68 |
+
check_box['required'] = ['Avg Score', 'Avg Rank'] + DEFAULT_BENCH
|
69 |
+
check_box['avg'] = ['Avg Score', 'Avg Rank']
|
70 |
+
check_box['all'] = check_box['avg'] + fields
|
71 |
+
type_map = defaultdict(lambda: 'number')
|
72 |
+
type_map['Method'] = 'html'
|
73 |
+
type_map['Language Model'] = type_map['Vision Model'] = type_map['OpenSource'] = type_map['Verified'] = 'str'
|
74 |
+
check_box['type_map'] = type_map
|
75 |
+
|
76 |
+
df = generate_table(results, fields)
|
77 |
+
return df, check_box
|
78 |
+
|
79 |
+
|
80 |
+
def BUILD_L2_DF(results, dataset):
|
81 |
+
res = defaultdict(list)
|
82 |
+
sub = [v for v in results.values() if dataset in v]
|
83 |
+
assert len(sub)
|
84 |
+
fields = list(sub[0][dataset].keys())
|
85 |
+
|
86 |
+
non_overall_fields = [x for x in fields if 'Overall' not in x]
|
87 |
+
overall_fields = [x for x in fields if 'Overall' in x]
|
88 |
+
if dataset == 'MME':
|
89 |
+
non_overall_fields = [x for x in non_overall_fields if not listinstr(['Perception', 'Cognition'], x)]
|
90 |
+
overall_fields = overall_fields + ['Perception', 'Cognition']
|
91 |
+
if dataset == 'OCRBench':
|
92 |
+
non_overall_fields = [x for x in non_overall_fields if not listinstr(['Final Score'], x)]
|
93 |
+
overall_fields = ['Final Score']
|
94 |
+
|
95 |
+
for m in results:
|
96 |
+
item = results[m]
|
97 |
+
if dataset not in item:
|
98 |
+
continue
|
99 |
+
meta = item['META']
|
100 |
+
for k in META_FIELDS:
|
101 |
+
if k == 'Param (B)':
|
102 |
+
param = meta['Parameters']
|
103 |
+
res[k].append(float(param.replace('B', '')) if param != '' else None)
|
104 |
+
elif k == 'Method':
|
105 |
+
name, url = meta['Method']
|
106 |
+
res[k].append(f'<a href="{url}">{name}</a>')
|
107 |
+
else:
|
108 |
+
res[k].append(meta[k])
|
109 |
+
fields = [x for x in fields]
|
110 |
+
|
111 |
+
for d in non_overall_fields:
|
112 |
+
res[d].append(item[dataset][d])
|
113 |
+
for d in overall_fields:
|
114 |
+
res[d].append(item[dataset][d])
|
115 |
+
|
116 |
+
df = pd.DataFrame(res)
|
117 |
+
all_fields = overall_fields + non_overall_fields
|
118 |
+
# Use the first 5 non-overall fields as required fields
|
119 |
+
required_fields = overall_fields if len(overall_fields) else non_overall_fields[:5]
|
120 |
+
|
121 |
+
if dataset == 'OCRBench':
|
122 |
+
df = df.sort_values('Final Score')
|
123 |
+
elif dataset == 'COCO_VAL':
|
124 |
+
df = df.sort_values('CIDEr')
|
125 |
+
else:
|
126 |
+
df = df.sort_values('Overall')
|
127 |
+
df = df.iloc[::-1]
|
128 |
+
|
129 |
+
check_box = {}
|
130 |
+
check_box['essential'] = ['Method', 'Param (B)', 'Language Model', 'Vision Model']
|
131 |
+
check_box['required'] = required_fields
|
132 |
+
check_box['all'] = all_fields
|
133 |
+
type_map = defaultdict(lambda: 'number')
|
134 |
+
type_map['Method'] = 'html'
|
135 |
+
type_map['Language Model'] = type_map['Vision Model'] = type_map['OpenSource'] = type_map['Verified'] = 'str'
|
136 |
+
check_box['type_map'] = type_map
|
137 |
+
return df, check_box
|
138 |
+
|
139 |
+
|
140 |
+
def generate_table(results, fields):
|
141 |
+
|
142 |
+
def get_mmbench_v11(item):
|
143 |
+
assert 'MMBench_TEST_CN_V11' in item and 'MMBench_TEST_EN_V11' in item
|
144 |
+
val = (item['MMBench_TEST_CN_V11']['Overall'] + item['MMBench_TEST_EN_V11']['Overall']) / 2
|
145 |
+
val = float(f'{val:.1f}')
|
146 |
+
return val
|
147 |
+
|
148 |
+
res = defaultdict(list)
|
149 |
+
for i, m in enumerate(results):
|
150 |
+
item = results[m]
|
151 |
+
meta = item['META']
|
152 |
+
for k in META_FIELDS:
|
153 |
+
if k == 'Param (B)':
|
154 |
+
param = meta['Parameters']
|
155 |
+
res[k].append(float(param.replace('B', '')) if param != '' else None)
|
156 |
+
elif k == 'Method':
|
157 |
+
name, url = meta['Method']
|
158 |
+
res[k].append(f'<a href="{url}">{name}</a>')
|
159 |
+
res['name'].append(name)
|
160 |
+
else:
|
161 |
+
res[k].append(meta[k])
|
162 |
+
scores, ranks = [], []
|
163 |
+
for d in fields:
|
164 |
+
key_name = 'Overall' if d != 'OCRBench' else 'Final Score'
|
165 |
+
# Every Model should have MMBench_V11 results
|
166 |
+
if d == 'MMBench_V11':
|
167 |
+
val = get_mmbench_v11(item)
|
168 |
+
res[d].append(val)
|
169 |
+
scores.append(val)
|
170 |
+
ranks.append(nth_large(val, [get_mmbench_v11(x) for x in results.values()]))
|
171 |
+
elif d in item:
|
172 |
+
res[d].append(item[d][key_name])
|
173 |
+
if d == 'MME':
|
174 |
+
scores.append(item[d][key_name] / 28)
|
175 |
+
elif d == 'OCRBench':
|
176 |
+
scores.append(item[d][key_name] / 10)
|
177 |
+
else:
|
178 |
+
scores.append(item[d][key_name])
|
179 |
+
ranks.append(nth_large(item[d][key_name], [x[d][key_name] for x in results.values() if d in x]))
|
180 |
+
else:
|
181 |
+
res[d].append(None)
|
182 |
+
scores.append(None)
|
183 |
+
ranks.append(None)
|
184 |
+
|
185 |
+
res['Avg Score'].append(round(np.mean(scores), 1) if None not in scores else None)
|
186 |
+
res['Avg Rank'].append(round(np.mean(ranks), 2) if None not in ranks else None)
|
187 |
+
|
188 |
+
df = pd.DataFrame(res)
|
189 |
+
valid, missing = df[~pd.isna(df['Avg Score'])], df[pd.isna(df['Avg Score'])]
|
190 |
+
valid = valid.sort_values('Avg Score')
|
191 |
+
valid = valid.iloc[::-1]
|
192 |
+
if len(fields):
|
193 |
+
missing = missing.sort_values('MMBench_V11' if 'MMBench_V11' in fields else fields[0])
|
194 |
+
missing = missing.iloc[::-1]
|
195 |
+
df = pd.concat([valid, missing])
|
196 |
+
return df
|
meta_data.py
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# CONSTANTS-URL
|
2 |
+
URL = "http://opencompass.openxlab.space/assets/OpenVLM.json"
|
3 |
+
VLMEVALKIT_README = 'https://raw.githubusercontent.com/open-compass/VLMEvalKit/main/README.md'
|
4 |
+
# CONSTANTS-CITATION
|
5 |
+
CITATION_BUTTON_TEXT = r"""@misc{2023opencompass,
|
6 |
+
title={OpenCompass: A Universal Evaluation Platform for Foundation Models},
|
7 |
+
author={OpenCompass Contributors},
|
8 |
+
howpublished = {\url{https://github.com/open-compass/opencompass}},
|
9 |
+
year={2023}
|
10 |
+
}"""
|
11 |
+
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
12 |
+
# CONSTANTS-TEXT
|
13 |
+
LEADERBORAD_INTRODUCTION = """# OpenVLM Leaderboard
|
14 |
+
### Welcome to the OpenVLM Leaderboard! On this leaderboard we share the evaluation results of VLMs obtained by the OpenSource Framework:
|
15 |
+
### [*VLMEvalKit*: A Toolkit for Evaluating Large Vision-Language Models](https://github.com/open-compass/VLMEvalKit) 🏆
|
16 |
+
### Currently, OpenVLM Leaderboard covers {} different VLMs (including GPT-4v, Gemini, QwenVLPlus, LLaVA, etc.) and {} different multi-modal benchmarks.
|
17 |
+
|
18 |
+
This leaderboard was last updated: {}.
|
19 |
+
|
20 |
+
OpenVLM Leaderboard only includes open-source VLMs or API models that are publicly available. To add your own model to the leaderboard, please create a PR in [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) to support your VLM and then we will help with the evaluation and updating the leaderboard. For any questions or concerns, please feel free to contact us at [opencompass, duanhaodong]@pjlab.org.cn.
|
21 |
+
"""
|
22 |
+
# CONSTANTS-FIELDS
|
23 |
+
META_FIELDS = ['Method', 'Param (B)', 'Language Model', 'Vision Model', 'OpenSource', 'Verified']
|
24 |
+
MAIN_FIELDS = [
|
25 |
+
'MMBench_V11', 'MMStar', 'MME',
|
26 |
+
'MMMU_VAL', 'MathVista', 'OCRBench', 'AI2D',
|
27 |
+
'HallusionBench', 'SEEDBench_IMG', 'MMVet',
|
28 |
+
'LLaVABench', 'CCBench', 'RealWorldQA', 'POPE', 'ScienceQA_TEST',
|
29 |
+
'SEEDBench2_Plus', 'MMT-Bench_VAL', 'BLINK'
|
30 |
+
]
|
31 |
+
DEFAULT_BENCH = [
|
32 |
+
'MMBench_V11', 'MMStar', 'MMMU_VAL', 'MathVista', 'OCRBench', 'AI2D',
|
33 |
+
'HallusionBench', 'MMVet'
|
34 |
+
]
|
35 |
+
MMBENCH_FIELDS = ['MMBench_TEST_EN_V11', 'MMBench_TEST_CN_V11', 'MMBench_TEST_EN', 'MMBench_TEST_CN', 'CCBench']
|
36 |
+
MODEL_SIZE = ['<4B', '4B-10B', '10B-20B', '20B-40B', '>40B', 'Unknown']
|
37 |
+
MODEL_TYPE = ['API', 'OpenSource', 'Proprietary']
|
38 |
+
|
39 |
+
# The README file for each benchmark
|
40 |
+
LEADERBOARD_MD = {}
|
41 |
+
|
42 |
+
LEADERBOARD_MD['MAIN'] = f"""
|
43 |
+
## Main Evaluation Results
|
44 |
+
|
45 |
+
- Metrics:
|
46 |
+
- Avg Score: The average score on all VLM Benchmarks (normalized to 0 - 100, the higher the better).
|
47 |
+
- Avg Rank: The average rank on all VLM Benchmarks (the lower the better).
|
48 |
+
- Avg Score & Rank are calculated based on selected benchmark. **When results for some selected benchmarks are missing, Avg Score / Rank will be None!!!**
|
49 |
+
- By default, we present the overall evaluation results based on {len(DEFAULT_BENCH)} VLM benchmarks, sorted by the descending order of Avg Score.
|
50 |
+
- The following datasets are included in the main results: {', '.join(DEFAULT_BENCH)}.
|
51 |
+
- Detailed evaluation results for each dataset (included or not included in main) are provided in the consequent tabs.
|
52 |
+
"""
|
53 |
+
|
54 |
+
for dataset in ['MMBench_DEV_CN', 'MMBench_TEST_CN', 'MMBench_DEV_EN', 'MMBench_TEST_EN', 'CCBench']:
|
55 |
+
LEADERBOARD_MD[dataset] = f"""
|
56 |
+
## {dataset.replace('_', ' ')} Evaluation Results
|
57 |
+
|
58 |
+
- We adopt Circular Eval for benchmarks in MMBench series, you can check https://arxiv.org/pdf/2307.06281.pdf for the detailed definition of Circular Eval.
|
59 |
+
"""
|
60 |
+
|
61 |
+
LEADERBOARD_MD['SEEDBench_IMG'] = """
|
62 |
+
## SEEDBench_IMG Scores (ChatGPT Answer Extraction / Official Leaderboard)
|
63 |
+
|
64 |
+
- **Overall**: The overall accuracy across all questions with **ChatGPT answer matching**.
|
65 |
+
- **Overall (official)**: SEEDBench_IMG acc on the official leaderboard (if applicable).
|
66 |
+
"""
|
67 |
+
|
68 |
+
LEADERBOARD_MD['MMVet'] = """
|
69 |
+
## MMVet Evaluation Results
|
70 |
+
|
71 |
+
- In MMVet Evaluation, we use GPT-4-Turbo (gpt-4-1106-preview) as the judge LLM to assign scores to the VLM outputs. We only perform the evaluation once due to the limited variance among results of multiple evaluation pass originally reported.
|
72 |
+
- No specific prompt template adopted for **ALL VLMs**.
|
73 |
+
- We also provide performance on the [**Official Leaderboard**](https://paperswithcode.com/sota/visual-question-answering-on-mm-vet) for models that are applicable. Those results are obtained with GPT-4-0314 evaluator (which has been deperacted for new users).
|
74 |
+
"""
|
75 |
+
|
76 |
+
LEADERBOARD_MD['MMMU_VAL'] = """
|
77 |
+
## MMMU Validation Evaluation Results
|
78 |
+
|
79 |
+
- For MMMU, we support the evaluation of the `dev` (150 samples) and `validation` (900 samples) set. Here we only report the results on the `validation` set.
|
80 |
+
- **Answer Inference:**
|
81 |
+
- For models with `interleave_generate` interface (accept interleaved images & texts as inputs), all testing samples can be inferred. **`interleave_generate` is adopted for inference.**
|
82 |
+
- For models without `interleave_generate` interface, samples with more than one images are skipped (42 out of 1050, directly count as wrong). **`generate` is adopted for inference.**
|
83 |
+
- **Evaluation**:
|
84 |
+
- MMMU include two types of questions: **multi-choice questions** & **open-ended QA**.
|
85 |
+
- For **open-ended QA (62/1050)**, we re-formulate it as multi-choice questions: `{'question': 'QQQ', 'answer': 'AAA'} -> {'question': 'QQQ', 'A': 'AAA', 'B': 'Other Answers', 'answer': 'A'}`, and then adopt the same evaluation paradigm for **multi-choice questions**.
|
86 |
+
- For **multi-choice questions (988/1050)**, we use **GPT-3.5-Turbo-0613** for matching prediction with options if heuristic matching does not work.
|
87 |
+
"""
|
88 |
+
|
89 |
+
LEADERBOARD_MD['MathVista'] = """
|
90 |
+
## MMMU TestMini Evaluation Results
|
91 |
+
|
92 |
+
- We report the evaluation results on MathVista **TestMini**, which include 1000 test samples.
|
93 |
+
- We adopt `GPT-4-Turbo (1106)` as the answer extractor when we failed to extract the answer with heuristic matching.
|
94 |
+
- The performance of **Human (High school)** and **Random Choice** are copied from the official leaderboard.
|
95 |
+
**Category Definitions:** **FQA:** figure QA, **GPS:** geometry problem solving, **MWP:** math word problem, **TQA:** textbook QA, **VQA:** visual QA, **ALG:** algebraic, **ARI:** arithmetic, **GEO:** geometry, **LOG:** logical , **NUM:** numeric, **SCI:** scientific, **STA:** statistical.
|
96 |
+
"""
|
97 |
+
|
98 |
+
LEADERBOARD_MD['HallusionBench'] = """
|
99 |
+
[**HallusionBench**](https://github.com/tianyi-lab/HallusionBench) is a benchmark to evaluate hallucination of VLMs. It asks a set of visual questions with one original image and one modified image (the answers for a question can be different, considering the image content).
|
100 |
+
|
101 |
+
**Examples in HallusionBench:**
|
102 |
+
|
103 |
+
| Original Figure | Modified Figure |
|
104 |
+
| ------------------------------------------------------------ | ------------------------------------------------------------ |
|
105 |
+
| ![](http://opencompass.openxlab.space/utils/Hallu0.png) | ![](http://opencompass.openxlab.space/utils/Hallu1.png) |
|
106 |
+
| **Q1.** Is the right orange circle the same size as the left orange circle? **A1. Yes** | **Q1.** Is the right orange circle the same size as the left orange circle? **A1. No** |
|
107 |
+
| **Q2.** Is the right orange circle larger than the left orange circle? **A2. No** | **Q2.** Is the right orange circle larger than the left orange circle? **A2. Yes** |
|
108 |
+
| **Q3.** Is the right orange circle smaller than the left orange circle? **A3. No** | **Q3.** Is the right orange circle smaller than the left orange circle? **A3. No** |
|
109 |
+
|
110 |
+
**Metrics**:
|
111 |
+
|
112 |
+
>- aAcc: The overall accuracy of **all** atomic questions.
|
113 |
+
>
|
114 |
+
>- qAcc: The mean accuracy of unique **questions**. One question can be asked multiple times with different figures, we consider VLM correctly solved a unique question only if it succeeds in all <question, figure> pairs for this unique question.
|
115 |
+
>- fAcc: The mean accuracy of all **figures**. One figure is associated with multiple questions, we consider VLM correct on a figure only if it succeeds to solve all questions of this figure.
|
116 |
+
|
117 |
+
**Evaluation Setting**:
|
118 |
+
|
119 |
+
> 1. **No-visual** Questions (questions asked without the associated figure) in HallusionBench are **skipped** during evaluation.
|
120 |
+
> 2. When we failed to extract Yes / No from the VLM prediction, we adopt **GPT-3.5-Turbo-0613** as the answer extractor.
|
121 |
+
> 3. We report aAcc, qAcc, and fAcc for all evaluated VLMs.
|
122 |
+
|
123 |
+
## HallusionBench Evaluation Results
|
124 |
+
"""
|
125 |
+
|
126 |
+
LEADERBOARD_MD['LLaVABench'] = """
|
127 |
+
## LLaVABench Evaluation Results
|
128 |
+
|
129 |
+
- In LLaVABench Evaluation, we use GPT-4-Turbo (gpt-4-1106-preview) as the judge LLM to assign scores to the VLM outputs. We only perform the evaluation once due to the limited variance among results of multiple evaluation pass originally reported.
|
130 |
+
- No specific prompt template adopted for **ALL VLMs**.
|
131 |
+
- We also include the official results (obtained by gpt-4-0314) for applicable models.
|
132 |
+
"""
|
133 |
+
|
134 |
+
LEADERBOARD_MD['COCO_VAL'] = """
|
135 |
+
## COCO Caption Results
|
136 |
+
|
137 |
+
- By default, we evaluate COCO Caption Validation set (5000 samples), and report the following metrics: BLEU-1, BLEU-4, CIDEr, ROUGE-L (default sorted by CIDEr).
|
138 |
+
- We use the following prompt to evaluate all VLMs: `Please describe this image in general. Directly provide the description, do not include prefix like "This image depicts". `
|
139 |
+
- **No specific prompt is adopted for all VLMs.**
|
140 |
+
"""
|
141 |
+
|
142 |
+
LEADERBOARD_MD['ScienceQA_VAL'] = """
|
143 |
+
## ScienceQA Evaluation Results
|
144 |
+
|
145 |
+
- We benchmark the **image** subset of ScienceQA validation and test set, and report the Top-1 accuracy.
|
146 |
+
- During evaluation, we use `GPT-3.5-Turbo-0613` as the choice extractor for all VLMs if the choice can not be extracted via heuristic matching. **Zero-shot** inference is adopted.
|
147 |
+
"""
|
148 |
+
|
149 |
+
LEADERBOARD_MD['ScienceQA_TEST'] = LEADERBOARD_MD['ScienceQA_VAL']
|
150 |
+
|
151 |
+
LEADERBOARD_MD['OCRBench'] = """
|
152 |
+
## OCRBench Evaluation Results
|
153 |
+
|
154 |
+
- The evaluation of OCRBench is implemented by the official team: https://github.com/Yuliang-Liu/MultimodalOCR.
|
155 |
+
- The performance of GPT4V might be underestimated: GPT4V rejects to answer 12 percent of the questions due to the policy of OpenAI. For those questions, the returned answer is "Your input image may contain content that is not allowed by our safety system."
|
156 |
+
"""
|
157 |
+
|
158 |
+
LEADERBOARD_MD['MMStar'] = """
|
159 |
+
## MMStar Evaluation Results
|
160 |
+
|
161 |
+
- MMStar is an elite vision-indispensable multi-modal benchmark, including 1,500 challenging samples meticulously selected by humans.
|
162 |
+
- During the evaluation of MMStar, we find that some API models may reject to answer some of the questions. Currently, we treat such cases as wrong answers when reporting the results.
|
163 |
+
"""
|
164 |
+
|
165 |
+
LEADERBOARD_MD['RealWorldQA'] = """
|
166 |
+
## RealWorldQA Evaluation Results
|
167 |
+
|
168 |
+
- RealWorldQA is a benchmark designed to evaluate the real-world spatial understanding capabilities of multimodal AI models, contributed by XAI. It assesses how well these models comprehend physical environments. The benchmark consists of 700+ images, each accompanied by a question and a verifiable answer. These images are drawn from real-world scenarios, including those captured from vehicles. The goal is to advance AI models' understanding of our physical world.
|
169 |
+
"""
|
170 |
+
|
171 |
+
LEADERBOARD_MD['TextVQA_VAL'] = """
|
172 |
+
## TextVQA Evaluation Results
|
173 |
+
|
174 |
+
- TextVQA is a dataset to benchmark visual reasoning based on text in images. TextVQA requires models to read and reason about text in images to answer questions about them. Specifically, models need to incorporate a new modality of text present in the images and reason over it to answer TextVQA questions.
|
175 |
+
- Note that some models may not be able to generate standardized responses based on the prompt. We currently do not have reports for these models.
|
176 |
+
"""
|
177 |
+
|
178 |
+
LEADERBOARD_MD['ChartQA_TEST'] = """
|
179 |
+
## ChartQA Evaluation Results
|
180 |
+
|
181 |
+
- ChartQA is a benchmark for question answering about charts with visual and logical reasoning.
|
182 |
+
- Note that some models may not be able to generate standardized responses based on the prompt. We currently do not have reports for these models.
|
183 |
+
"""
|
184 |
+
|
185 |
+
LEADERBOARD_MD['OCRVQA_TESTCORE'] = """
|
186 |
+
## OCRVQA Evaluation Results
|
187 |
+
|
188 |
+
- OCRVQA is a benchmark for visual question answering by reading text in images. It presents a large-scale dataset, OCR-VQA-200K, comprising over 200,000 images of book covers. The study combines techniques from the Optical Character Recognition (OCR) and Visual Question Answering (VQA) domains to address the challenges associated with this new task and dataset.
|
189 |
+
- Note that some models may not be able to generate standardized responses based on the prompt. We currently do not have reports for these models.
|
190 |
+
"""
|
191 |
+
|
192 |
+
LEADERBOARD_MD['POPE'] = """
|
193 |
+
## POPE Evaluation Results
|
194 |
+
|
195 |
+
- POPE is a benchmark for object hallucination evaluation. It includes three tracks of object hallucination: random, popular, and adversarial.
|
196 |
+
- Note that the official POPE dataset contains approximately 8910 cases. POPE includes three tracks, and there are some overlapping samples among the three tracks. To reduce the data file size, we have kept only a single copy of the overlapping samples (about 5127 examples). However, the final accuracy will be calculated on the ~9k samples.
|
197 |
+
- Some API models, due to safety policies, refuse to answer certain questions, so their actual capabilities may be higher than the reported scores.
|
198 |
+
- We report the average F1 score across the three types of data as the overall score. Accuracy, precision, and recall are also shown in the table. F1 score = 2 * (precision * recall) / (precision + recall).
|
199 |
+
"""
|
200 |
+
|
201 |
+
LEADERBOARD_MD['SEEDBench2_Plus'] = """
|
202 |
+
## SEEDBench2 Plus Evaluation Results
|
203 |
+
|
204 |
+
- SEEDBench2 Plus comprises 2.3K multiple-choice questions with precise human annotations, spanning three broad categories: Charts, Maps, and Webs, each of which covers a wide spectrum of textrich scenarios in the real world.
|
205 |
+
"""
|
206 |
+
|
207 |
+
LEADERBOARD_MD['MMT-Bench_VAL'] = """
|
208 |
+
## MMT-Bench Validation Evaluation Results
|
209 |
+
|
210 |
+
- MMT-Bench comprises 31,325 meticulously curated multi-choice visual questions from various multimodal scenarios such as vehicle driving and embodied navigation, covering 32 core meta-tasks and 162 subtasks in multimodal understanding.
|
211 |
+
- MMT-Bench_VAL is the validation set of MMT-Bench. MMT-Bench_ALL includes both validation and test sets. The suffix `MI`, such as `MMT-Bench_VAL_MI`, represents the multi-image version of the dataset with several images input.
|
212 |
+
The defualt version is the single-image version, which concats the multiple images into a single image as input.
|
213 |
+
"""
|
214 |
+
|
215 |
+
LEADERBOARD_MD['SEEDBench2'] = """
|
216 |
+
## SEEDBench2 Evaluation Results
|
217 |
+
|
218 |
+
- SEEDBench2 comprises 24K multiple-choice questions with accurate human annotations, which spans 27 dimensions, including the evaluation of both text and image generation.
|
219 |
+
- Note that we only evaluate and report the part of model's results on the SEEDBench2.
|
220 |
+
"""
|
221 |
+
|
222 |
+
LEADERBOARD_MD['BLINK'] = """
|
223 |
+
## BLINK Test Evaluation Results
|
224 |
+
|
225 |
+
- BLINK is a benchmark containing 14 visual perception tasks that can be solved by humans “within a blink”, but pose significant challenges for current multimodal large language models (LLMs).
|
226 |
+
- We evaluate BLINK on the test set of the benchmark, which contains 1901 visual questions in multi-choice format.
|
227 |
+
"""
|
requirements.txt
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
|
|
|
|
|
|
1 |
+
gradio==4.15.0
|
2 |
+
numpy>=1.23.4
|
3 |
+
pandas>=1.5.3
|
templates/index.html
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html>
|
3 |
-
|
4 |
-
<head>
|
5 |
-
<meta charset="utf-8" />
|
6 |
-
<meta name="viewport" content="width=device-width" />
|
7 |
-
<title>My static Space</title>
|
8 |
-
<style>
|
9 |
-
body {
|
10 |
-
margin: 0;
|
11 |
-
}
|
12 |
-
|
13 |
-
.space {
|
14 |
-
max-width: 100%;
|
15 |
-
max-height: 100%;
|
16 |
-
width: 100vw;
|
17 |
-
height: 100vh;
|
18 |
-
overflow: hidden;
|
19 |
-
}
|
20 |
-
|
21 |
-
.iframe {
|
22 |
-
min-width: 100%;
|
23 |
-
min-height: 100%;
|
24 |
-
}
|
25 |
-
</style>
|
26 |
-
</head>
|
27 |
-
|
28 |
-
<body>
|
29 |
-
<div class="space">
|
30 |
-
<iframe class="iframe" allowfullscreen="true" frameborder="0" src="https://mmbench.opencompass.org.cn/leaderboard">
|
31 |
-
</iframe>
|
32 |
-
</div>
|
33 |
-
</body>
|
34 |
-
|
35 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|