Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
Myhs-phz committed Dec 16, 2024
1 parent 3fa22ac commit f386d34
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion vlmeval/dataset/cmmmu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from .image_base import ImageBaseDataset
import re
import random
from collections import Counter
import os
import re
import tempfile
from ..smp import *


def get_multi_choice_prediction(response, all_choices, index2ans):
Expand Down Expand Up @@ -190,15 +193,35 @@ def get_key_subresponses(response):


class CMMMU(ImageBaseDataset):
TYPE = 'VQA'

DATASET_URL = {
'CMMMU_TEST': 'https://opencompass.openxlab.space/utils/VLMEval/CMMMU_TEST.tsv',
'CMMMU_VAL': 'https://opencompass.openxlab.space/utils/VLMEval/CMMMU_VAL.tsv'
}

DATASET_MD5 = {
'CMMMU_TEST': '521afc0f3bf341e6654327792781644d',
'CMMMU_VAL': 'b4727e2fce2415bf646379e60c11a726'
}

def dump_image(self, line):
os.makedirs(self.img_root, exist_ok=True)

tgt_path_z = []
if isinstance(line['image'], list):
for i in range(len(line['image'])):
tgt_path = osp.join(self.img_root, f"{line['index']}--{i + 1}.jpg")
if not read_ok(tgt_path):
decode_base64_to_image_file(line['image'][i], tgt_path)
tgt_path_z.append(tgt_path)
else:
tgt_path = osp.join(self.img_root, f"{line['index']}.jpg")
if not read_ok(tgt_path):
decode_base64_to_image_file(line['image'], tgt_path)
tgt_path_z.append(tgt_path)
return tgt_path_z

@classmethod
def evaluate(self, eval_file, **judge_kwargs):

Expand Down

0 comments on commit f386d34

Please sign in to comment.