From ae49b2a8e1bc676e6014d8a12ebeec947b655e3e Mon Sep 17 00:00:00 2001
From: 莫拉古 <61447879+yechaoying@users.noreply.github.com>
Date: 星期五, 29 十一月 2024 09:55:43 +0800
Subject: [PATCH] 变量名写错了 (#2249)
---
funasr/download/download_model_from_hub.py | 38 +++++++++++++++++++++++++++++++++-----
1 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/funasr/download/download_model_from_hub.py b/funasr/download/download_model_from_hub.py
index df4f33d..f7eea2a 100644
--- a/funasr/download/download_model_from_hub.py
+++ b/funasr/download/download_model_from_hub.py
@@ -51,7 +51,8 @@
cfg = {}
if "file_path_metas" in conf_json:
add_file_root_path(model_or_path, conf_json["file_path_metas"], cfg)
- cfg.update(kwargs)
+ # cfg.update(kwargs)
+ cfg = OmegaConf.merge(cfg, kwargs)
if "config" in cfg:
config = OmegaConf.load(cfg["config"])
kwargs = OmegaConf.merge(config, cfg)
@@ -159,15 +160,42 @@
def add_file_root_path(model_or_path: str, file_path_metas: dict, cfg={}):
if isinstance(file_path_metas, dict):
+ if isinstance(cfg, list):
+ cfg.append({})
+
for k, v in file_path_metas.items():
if isinstance(v, str):
p = os.path.join(model_or_path, v)
if os.path.exists(p):
- cfg[k] = p
+ if isinstance(cfg, dict):
+ cfg[k] = p
+ elif isinstance(cfg, list):
+ # if len(cfg) == 0:
+ # cfg.append({})
+ cfg[-1][k] = p
+
elif isinstance(v, dict):
- if k not in cfg:
- cfg[k] = {}
- add_file_root_path(model_or_path, v, cfg[k])
+ if isinstance(cfg, dict):
+ if k not in cfg:
+ cfg[k] = {}
+ add_file_root_path(model_or_path, v, cfg[k])
+ # elif isinstance(cfg, list):
+ # cfg.append({})
+ # add_file_root_path(model_or_path, v, cfg)
+ elif isinstance(v, (list, tuple)):
+ for i, vv in enumerate(v):
+ if k not in cfg:
+ cfg[k] = []
+ if isinstance(vv, str):
+ p = os.path.join(model_or_path, vv)
+ # file_path_metas[i] = p
+ if os.path.exists(p):
+ if isinstance(cfg[k], dict):
+ cfg[k] = p
+ elif isinstance(cfg[k], list):
+ cfg[k].append(p)
+ elif isinstance(vv, dict):
+ add_file_root_path(model_or_path, vv, cfg[k])
return cfg
--
Gitblit v1.9.1