Spaces:
Sleeping
Sleeping
File size: 1,333 Bytes
e84842d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
"""
Copyright (c) 2022, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
"""
from lavis.common.registry import registry
from lavis.common.utils import get_cache_path
from lavis.datasets.builders.base_dataset_builder import BaseDatasetBuilder
from lavis.datasets.datasets.video_vqa_datasets import VideoQADataset
class VideoQABuilder(BaseDatasetBuilder):
train_dataset_cls = VideoQADataset
eval_dataset_cls = VideoQADataset
def build(self):
datasets = super().build()
ans2label = self.config.build_info.annotations.get("ans2label")
if ans2label is None:
raise ValueError("ans2label is not specified in build_info.")
ans2label = get_cache_path(ans2label.storage)
for split in datasets:
datasets[split]._build_class_labels(ans2label)
return datasets
@registry.register_builder("msrvtt_qa")
class MSRVTTQABuilder(VideoQABuilder):
DATASET_CONFIG_DICT = {
"default": "configs/datasets/msrvtt/defaults_qa.yaml",
}
@registry.register_builder("msvd_qa")
class MSVDQABuilder(VideoQABuilder):
DATASET_CONFIG_DICT = {
"default": "configs/datasets/msvd/defaults_qa.yaml",
}
|