MCPcopy
hub / github.com/open-compass/VLMEvalKit / evaluate

Function evaluate

scripts/mmb_eval_gradio.py:72–99  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

70 return pd.DataFrame(nacc)
71
72def evaluate(file):
73 file_name = file.name
74 flag, eval_file = prepare_file(file_name)
75 if not flag:
76 return "Error: " + eval_file
77 dataset = determine_dataset(eval_file)
78 if dataset == 'Unknown':
79 return "Error: Cannot determine the dataset given your submitted file. "
80
81 eval_id = eval_file.split('/')[-1].split('.')[0]
82 ret = f"Evaluation ID: {eval_id}\n"
83 timestamp = datetime.datetime.now().strftime('%Y.%m.%d %H:%M:%S')
84 ret += f'Evaluation Timestamp: {timestamp}\n'
85 eval_data = load(eval_file)
86 eval_data['index'] = [int(x) for x in eval_data['index']]
87 base_data = build_dataset(dataset).data
88 base_index_set = set([int(x) for x in base_data['index']])
89 inds_more = {k for k in eval_data['index'] if k not in base_index_set}
90 if len(inds_more) > 0:
91 inds_more = set([x % 1e6 for x in inds_more])
92 ret += f"Warning: The matched dataset is {dataset}. The following indices are not in the base dataset: {inds_more}\n"
93 ret += f"We automatically remove those indices, and still recommend you to check the indices in your prediction file.\n"
94 eval_data = eval_data[eval_data['index'].isin(base_index_set)]
95 dump(eval_data, eval_file)
96
97 acc = EVAL(dataset, eval_file)
98 nacc = reformat_acc(acc).round(1)
99 return ret, nacc
100
101with gr.Blocks() as demo:
102 gr.Markdown(HEADER)

Callers

nothing calls this directly

Calls 7

build_datasetFunction · 0.90
EVALFunction · 0.90
prepare_fileFunction · 0.85
determine_datasetFunction · 0.85
loadFunction · 0.85
dumpFunction · 0.85
reformat_accFunction · 0.85

Tested by

no test coverage detected