add global keyword
parent
5ae81344a0
commit
31068ca233
|
@ -32,7 +32,8 @@ def init_image_dataset(name, **kwargs):
|
|||
"""Initializes an image dataset."""
|
||||
avai_datasets = list(__image_datasets.keys())
|
||||
if name not in avai_datasets:
|
||||
raise ValueError('Invalid dataset name. Received "{}", but expected to be one of {}'.format(name, avai_datasets))
|
||||
raise ValueError('Invalid dataset name. Received "{}", '
|
||||
'but expected to be one of {}'.format(name, avai_datasets))
|
||||
return __image_datasets[name](**kwargs)
|
||||
|
||||
|
||||
|
@ -40,16 +41,17 @@ def init_video_dataset(name, **kwargs):
|
|||
"""Initializes a video dataset."""
|
||||
avai_datasets = list(__video_datasets.keys())
|
||||
if name not in avai_datasets:
|
||||
raise ValueError('Invalid dataset name. Received "{}", but expected to be one of {}'.format(name, avai_datasets))
|
||||
raise ValueError('Invalid dataset name. Received "{}", '
|
||||
'but expected to be one of {}'.format(name, avai_datasets))
|
||||
return __video_datasets[name](**kwargs)
|
||||
|
||||
|
||||
def register_image_dataset(name, dataset_):
|
||||
def register_image_dataset(name, dataset):
|
||||
"""Registers a new image dataset.
|
||||
|
||||
Args:
|
||||
name (str): key corresponding to the new dataset.
|
||||
dataset_ (Dataset): the new dataset class.
|
||||
dataset (Dataset): the new dataset class.
|
||||
|
||||
Examples::
|
||||
|
||||
|
@ -67,18 +69,20 @@ def register_image_dataset(name, dataset_):
|
|||
sources=['new_dataset', 'dukemtmcreid']
|
||||
)
|
||||
"""
|
||||
global __image_datasets
|
||||
curr_datasets = list(__image_datasets.keys())
|
||||
if name in curr_datasets:
|
||||
raise ValueError('The given name already exists, please choose another name excluding {}'.format(curr_datasets))
|
||||
__image_datasets[name] = dataset_
|
||||
raise ValueError('The given name already exists, please choose '
|
||||
'another name excluding {}'.format(curr_datasets))
|
||||
__image_datasets[name] = dataset
|
||||
|
||||
|
||||
def register_video_dataset(name, dataset_):
|
||||
def register_video_dataset(name, dataset):
|
||||
"""Registers a new video dataset.
|
||||
|
||||
Args:
|
||||
name (str): key corresponding to the new dataset.
|
||||
dataset_ (Dataset): the new dataset class.
|
||||
dataset (Dataset): the new dataset class.
|
||||
|
||||
Examples::
|
||||
|
||||
|
@ -96,7 +100,9 @@ def register_video_dataset(name, dataset_):
|
|||
sources=['new_dataset', 'ilidsvid']
|
||||
)
|
||||
"""
|
||||
global __video_datasets
|
||||
curr_datasets = list(__video_datasets.keys())
|
||||
if name in curr_datasets:
|
||||
raise ValueError('The given name already exists, please choose another name excluding {}'.format(curr_datasets))
|
||||
__video_datasets[name] = dataset_
|
||||
raise ValueError('The given name already exists, please choose '
|
||||
'another name excluding {}'.format(curr_datasets))
|
||||
__video_datasets[name] = dataset
|
||||
|
|
Loading…
Reference in New Issue