Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
feat(app): category model fix
Browse files- app-full.py +12 -13
- app.py +12 -13
app-full.py
CHANGED
@@ -149,30 +149,28 @@ def change_to_upload_mode(upload_mode):
|
|
149 |
|
150 |
if __name__ == '__main__':
|
151 |
load_hubert()
|
152 |
-
models = []
|
153 |
categories = []
|
154 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
155 |
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
156 |
with open("weights/folder_info.json", "r", encoding="utf-8") as f:
|
157 |
folder_info = json.load(f)
|
158 |
-
for
|
159 |
-
if not
|
160 |
continue
|
161 |
-
|
162 |
-
|
163 |
-
description =
|
164 |
-
|
165 |
-
|
166 |
-
with open(f"weights/{folder}/model_info.json", "r", encoding="utf-8") as f:
|
167 |
models_info = json.load(f)
|
168 |
for name, info in models_info.items():
|
169 |
if not info['enable']:
|
170 |
continue
|
171 |
title = info['title']
|
172 |
author = info.get("author", None)
|
173 |
-
cover = f"weights/{
|
174 |
-
index = f"weights/{
|
175 |
-
cpt = torch.load(f"weights/{
|
176 |
tgt_sr = cpt["config"][-1]
|
177 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
178 |
if_f0 = cpt.get("f0", 1)
|
@@ -190,6 +188,7 @@ if __name__ == '__main__':
|
|
190 |
vc = VC(tgt_sr, config)
|
191 |
print(f"Model loaded: {name}")
|
192 |
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
|
|
193 |
with gr.Blocks() as app:
|
194 |
gr.Markdown(
|
195 |
"# <center> RVC Models [(Latest Update)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/releases/tag/20230428updated)\n"
|
@@ -198,7 +197,7 @@ if __name__ == '__main__':
|
|
198 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
199 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
200 |
)
|
201 |
-
for (folder_title, folder, description) in categories:
|
202 |
with gr.TabItem(folder_title):
|
203 |
if description:
|
204 |
gr.Markdown(f"<center>{description}")
|
|
|
149 |
|
150 |
if __name__ == '__main__':
|
151 |
load_hubert()
|
|
|
152 |
categories = []
|
153 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
154 |
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
155 |
with open("weights/folder_info.json", "r", encoding="utf-8") as f:
|
156 |
folder_info = json.load(f)
|
157 |
+
for category_name, category_info in folder_info.items():
|
158 |
+
if not category_info['enable']:
|
159 |
continue
|
160 |
+
category_title = category_info['title']
|
161 |
+
category_folder = category_info['folder_path']
|
162 |
+
description = category_info['description']
|
163 |
+
models = []
|
164 |
+
with open(f"weights/{category_folder}/model_info.json", "r", encoding="utf-8") as f:
|
|
|
165 |
models_info = json.load(f)
|
166 |
for name, info in models_info.items():
|
167 |
if not info['enable']:
|
168 |
continue
|
169 |
title = info['title']
|
170 |
author = info.get("author", None)
|
171 |
+
cover = f"weights/{category_folder}/{name}/{info['cover']}"
|
172 |
+
index = f"weights/{category_folder}/{name}/{info['feature_retrieval_library']}"
|
173 |
+
cpt = torch.load(f"weights/{category_folder}/{name}/{name}.pth", map_location="cpu")
|
174 |
tgt_sr = cpt["config"][-1]
|
175 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
176 |
if_f0 = cpt.get("f0", 1)
|
|
|
188 |
vc = VC(tgt_sr, config)
|
189 |
print(f"Model loaded: {name}")
|
190 |
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
191 |
+
categories.append([category_title, category_folder, description, models])
|
192 |
with gr.Blocks() as app:
|
193 |
gr.Markdown(
|
194 |
"# <center> RVC Models [(Latest Update)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/releases/tag/20230428updated)\n"
|
|
|
197 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
198 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
199 |
)
|
200 |
+
for (folder_title, folder, description, models) in categories:
|
201 |
with gr.TabItem(folder_title):
|
202 |
if description:
|
203 |
gr.Markdown(f"<center>{description}")
|
app.py
CHANGED
@@ -96,30 +96,28 @@ def change_to_tts_mode(tts_mode):
|
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
load_hubert()
|
99 |
-
models = []
|
100 |
categories = []
|
101 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
102 |
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
103 |
with open("weights/folder_info.json", "r", encoding="utf-8") as f:
|
104 |
folder_info = json.load(f)
|
105 |
-
for
|
106 |
-
if not
|
107 |
continue
|
108 |
-
|
109 |
-
|
110 |
-
description =
|
111 |
-
|
112 |
-
|
113 |
-
with open(f"weights/{folder}/model_info.json", "r", encoding="utf-8") as f:
|
114 |
models_info = json.load(f)
|
115 |
for name, info in models_info.items():
|
116 |
if not info['enable']:
|
117 |
continue
|
118 |
title = info['title']
|
119 |
author = info.get("author", None)
|
120 |
-
cover = f"weights/{
|
121 |
-
index = f"weights/{
|
122 |
-
cpt = torch.load(f"weights/{
|
123 |
tgt_sr = cpt["config"][-1]
|
124 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
125 |
if_f0 = cpt.get("f0", 1)
|
@@ -137,6 +135,7 @@ if __name__ == '__main__':
|
|
137 |
vc = VC(tgt_sr, config)
|
138 |
print(f"Model loaded: {name}")
|
139 |
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
|
|
140 |
with gr.Blocks() as app:
|
141 |
gr.Markdown(
|
142 |
"# <center> RVC Models [(Latest Update)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/releases/tag/20230428updated)\n"
|
@@ -145,7 +144,7 @@ if __name__ == '__main__':
|
|
145 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
146 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
147 |
)
|
148 |
-
for (folder_title, folder, description) in categories:
|
149 |
with gr.TabItem(folder_title):
|
150 |
if description:
|
151 |
gr.Markdown(f"<center>{description}")
|
|
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
load_hubert()
|
|
|
99 |
categories = []
|
100 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
101 |
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
102 |
with open("weights/folder_info.json", "r", encoding="utf-8") as f:
|
103 |
folder_info = json.load(f)
|
104 |
+
for category_name, category_info in folder_info.items():
|
105 |
+
if not category_info['enable']:
|
106 |
continue
|
107 |
+
category_title = category_info['title']
|
108 |
+
category_folder = category_info['folder_path']
|
109 |
+
description = category_info['description']
|
110 |
+
models = []
|
111 |
+
with open(f"weights/{category_folder}/model_info.json", "r", encoding="utf-8") as f:
|
|
|
112 |
models_info = json.load(f)
|
113 |
for name, info in models_info.items():
|
114 |
if not info['enable']:
|
115 |
continue
|
116 |
title = info['title']
|
117 |
author = info.get("author", None)
|
118 |
+
cover = f"weights/{category_folder}/{name}/{info['cover']}"
|
119 |
+
index = f"weights/{category_folder}/{name}/{info['feature_retrieval_library']}"
|
120 |
+
cpt = torch.load(f"weights/{category_folder}/{name}/{name}.pth", map_location="cpu")
|
121 |
tgt_sr = cpt["config"][-1]
|
122 |
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
|
123 |
if_f0 = cpt.get("f0", 1)
|
|
|
135 |
vc = VC(tgt_sr, config)
|
136 |
print(f"Model loaded: {name}")
|
137 |
models.append((name, title, author, cover, create_vc_fn(tgt_sr, net_g, vc, if_f0, index)))
|
138 |
+
categories.append([category_title, category_folder, description, models])
|
139 |
with gr.Blocks() as app:
|
140 |
gr.Markdown(
|
141 |
"# <center> RVC Models [(Latest Update)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/releases/tag/20230428updated)\n"
|
|
|
144 |
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/110kiMZTdP6Ri1lY9-NbQf17GVPPhHyeT?usp=sharing)\n\n"
|
145 |
"[![Original Repo](https://badgen.net/badge/icon/github?icon=github&label=Original%20Repo)](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)"
|
146 |
)
|
147 |
+
for (folder_title, folder, description, models) in categories:
|
148 |
with gr.TabItem(folder_title):
|
149 |
if description:
|
150 |
gr.Markdown(f"<center>{description}")
|