File size: 2,827 Bytes
375239b 33dd4ea 375239b 33dd4ea 375239b 33dd4ea 375239b 33dd4ea 375239b 33dd4ea 375239b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import json
import csv
if __name__ == '__main__':
# category_to_sample_ids_dict = json.load(open('../category_to_sample_ids_dict.json'))
# answer_dict_for_mixtral_eval = json.load(open('../answer_dict_for_mixtral_eval.json'))
model_name = 'llava1.5_7b'
# model_name = 'llava1.5_13b'
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 = '/system/user/publicdata/LMM_benchmarks/MMFM_challenge_final/doc-vl-eval/answer_dicts/coverted_output_test_all_datasets.json'
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) # 2000 samples, 200 samples x 10 datasets
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}
# answer_dict = { **answer_dict_phase2}
# merged_submission = {**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'])
# idx = 0
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'])
# idx += 1
t = 1 |