diff --git a/convert_params_compute_diff.py b/convert_params_compute_diff.py index 3369c93..8370a71 100644 --- a/convert_params_compute_diff.py +++ b/convert_params_compute_diff.py @@ -20,7 +20,7 @@ def load_config(file_path): _, ext = os.path.splitext(file_path) assert ext in [".yml", ".yaml"], "only support yaml files for now" - config = yaml.load(open(file_path, "rb"), Loader=yaml.Loader) + config = yaml.load(open(file_path, "rb"), Loader=yaml.SafeLoader) return config diff --git a/torchocr/engine/config.py b/torchocr/engine/config.py index 0d52ab1..ad9d3c0 100644 --- a/torchocr/engine/config.py +++ b/torchocr/engine/config.py @@ -28,7 +28,7 @@ def _parse_opt(self, opts): s = s.strip() k, v = s.split('=', 1) if '.' not in k: - config[k] = yaml.load(v, Loader=yaml.Loader) + config[k] = yaml.load(v, Loader=yaml.SafeLoader) else: keys = k.split('.') if keys[0] not in config: @@ -36,7 +36,7 @@ def _parse_opt(self, opts): cur = config[keys[0]] for idx, key in enumerate(keys[1:]): if idx == len(keys) - 2: - cur[key] = yaml.load(v, Loader=yaml.Loader) + cur[key] = yaml.load(v, Loader=yaml.SafeLoader) else: cur[key] = {} cur = cur[key] @@ -116,7 +116,7 @@ def _load_config_with_base(self, file_path): assert ext in ['.yml', '.yaml'], "only support yaml files for now" with open(file_path) as f: - file_cfg = yaml.load(f, Loader=yaml.Loader) + file_cfg = yaml.load(f, Loader=yaml.SafeLoader) # NOTE: cfgs outside have higher priority than cfgs in _BASE_ if self.BASE_KEY in file_cfg: