Update PlotQA_dataset.py
Browse files- PlotQA_dataset.py +9 -9
PlotQA_dataset.py
CHANGED
|
@@ -73,12 +73,12 @@ class PlotQA(datasets.GeneratorBasedBuilder):
|
|
| 73 |
def _info(self):
|
| 74 |
features = datasets.Features(
|
| 75 |
{
|
| 76 |
-
|
| 77 |
"image": datasets.Image(),
|
| 78 |
"version": datasets.Value("string"),
|
| 79 |
-
|
| 80 |
"query_token": datasets.Sequence(datasets.Value("string")),
|
| 81 |
-
|
| 82 |
"img_ann": datasets.Value("string"),
|
| 83 |
###
|
| 84 |
"image_index": datasets.Value("string"),
|
|
@@ -155,13 +155,13 @@ class PlotQA(datasets.GeneratorBasedBuilder):
|
|
| 155 |
with open(anno_path, "r", encoding="utf-8") as f:
|
| 156 |
data = json.load(f)
|
| 157 |
#returns the examples in the raw in json file
|
| 158 |
-
for
|
| 159 |
-
item = copy.deepcopy(
|
| 160 |
-
|
| 161 |
-
item["image"] = os.path.join('./imgs',item["
|
| 162 |
item["query_token"] = []
|
| 163 |
-
|
| 164 |
-
|
| 165 |
|
| 166 |
item["version"] = "temp"
|
| 167 |
item["img_ann"] = "TBD"
|
|
|
|
| 73 |
def _info(self):
|
| 74 |
features = datasets.Features(
|
| 75 |
{
|
| 76 |
+
"imgname": datasets.Value("string"),
|
| 77 |
"image": datasets.Image(),
|
| 78 |
"version": datasets.Value("string"),
|
| 79 |
+
"query": datasets.Value("string"),
|
| 80 |
"query_token": datasets.Sequence(datasets.Value("string")),
|
| 81 |
+
"label": datasets.Value("string"),
|
| 82 |
"img_ann": datasets.Value("string"),
|
| 83 |
###
|
| 84 |
"image_index": datasets.Value("string"),
|
|
|
|
| 155 |
with open(anno_path, "r", encoding="utf-8") as f:
|
| 156 |
data = json.load(f)
|
| 157 |
#returns the examples in the raw in json file
|
| 158 |
+
for idx in range(0,len(data['qa_pairs'])-1):
|
| 159 |
+
item = copy.deepcopy(data['qa_pairs'][idx])
|
| 160 |
+
item["imgname"] = item["image_index"]
|
| 161 |
+
item["image"] = os.path.join('./imgs',item["imgname"]) + '.png'
|
| 162 |
item["query_token"] = []
|
| 163 |
+
item["query"] = item["question_string"]
|
| 164 |
+
item["label"] = item["answer"]
|
| 165 |
|
| 166 |
item["version"] = "temp"
|
| 167 |
item["img_ann"] = "TBD"
|