CoolFace
Apppublic

k20hcmus/FishEye8K

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
3likes
parser.py42 linesDownload Raw Back to utils
1import os2import yaml3from easydict import EasyDict as edict4 5 6class YamlParser(edict):7    """8    This is yaml parser based on EasyDict.9    """10 11    def __init__(self, cfg_dict=None, config_file=None):12        if cfg_dict is None:13            cfg_dict = {}14 15        if config_file is not None:16            assert(os.path.isfile(config_file))17            with open(config_file, 'r') as fo:18                yaml_ = yaml.load(fo.read(), Loader=yaml.FullLoader)19                cfg_dict.update(yaml_)20 21        super(YamlParser, self).__init__(cfg_dict)22 23    def merge_from_file(self, config_file):24        with open(config_file, 'r') as fo:25            yaml_ = yaml.load(fo.read(), Loader=yaml.FullLoader)26            self.update(yaml_)27 28    def merge_from_dict(self, config_dict):29        self.update(config_dict)30 31 32def get_config(config_file=None):33    return YamlParser(config_file=config_file)34 35 36if __name__ == "__main__":37    cfg = YamlParser(config_file="../configs/yolov3.yaml")38    cfg.merge_from_file("../configs/deep_sort.yaml")39 40    import ipdb41    ipdb.set_trace()42