cvpods.configs package¶
-
class
cvpods.configs.base_config.
ConfigDict
(d=None, **kwargs)[source]¶ Bases:
dict
-
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
- 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
-
link_log
(link_name='log')[source]¶ create a softlink to output dir.
- Parameters
link_name (str) – name of softlink
-
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
- 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
-
cvpods.configs.config_helper.
find_key
(param_dict: dict, key: str) → dict[source]¶ find key in dict
- Examples::
>>> d = dict(abc=2, ab=4, c=4) >>> find_key(d, "ab") {'abc': 2, 'ab':4}