[Feature]: Add image_only param (#1613)

* [Feature]: Add image_only param

* [Feature]: Use image_only
pull/1641/head
Yuan Liu 2023-06-06 12:50:42 +08:00 committed by GitHub
parent 3a277ee9e6
commit bddbc085fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -23,6 +23,8 @@ class ScienceQA(BaseDataset):
split_file (str): The split file of dataset, which contains the
ids of data samples in the split.
ann_file (str): Annotation file path.
image_only (bool): Whether only to load data with image. Defaults to
False.
data_prefix (dict): Prefix for data field. Defaults to
``dict(img_path='')``.
pipeline (Sequence): Processing pipeline. Defaults to an empty tuple.
@ -34,15 +36,16 @@ class ScienceQA(BaseDataset):
split: str,
split_file: str,
ann_file: str,
image_only: bool = False,
data_prefix: dict = dict(img_path=''),
pipeline: Sequence[Callable] = (),
**kwargs):
assert split in [
'train', 'val', 'test', 'trainval', 'minival', 'minitest'
], f'Invalid split {split}'
self.split = split
self.split_file = os.path.join(data_root, split_file)
self.image_only = image_only
super().__init__(
data_root=data_root,
@ -62,6 +65,8 @@ class ScienceQA(BaseDataset):
data_list = []
for data_id in current_data_split:
ann = annotations[data_id]
if self.image_only and ann['image'] is None:
continue
data_info = {
'image_id':
data_id,