Spaces:
Sleeping
Sleeping
Update gen_table.py
Browse files- gen_table.py +0 -76
gen_table.py
CHANGED
@@ -10,13 +10,6 @@ import pandas as pd
|
|
10 |
from meta_data import DEFAULT_BENCH, META_FIELDS, RESULTS
|
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 |
def load_results_local():
|
21 |
with open(RESULTS, 'r') as infile:
|
22 |
data = json.load(infile)
|
@@ -26,11 +19,6 @@ def nth_large(val, vals):
|
|
26 |
return sum([1 for v in vals if v > val]) + 1
|
27 |
|
28 |
|
29 |
-
def format_timestamp(timestamp):
|
30 |
-
date = timestamp[:2] + '.' + timestamp[2:4] + '.' + timestamp[4:6]
|
31 |
-
time = timestamp[6:8] + ':' + timestamp[8:10] + ':' + timestamp[10:12]
|
32 |
-
return date + ' ' + time
|
33 |
-
|
34 |
|
35 |
def model_size_flag(sz, FIELDS):
|
36 |
if pd.isna(sz) and 'Unknown' in FIELDS:
|
@@ -76,70 +64,6 @@ def BUILD_L1_DF(results, fields):
|
|
76 |
return df, check_box
|
77 |
|
78 |
|
79 |
-
def BUILD_L2_DF(results, dataset):
|
80 |
-
res = defaultdict(list)
|
81 |
-
sub = [v for v in results.values() if dataset in v]
|
82 |
-
assert len(sub)
|
83 |
-
fields = list(sub[0][dataset].keys())
|
84 |
-
|
85 |
-
non_overall_fields = [x for x in fields if 'Overall' not in x]
|
86 |
-
overall_fields = [x for x in fields if 'Overall' in x]
|
87 |
-
if dataset == 'MME':
|
88 |
-
non_overall_fields = [x for x in non_overall_fields if not listinstr(['Perception', 'Cognition'], x)]
|
89 |
-
overall_fields = overall_fields + ['Perception', 'Cognition']
|
90 |
-
if dataset == 'OCRBench':
|
91 |
-
non_overall_fields = [x for x in non_overall_fields if not listinstr(['Final Score'], x)]
|
92 |
-
overall_fields = ['Final Score']
|
93 |
-
print(overall_fields)
|
94 |
-
print(non_overall_fields)
|
95 |
-
|
96 |
-
for m in results:
|
97 |
-
item = results[m]
|
98 |
-
if dataset not in item:
|
99 |
-
continue
|
100 |
-
meta = item['META']
|
101 |
-
for k in META_FIELDS:
|
102 |
-
if k == 'Param (B)':
|
103 |
-
param = meta['Parameters']
|
104 |
-
res[k].append(float(param.replace('B', '')) if param != '' else None)
|
105 |
-
elif k == 'Method':
|
106 |
-
name, url = meta['Method']
|
107 |
-
res[k].append(f'<a href="{url}">{name}</a>')
|
108 |
-
else:
|
109 |
-
res[k].append(meta[k])
|
110 |
-
fields = [x for x in fields]
|
111 |
-
|
112 |
-
for d in non_overall_fields:
|
113 |
-
res[d].append(item[dataset][d])
|
114 |
-
for d in overall_fields:
|
115 |
-
res[d].append(item[dataset][d])
|
116 |
-
|
117 |
-
df = pd.DataFrame(res)
|
118 |
-
print(df)
|
119 |
-
all_fields = overall_fields + non_overall_fields
|
120 |
-
# Use the first 5 non-overall fields as required fields
|
121 |
-
# required_fields = overall_fields if len(overall_fields) else non_overall_fields[:5]
|
122 |
-
required_fields = all_fields
|
123 |
-
|
124 |
-
if dataset == 'OCRBench':
|
125 |
-
df = df.sort_values('Final Score')
|
126 |
-
elif dataset == 'COCO_VAL':
|
127 |
-
df = df.sort_values('CIDEr')
|
128 |
-
else:
|
129 |
-
df = df.sort_values('Overall')
|
130 |
-
df = df.iloc[::-1]
|
131 |
-
|
132 |
-
check_box = {}
|
133 |
-
check_box['essential'] = ['Method', 'Param (B)']
|
134 |
-
check_box['required'] = required_fields
|
135 |
-
check_box['all'] = all_fields
|
136 |
-
type_map = defaultdict(lambda: 'number')
|
137 |
-
type_map['Method'] = 'html'
|
138 |
-
type_map['Language Model'] = type_map['Vision Model'] = type_map['OpenSource'] = type_map['Verified'] = 'str'
|
139 |
-
check_box['type_map'] = type_map
|
140 |
-
return df, check_box
|
141 |
-
|
142 |
-
|
143 |
def generate_table(results, fields):
|
144 |
|
145 |
def get_mmbench_v11(item):
|
|
|
10 |
from meta_data import DEFAULT_BENCH, META_FIELDS, RESULTS
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
def load_results_local():
|
14 |
with open(RESULTS, 'r') as infile:
|
15 |
data = json.load(infile)
|
|
|
19 |
return sum([1 for v in vals if v > val]) + 1
|
20 |
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
def model_size_flag(sz, FIELDS):
|
24 |
if pd.isna(sz) and 'Unknown' in FIELDS:
|
|
|
64 |
return df, check_box
|
65 |
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def generate_table(results, fields):
|
68 |
|
69 |
def get_mmbench_v11(item):
|