Exemplo n.º 1
0
def _decode_cfg_value(v):
    """Decodes a raw config value (e.g., from a yaml config files or command
    line argument) into a Python object.
    """
    # Configs parsed from raw yaml will contain dictionary keys that need to be
    # converted to AttrDict objects
    if isinstance(v, dict):
        return AttrDict(v)
    # All remaining processing is only applied to strings
    if not isinstance(v, string_types):
        return v
    # Try to interpret `v` as a:
    #   string, number, tuple, list, dict, boolean, or None
    try:
        v = literal_eval(v)
    # The following two excepts allow v to pass through when it represents a
    # string.
    #
    # Longer explanation:
    # The type of v is always a string (before calling literal_eval), but
    # sometimes it *represents* a string and other times a data structure, like
    # a list. In the case that v represents a string, what we got back from the
    # yaml parser is 'foo' *without quotes* (so, not '"foo"'). literal_eval is
    # ok with '"foo"', but will raise a ValueError if given 'foo'. In other
    # cases, like paths (v = 'foo/bar' and not v = '"foo/bar"'), literal_eval
    # will raise a SyntaxError.
    except ValueError:
        pass
    except SyntaxError:
        pass
    return v
Exemplo n.º 2
0
from __future__ import print_function
from __future__ import unicode_literals

import yaml
import io
import os
import copy
from ast import literal_eval
import numpy as np

# from past.builtins import basestring
from six import string_types

from configs.collections import AttrDict

__C = AttrDict()

cfg = __C

# Training options

__C.TRAIN = AttrDict()

__C.TRAIN.WEIGHTS = ''

__C.TRAIN.BATCH_SIZE = 32

__C.TRAIN.START_EPOCH = 0

__C.TRAIN.MAX_EPOCH = 200
Exemplo n.º 3
0
def merge_cfg_from_file(cfg_filename):
    """Load a yaml config file and merge it into the global config."""
    with open(cfg_filename, 'r') as f:
        yaml_cfg = AttrDict(load_cfg(f))
    _merge_a_into_b(yaml_cfg, __C)
Exemplo n.º 4
0
from __future__ import print_function
from __future__ import unicode_literals

import yaml
import io
import os
import copy
from ast import literal_eval
import numpy as np

# from past.builtins import basestring
from six import string_types

from configs.collections import AttrDict

__C = AttrDict()

cfg = __C

# Training options

__C.TRAIN = AttrDict()

__C.TRAIN.WEIGHTS = ''

__C.TRAIN.BATCH_SIZE = 32

__C.TRAIN.START_EPOCH = 0

__C.TRAIN.MAX_EPOCH = 200