ndsampler.coerce_data

Moved to netharn

Module Contents

Functions

coerce_datasets(config, build_hashid=False, verbose=1)

Coerce train / val / test datasets from standard netharn config keys

_print_catfreq_columns(subsets)

_catfreq_columns_str(subsets)

_split_train_vali_test(coco_dset, factor=3)

Parameters

factor (int) -- number of pieces to divide images into

ndsampler.coerce_data.coerce_datasets(config, build_hashid=False, verbose=1)

Coerce train / val / test datasets from standard netharn config keys

Todo

  • Does this belong in netharn?

This only looks at the following keys in config:
  • datasets

  • train_dataset

  • vali_dataset

  • test_dataset

Example

>>> import kwcoco
>>> import ndsampler.coerce_data
>>> config = {'datasets': 'special:shapes'}
>>> print('config = {!r}'.format(config))
>>> dsets = ndsampler.coerce_data.coerce_datasets(config)
>>> print('dsets = {!r}'.format(dsets))
>>> config = {'datasets': 'special:shapes256'}
>>> ndsampler.coerce_data.coerce_datasets(config)
>>> config = {
>>>     'datasets': kwcoco.CocoDataset.demo('shapes'),
>>> }
>>> coerce_datasets(config)
>>> coerce_datasets({
>>>     'datasets': kwcoco.CocoDataset.demo('shapes'),
>>>     'test_dataset': kwcoco.CocoDataset.demo('photos'),
>>> })
>>> coerce_datasets({
>>>     'datasets': kwcoco.CocoDataset.demo('shapes'),
>>>     'test_dataset': kwcoco.CocoDataset.demo('photos'),
>>> })
ndsampler.coerce_data._print_catfreq_columns(subsets)
ndsampler.coerce_data._catfreq_columns_str(subsets)
ndsampler.coerce_data._split_train_vali_test(coco_dset, factor=3)
Parameters

factor (int) – number of pieces to divide images into

CommandLine:

xdoctest -m /home/joncrall/code/ndsampler/ndsampler/coerce_data.py _split_train_vali_test

Example

>>> from ndsampler.coerce_data import _split_train_vali_test
>>> import kwcoco
>>> coco_dset = kwcoco.CocoDataset.demo('shapes8')
>>> split_gids = _split_train_vali_test(coco_dset)
>>> print('split_gids = {}'.format(ub.repr2(split_gids, nl=1)))