kwcoco.cli.coco_split module

class kwcoco.cli.coco_split.CocoSplitCLI[source]

Bases: object

Splits a coco files into two parts base on some criteria.

Useful for generating quick and dirty train/test splits, but in general users should opt for using kwcoco subset instead to explicitly construct these splits based on domain knowledge.

name = 'split'
class CLIConfig(data=None, default=None, cmdline=False)[source]

Bases: Config

Split a single COCO dataset into two sub-datasets.

Parameters:
  • data (object) – filepath, dict, or None

  • default (dict | None) – overrides the class defaults

  • cmdline (bool | List[str] | str | dict) – If False, then no command line information is used. If True, then sys.argv is parsed and used. If a list of strings that used instead of sys.argv. If a string, then that is parsed using shlex and used instead

    of sys.argv.

    If a dictionary grants fine grained controls over the args passed to Config._read_argv(). Can contain:

    • strict (bool): defaults to False

    • argv (List[str]): defaults to None

    • special_options (bool): defaults to True

    • autocomplete (bool): defaults to False

    Defaults to False.

Note

Avoid setting cmdline parameter here. Instead prefer to use the cli classmethod to create a command line aware config instance..

default = {'balance_categories': <Value(True)>, 'compress': <Value('auto')>, 'dst1': <Value('split1.kwcoco.json')>, 'dst2': <Value('split2.kwcoco.json')>, 'factor': <Value(3)>, 'num_write': <Value(1)>, 'rng': <Value(None)>, 'splitter': <Value('auto')>, 'src': <Value(None)>}
classmethod main(cmdline=True, **kw)[source]

Example

>>> from kwcoco.cli.coco_split import *  # NOQA
>>> import ubelt as ub
>>> dpath = ub.Path.appdir('kwcoco/tests/cli/split').ensuredir()
>>> kw = {'src': 'special:vidshapes8',
>>>       'dst1': dpath / 'train.json',
>>>       'dst2': dpath / 'test.json'}
>>> cmdline = False
>>> cls = CocoSplitCLI
>>> cls.main(cmdline, **kw)
kwcoco.cli.coco_split._CLI

alias of CocoSplitCLI