From 144073a92467bd9a83e12158e0620e0d10e92d58 Mon Sep 17 00:00:00 2001 From: Flynn Duniho Date: Sat, 29 Jul 2023 20:13:03 -0700 Subject: [PATCH] Automatically select index file when model is selected (#894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * automatically select index file when model is selected * Search for full directory of index file * Add trailing separator char to index search string * disable debug log * remove unused re --------- Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com> --- infer-web.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/infer-web.py b/infer-web.py index 5fc309a..f36de89 100644 --- a/infer-web.py +++ b/infer-web.py @@ -399,6 +399,16 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format torch.cuda.empty_cache() yield "\n".join(infos) +def get_index_path_from_model(sid): + sel_index_path = "" + name = os.path.join("logs", sid.split(".")[0], "") + # print(name) + for f in index_paths: + if name in f: + # print("selected index path:", f) + sel_index_path = f + break + return sel_index_path # 一个选项卡全局只能有一个音色 def get_vc(sid, to_return_protect0, to_return_protect1): @@ -434,6 +444,7 @@ def get_vc(sid, to_return_protect0, to_return_protect1): return {"visible": False, "__type__": "update"} person = "%s/%s" % (weight_root, sid) print("loading %s" % person) + cpt = torch.load(person, map_location="cpu") tgt_sr = cpt["config"][-1] cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk @@ -479,6 +490,7 @@ def get_vc(sid, to_return_protect0, to_return_protect1): {"visible": True, "maximum": n_spk, "__type__": "update"}, to_return_protect0, to_return_protect1, + get_index_path_from_model(sid), ) @@ -1629,7 +1641,7 @@ with gr.Blocks(title="RVC WebUI") as app: sid0.change( fn=get_vc, inputs=[sid0, protect0, protect1], - outputs=[spk_item, protect0, protect1], + outputs=[spk_item, protect0, protect1, file_index2], ) with gr.TabItem(i18n("伴奏人声分离&去混响&去回声")): with gr.Group():