llava_100k_finetuned / scripts /convert_mmbench_for_submission.py
saurabh-straive's picture
Duplicate from advaitadasein/llava_alt_text
92aaa61 verified
raw
history blame contribute delete
980 Bytes
import os
import json
import argparse
import pandas as pd
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--annotation-file", type=str, required=True)
parser.add_argument("--result-dir", type=str, required=True)
parser.add_argument("--upload-dir", type=str, required=True)
parser.add_argument("--experiment", type=str, required=True)
return parser.parse_args()
if __name__ == "__main__":
args = get_args()
df = pd.read_table(args.annotation_file)
cur_df = df.copy()
cur_df = cur_df.drop(columns=['hint', 'category', 'source', 'image', 'comment', 'l2-category'])
cur_df.insert(6, 'prediction', None)
for pred in open(os.path.join(args.result_dir, f"{args.experiment}.jsonl")):
pred = json.loads(pred)
cur_df.loc[df['index'] == pred['question_id'], 'prediction'] = pred['text']
cur_df.to_excel(os.path.join(args.upload_dir, f"{args.experiment}.xlsx"), index=False, engine='openpyxl')