Spaces:
Sleeping
Sleeping
File size: 1,354 Bytes
0874d87 |
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 |
from typing import List
from torch.utils.data import Dataset
from .image_dataset import CustomDataset
from .audio_dataset import EmodbDataset
from .ctc_audio_dataclass import CTCEmodbDataset
from .TESS_Dataset import TESSRawWaveformDataset
__dataset_mapper__ = {
"image": CustomDataset,
"emodb": EmodbDataset,
'CTCemodb': CTCEmodbDataset,
'TESSDataset': TESSRawWaveformDataset
}
def list_datasets() -> List[str]:
"""Returns a list of available dataset names.
Returns:
List[str]: List of dataset names as strings.
Example:
>>> from datasets import list_datasets
>>> list_datasets()
['image', 'emodb']
"""
return sorted(__dataset_mapper__.keys())
def get_dataset_by_name(dataset: str, *args, **kwargs) -> Dataset:
"""Returns the Dataset class using the given name and arguments.
Args:
dataset (str): The name of the dataset.
Returns:
Dataset: The requested dataset instance.
Example:
>>> from datasets import get_dataset_by_name
>>> dataset = get_dataset_by_name("emodb", root_path="./data/emodb")
>>> type(dataset)
<class 'datasets.audio_dataset.EmodbDataset'>
"""
assert dataset in __dataset_mapper__, f"Dataset '{dataset}' not found in the mapper."
return __dataset_mapper__[dataset](*args, **kwargs) |