|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""VRP2 dataset""" |
|
|
|
import copy |
|
import json |
|
import os |
|
import pandas as pd |
|
|
|
import datasets |
|
from datasets import load_dataset |
|
|
|
_CITATION = """\ |
|
@article{vp2r2022jjk, |
|
title={xxxxx}, |
|
author={test1}, |
|
journal={arXiv preprint arXiv:2203.10981}, |
|
year={2022} |
|
} |
|
""" |
|
_DESCRIPTION = """\ |
|
yhello |
|
""" |
|
|
|
_LICENSE = "GNU General Public License v3.0" |
|
_SPLITS = ["test"] |
|
|
|
_URL = "https://huggingface.co/datasets/mujif/vrptest2/resolve/main/data/IQ" |
|
|
|
|
|
class ChartQA(datasets.GeneratorBasedBuilder): |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"imgname": datasets.Value("string"), |
|
"image": datasets.Image(), |
|
"question": datasets.Value("string"), |
|
"gt_answer": datasets.Value("string"), |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
supervised_keys=None, |
|
license=_LICENSE, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
downloaded_file = dl_manager.download_and_extract(_URL) |
|
|
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={ |
|
"images_path": downloaded_file + "/test", |
|
"img_anno_path": downloaded_file + "/test/result.jsonl", |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, img_anno_path:str ,images_path: str): |
|
idx = 0 |
|
with open(img_anno_path, "r", encoding="utf-8") as f: |
|
data = json.load(f) |
|
|
|
for item in data: |
|
item = copy.deepcopy(item) |
|
item["image"] = os.path.join(images_path,item["file_name"]) |
|
item["question"] = item["question"] |
|
item["gt_answer"] = item["gt_answer"] |
|
|
|
yield idx, item |
|
idx += 1 |
|
|