|
|
|
|
|
import json |
|
import csv |
|
if __name__ == '__main__': |
|
|
|
|
|
|
|
model_name = 'llava1.5_7b' |
|
|
|
|
|
submission_file_phase1_6datasets = f'/system/user/publicdata/LMM_benchmarks/MMFM_challenge_final/doc-vl-eval/inference_results/output_6_datasets_{model_name}.json' |
|
submission_file_phase1_4datasets = f'/system/user/publicdata/LMM_benchmarks/MMFM_challenge_final/doc-vl-eval/inference_results/output_4_datasets_{model_name}.json' |
|
submission_file_phase2 = f'/system/user/publicdata/LMM_benchmarks/MMFM_challenge_final/doc-vl-eval/inference_results/output_private_{model_name}.json' |
|
submission_file = f'test_submission_{model_name}.csv' |
|
|
|
|
|
|
|
answer_dict_file_phase1 = '/system/user/publicdata/LMM_benchmarks/MMFM_challenge_final/doc-vl-eval/answer_dicts/coverted_output_test_all_datasets.json' |
|
answer_dict_file_phase2 = '/system/user/publicdata/LMM_benchmarks/MMFM_challenge_final/doc-vl-eval/answer_dicts/converted_output_test_private_for_mixtral_eval.json' |
|
|
|
with open(answer_dict_file_phase1, 'r') as f: |
|
answer_dict_phase1 = json.load(f) |
|
with open(answer_dict_file_phase2, 'r') as f: |
|
answer_dict_phase2 = json.load(f) |
|
|
|
|
|
submission_phase1_6datasets = json.load(open(submission_file_phase1_6datasets)) |
|
submission_phase1_4datasets = json.load(open(submission_file_phase1_4datasets)) |
|
submission_phase2 = json.load(open(submission_file_phase2)) |
|
|
|
answer_dict = {**answer_dict_phase1, **answer_dict_phase2} |
|
merged_submission = {**submission_phase1_6datasets, **submission_phase1_4datasets, **submission_phase2} |
|
|
|
|
|
|
|
|
|
merged_submission_ = {} |
|
for key, value in merged_submission.items(): |
|
items = key.split('_') |
|
if items[0] == 'mychart': |
|
items = items[:3] + [items[-1]] |
|
elif items[0] == 'myinfographic': |
|
items = items[:2] + [items[-1]] |
|
key_ = '_'.join(items[:-1]) |
|
merged_submission_[key_] = value |
|
|
|
with open(submission_file, 'w', newline='') as f: |
|
writer = csv.writer(f) |
|
writer.writerow(['id', 'pred', 'split']) |
|
|
|
for sample_key, data_dict in answer_dict.items(): |
|
items = sample_key.split('_') |
|
id_ = '_'.join(items[:-1]) |
|
pred = merged_submission_[id_] |
|
writer.writerow([id_, pred, 'public']) |
|
|
|
|
|
t = 1 |