def eval_simple_qa_acc(gt_data_or_path, pred_data_or_path):
    """For open-ended QA that has a single answer,
    accuracy is computed based on exact match"""
    if isinstance(gt_data_or_path, str):
        gt_data_or_path = json.load(open(gt_data_or_path, "r"))
    if isinstance(pred_data_or_path, str):
        pred_data_or_path = json.load(open(pred_data_or_path, "r"))
    true_or_false_list = []
    gt_qid2answer = {d["question_id"]: d["answer"] for d in gt_data_or_path}
    pred_qid2answer = {d["question_id"]: d["answer"] for d in pred_data_or_path}
    missing_qids = []
    for qid, answer in gt_qid2answer.items():
        if qid in pred_qid2answer:
            true_or_false_list.append(int(pred_qid2answer[qid] == answer))
        else:  # if not exists automatically False
            true_or_false_list.append(0)
            missing_qids.append(qid)
    logger.info(f"Missing predictions for {len(missing_qids)} questions, example[:3] {missing_qids[:3]}")
    acc = round(100. * sum(true_or_false_list) / len(true_or_false_list), 2)
    return acc
For open-ended QA that has a single answer,
accuracy is computed based on exact match
videomamba/video_mm/tasks/vqa_utils.py