cvpods.configs package

class cvpods.configs.base_config.ConfigDict(d=None, **kwargs)[source]

Bases: dict

funcname_not_in_attr()[source]
update(e=None, **f)[source]
pop(k, d=None)[source]
merge(config=None, **kwargs)[source]

merge all key and values of config as BaseConfig’s attributes. Note that kwargs will override values in config if they have the same keys

Parameters

config (dict) – custom config dict

merge_from_list(cfg_list)[source]

Merge config (keys, values) in a list (e.g., from command line) into this config dict.

Parameters
  • cfg_list (list) – cfg_list must be divided exactly.

  • example, cfg_list = ['FOO.BAR', 0.5] (For) –

diff(cfg)dict[source]

diff given config with current config object

Parameters

cfg (ConfigDict) – given config, could be any subclass of ConfigDict

Returns

ConfigDict – contains all diff pair

find(key: str, show=True, color='\x1b[30m\x1b[43m')dict[source]

find a given key and its value in config

Parameters
  • key (str) – the string you want to find

  • show (bool) – if show is True, print find result; or return the find result

  • color (str) – color of key, default color is black(foreground) yellow(background)

Returns

dict – if show is False, return dict that contains all find result

Example:

>>> from config import config        # suppose you are in your training dir
>>> config.find("weights")
clear() → None. Remove all items from D.
copy() → a shallow copy of D
fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

items() → a set-like object providing a view on D’s items
keys() → a set-like object providing a view on D’s keys
popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

values() → an object providing a view on D’s values
class cvpods.configs.base_config.BaseConfig(d=None, **kwargs)[source]

Bases: cvpods.configs.base_config.ConfigDict

create a softlink to output dir.

Parameters

link_name (str) – name of softlink

funcname_not_in_attr()[source]
clear() → None. Remove all items from D.
copy() → a shallow copy of D
diff(cfg)dict

diff given config with current config object

Parameters

cfg (ConfigDict) – given config, could be any subclass of ConfigDict

Returns

ConfigDict – contains all diff pair

find(key: str, show=True, color='\x1b[30m\x1b[43m')dict

find a given key and its value in config

Parameters
  • key (str) – the string you want to find

  • show (bool) – if show is True, print find result; or return the find result

  • color (str) – color of key, default color is black(foreground) yellow(background)

Returns

dict – if show is False, return dict that contains all find result

Example:

>>> from config import config        # suppose you are in your training dir
>>> config.find("weights")
fromkeys()

Create a new dictionary with keys from iterable and values set to value.

get()

Return the value for key if key is in the dictionary, else default.

items() → a set-like object providing a view on D’s items
keys() → a set-like object providing a view on D’s keys
merge(config=None, **kwargs)

merge all key and values of config as BaseConfig’s attributes. Note that kwargs will override values in config if they have the same keys

Parameters

config (dict) – custom config dict

merge_from_list(cfg_list)

Merge config (keys, values) in a list (e.g., from command line) into this config dict.

Parameters
  • cfg_list (list) – cfg_list must be divided exactly.

  • example, cfg_list = ['FOO.BAR', 0.5] (For) –

pop(k, d=None)
popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault()

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(e=None, **f)
values() → an object providing a view on D’s values

cvpods.configs.config_helper module

cvpods.configs.config_helper.highlight(keyword, target, color='\x1b[30m\x1b[43m')[source]

use given color to highlight keyword in target string

Parameters
  • keyword (str) – highlight string

  • target (str) – target string

  • color (str) – string represent the color, use black foreground

  • yellow background as default (and) –

Returns

(str) target string with keyword highlighted

cvpods.configs.config_helper.find_key(param_dict: dict, key: str)dict[source]

find key in dict

Parameters
  • param_dict (dict) –

  • key (str) –

Returns

(dict)

Examples::
>>> d = dict(abc=2, ab=4, c=4)
>>> find_key(d, "ab")
{'abc': 2, 'ab':4}
cvpods.configs.config_helper.diff_dict(src, dst)[source]

find difference between src dict and dst dict

Parameters
  • src (dict) – src dict

  • dst (dict) – dst dict

Returns

(dict) dict contains all the difference key

cvpods.configs.config_helper.version_update(config)[source]

Backward compatibility of old config’s Augmentation pipelines and Optimizer configs; Convert old format into new ones.