|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""SMVB dataset""" |
|
|
|
import sys |
|
import pathlib |
|
if sys.version_info < (3, 9): |
|
from typing import Sequence, Generator, Tuple |
|
else: |
|
from collections.abc import Sequence, Generator |
|
Tuple = tuple |
|
|
|
from typing import Optional, IO |
|
|
|
import datasets |
|
import itertools |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@INPROCEEDINGS{karoly2024synthetic, |
|
author={Károly, Artúr I. and Nádas, Imre and Galambos, Péter}, |
|
booktitle={2024 IEEE 22nd World Symposium on Applied Machine Intelligence and Informatics (SAMI)}, |
|
title={Synthetic Multimodal Video Benchmark (SMVB): Utilizing Blender for rich dataset generation}, |
|
year={2024}, |
|
volume={}, |
|
number={}, |
|
pages={}, |
|
doi={}} |
|
|
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
Amultimodal video benchmark for evaluating models in multi-task learning scenarios. |
|
""" |
|
|
|
_HOMEPAGE = "https://huggingface.co/ABC-iRobotics/SMVB" |
|
|
|
_LICENSE = "GNU General Public License v3.0" |
|
|
|
_BASE_URL = "https://huggingface.co/datasets/ABC-iRobotics/SMVB/resolve/main/data" |
|
|
|
_VERSION = '1.0.0' |
|
|
|
_SCENES = ['car'] |
|
|
|
|
|
|
|
|
|
class SMVBDatasetConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for SMVB dataset.""" |
|
|
|
def __init__(self, name: str, data_urls: Sequence[str], version: Optional[str] = None, **kwargs): |
|
super(SMVBDatasetConfig, self).__init__(version=datasets.Version(version), name=name, **kwargs) |
|
self._data_urls = data_urls |
|
|
|
@property |
|
def features(self): |
|
return datasets.Features( |
|
{ |
|
"image": datasets.Image(), |
|
"mask": datasets.Image(), |
|
"depth": datasets.Sequence(datasets.Value("float32")), |
|
"flow": datasets.Sequence(datasets.Value("float32")), |
|
"normal": datasets.Sequence(datasets.Value("float32")) |
|
} |
|
) |
|
|
|
@property |
|
def keys(self): |
|
return ("image", "mask", "depth", "flow", "normal") |
|
|
|
|
|
|
|
|
|
|
|
class SMVBDataset(datasets.GeneratorBasedBuilder): |
|
"""SMVB dataset.""" |
|
|
|
BUILDER_CONFIG_CLASS = SMVBDatasetConfig |
|
BUILDER_CONFIGS = [ |
|
SMVBDatasetConfig( |
|
name = "all", |
|
description = "Photorealistic synthetic images", |
|
data_urls = [_BASE_URL + '/' + s + '.tar.gz' for s in _SCENES], |
|
version = _VERSION |
|
), |
|
] |
|
DEFAULT_WRITER_BATCH_SIZE = 10 |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=self.config.features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
version=self.config.version, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
local_data_paths = dl_manager.download(self.config._data_urls) |
|
local_data_gen = itertools.chain.from_iterable([dl_manager.iter_archive(path) for path in local_data_paths]) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"data": local_data_gen |
|
} |
|
) |
|
] |
|
|
|
def _generate_examples( |
|
self, |
|
data: Generator[Tuple[str,IO], None, None] |
|
): |
|
file_infos = [] |
|
keys = self.config.keys |
|
|
|
for i, info in enumerate(data): |
|
if file_infos and i%len(keys) == 0: |
|
yield (i//len(keys))-1, {k:{'path':d[0],'bytes':d[1]} for k,d in zip(keys,file_infos)} |
|
file_infos = [] |
|
file_path, file_object = info |
|
file_infos.append((file_path, file_object.read())) |