mmagic.datasets.basic_frames_dataset
¶
Module Contents¶
Classes¶
BasicFramesDataset for open source projects in OpenMMLab/MMagic. |
- class mmagic.datasets.basic_frames_dataset.BasicFramesDataset(ann_file: str = '', metainfo: Optional[dict] = None, data_root: Optional[str] = None, data_prefix: dict = dict(img=''), pipeline: List[Union[dict, Callable]] = [], test_mode: bool = False, filename_tmpl: dict = dict(), search_key: Optional[str] = None, backend_args: Optional[dict] = None, depth: int = 1, num_input_frames: Optional[int] = None, num_output_frames: Optional[int] = None, fixed_seq_len: Optional[int] = None, load_frames_list: dict = dict(), **kwargs)[source]¶
Bases:
mmengine.dataset.BaseDataset
BasicFramesDataset for open source projects in OpenMMLab/MMagic.
This dataset is designed for low-level vision tasks with frames, such as video super-resolution and video frame interpolation.
The annotation file is optional.
If use annotation file, the annotation format can be shown as follows.
Case 1 (Vid4): calendar 41 city 34 foliage 49 walk 47 Case 2 (REDS): 000/00000000.png (720, 1280, 3) 000/00000001.png (720, 1280, 3) Case 3 (Vimeo90k): 00001/0266 (256, 448, 3) 00001/0268 (256, 448, 3)
- Parameters
ann_file (str) – Annotation file path. Defaults to ‘’.
metainfo (dict, optional) – Meta information for dataset, such as class information. Defaults to None.
data_root (str, optional) – The root directory for
data_prefix
andann_file
. Defaults to None.data_prefix (dict, optional) – Prefix for training data. Defaults to dict(img=’’, gt=’’).
pipeline (list, optional) – Processing pipeline. Defaults to [].
test_mode (bool, optional) –
test_mode=True
means in test phase. Defaults to False.filename_tmpl (str) – Template for each filename. Note that the template excludes the file extension. Default: ‘{}’.
search_key (str) – The key used for searching the folder to get data_list. Default: ‘gt’.
backend_args (dict, optional) – Arguments to instantiate the prefix of uri corresponding backend. Defaults to None.
depth (int) – The depth of path. Default: 1
num_input_frames (None | int) – Number of input frames. Default: None.
num_output_frames (None | int) – Number of output frames. Default: None.
fixed_seq_len (None | int) – The fixed sequence length. If None, BasicFramesDataset will obtain the length of each sequence. Default: None.
load_frames_list (dict) – Load frames list for each key. Default: dict().
Examples
Assume the file structure as the following:
mmagic (root) ├── mmagic ├── tools ├── configs ├── data │ ├── Vid4 │ │ ├── BIx4 │ │ │ ├── city │ │ │ │ ├── img1.png │ │ ├── GT │ │ │ ├── city │ │ │ │ ├── img1.png │ │ ├── meta_info_Vid4_GT.txt │ ├── places │ │ ├── sequences | | | ├── 00001 │ │ │ │ ├── 0389 │ │ │ │ │ ├── img1.png │ │ │ │ │ ├── img2.png │ │ │ │ │ ├── img3.png │ │ ├── tri_trainlist.txt
Case 1: Loading Vid4 dataset for training a VSR model.
dataset = BasicFramesDataset( ann_file='meta_info_Vid4_GT.txt', metainfo=dict(dataset_type='vid4', task_name='vsr'), data_root='data/Vid4', data_prefix=dict(img='BIx4', gt='GT'), pipeline=[], depth=2, num_input_frames=5)
Case 2: Loading Vimeo90k dataset for training a VFI model.
dataset = BasicFramesDataset( ann_file='tri_trainlist.txt', metainfo=dict(dataset_type='vimeo90k', task_name='vfi'), data_root='data/vimeo-triplet', data_prefix=dict(img='sequences', gt='sequences'), pipeline=[], depth=2, load_frames_list=dict( img=['img1.png', 'img3.png'], gt=['img2.png']))
- See more details in unittest
- tests/test_datasets/test_base_frames_dataset.py
TestFramesDatasets().test_version_1_method()
- load_data_list() List[dict] [source]¶
Load data list from folder or annotation file.
- Returns
A list of annotation.
- Return type
list[dict]
- _get_path_list()[source]¶
Get list of paths from annotation file or folder of dataset.
- Returns
A list of paths.
- Return type
list[str]
- _get_path_list_from_ann()[source]¶
Get list of paths from annotation file.
- Returns
A list of paths.
- Return type
list[str]
- _get_path_list_from_folder(sub_folder=None, need_ext=True, depth=1)[source]¶
Get list of paths from folder.
- Parameters
sub_folder (None | str) – The path of sub_folder. Default: None.
need_ext (bool) – Whether need ext. Default: True.
depth (int) – Residual depth of path, recursively called to
depth == 1
. Default: 1
- Returns
A list of paths.
- Return type
list[str]