Skip to content

Commit

Permalink
[Fix] Modify example and load gt_answer as string.
Browse files Browse the repository at this point in the history
  • Loading branch information
yyk-wew committed Jun 12, 2023
1 parent 0e60d1c commit b1cd4f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
7 changes: 3 additions & 4 deletions mmpretrain/datasets/__init__.py
Expand Up @@ -24,14 +24,13 @@
from .sun397 import SUN397
from .transforms import * # noqa: F401,F403
from .voc import VOC
from .vsr import VSR

__all__ = [
'BaseDataset', 'CIFAR10', 'CIFAR100', 'CUB', 'Caltech101', 'CustomDataset',
'DTD', 'FGVCAircraft', 'FashionMNIST', 'Flowers102', 'Food101', 'ImageNet',
'ImageNet21k', 'InShop', 'KFoldDataset', 'MNIST', 'MultiLabelDataset',
'MultiTaskDataset', 'NLVR2', 'OxfordIIITPet', 'Places205', 'SUN397',
'StanfordCars', 'VOC', 'VSR', 'build_dataset'
'StanfordCars', 'VOC', 'build_dataset'
]

if WITH_MULTIMODAL:
Expand All @@ -45,10 +44,10 @@
from .scienceqa import ScienceQA
from .textvqa import TextVQA
from .visual_genome import VisualGenomeQA
from .vsr import VSR

__all__.extend([
'COCOCaption', 'COCORetrieval', 'COCOVQA', 'FlamingoEvalCOCOCaption',
'FlamingoEvalCOCOVQA', 'RefCOCO', 'VisualGenomeQA', 'ScienceQA',
'NoCaps'
'GQA', 'TextVQA'
'NoCaps', 'GQA', 'TextVQA', 'VSR'
])
15 changes: 6 additions & 9 deletions mmpretrain/datasets/vsr.py
@@ -1,5 +1,4 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
from typing import List

import mmengine
Expand Down Expand Up @@ -41,17 +40,15 @@ def load_data_list(self) -> List[dict]:
for ann in annotations:
# ann example
# {
# 'question': "Is it overcast?",
# 'answer': 'no,
# 'image_id': n161313.jpg,
# 'question_id': 262148000,
# ....
# "image": "train2017/000000372029.jpg",
# "question": "The dog is on the surfboard.",
# "answer": true
# }
data_info = dict()
data_info['img_path'] = osp.join(self.data_prefix['img_path'],
ann['image'])
data_info['img_path'] = mmengine.join_path(
self.data_prefix['img_path'], ann['image'])
data_info['question'] = ann['question']
data_info['gt_answer'] = ann['answer']
data_info['gt_answer'] = 'yes' if ann['answer'] else 'no'

data_list.append(data_info)

Expand Down

0 comments on commit b1cd4f3

Please sign in to comment.