Commit
•
11220de
1
Parent(s):
8a66fb4
Update webUI.py
Browse files
webUI.py
CHANGED
@@ -6,7 +6,7 @@ import soundfile
|
|
6 |
import numpy as np
|
7 |
|
8 |
import gradio as gr
|
9 |
-
from UVR_interface import root, UVRInterface, VR_MODELS_DIR, MDX_MODELS_DIR
|
10 |
from gui_data.constants import *
|
11 |
from typing import List, Dict, Callable, Union
|
12 |
|
@@ -28,14 +28,12 @@ class UVRWebUI:
|
|
28 |
models_url = {}
|
29 |
for arch, download_list_key in zip([VR_ARCH_TYPE, MDX_ARCH_TYPE], ["vr_download_list", "mdx_download_list"]):
|
30 |
models_url[arch] = {model: NORMAL_REPO+model_path for model, model_path in online_data[download_list_key].items()}
|
31 |
-
models_url[DEMUCS_ARCH_TYPE] = online_data["demucs_download_list"]
|
32 |
return models_url
|
33 |
|
34 |
def get_local_models(self, arch: str) -> List[str]:
|
35 |
model_config = {
|
36 |
VR_ARCH_TYPE: (VR_MODELS_DIR, ".pth"),
|
37 |
MDX_ARCH_TYPE: (MDX_MODELS_DIR, ".onnx"),
|
38 |
-
DEMUCS_ARCH_TYPE: (DEMUCS_MODELS_DIR, ".yaml"),
|
39 |
}
|
40 |
try:
|
41 |
model_dir, suffix = model_config[arch]
|
@@ -50,8 +48,6 @@ class UVRWebUI:
|
|
50 |
elif arch == MDX_ARCH_TYPE:
|
51 |
root.mdx_batch_size_var.set(setting1)
|
52 |
root.compensate_var.set(setting2)
|
53 |
-
elif arch == DEMUCS_ARCH_TYPE:
|
54 |
-
pass
|
55 |
|
56 |
def arch_select_update(self, arch: str) -> List[Dict]:
|
57 |
choices = self.get_local_models(arch)
|
@@ -63,10 +59,6 @@ class UVRWebUI:
|
|
63 |
model_update = self.model_choice.update(choices=choices, value=CHOOSE_MODEL, label=CHOOSE_MDX_MODEL_MAIN_LABEL)
|
64 |
setting1_update = self.arch_setting1.update(choices=BATCH_SIZE, label=BATCHES_MDX_MAIN_LABEL, value=root.mdx_batch_size_var.get())
|
65 |
setting2_update = self.arch_setting2.update(choices=VOL_COMPENSATION, label=VOL_COMP_MDX_MAIN_LABEL, value=root.compensate_var.get())
|
66 |
-
elif arch == DEMUCS_ARCH_TYPE:
|
67 |
-
model_update = self.model_choice.update(choices=choices, value=CHOOSE_MODEL, label=CHOOSE_DEMUCS_MODEL_MAIN_LABEL)
|
68 |
-
setting1_update = self.arch_setting1.update(choices=VR_WINDOW, label=WINDOW_SIZE_MAIN_LABEL, value=root.window_size_var.get())
|
69 |
-
setting2_update = self.arch_setting2.update(choices=VR_AGGRESSION, label=AGGRESSION_SETTING_MAIN_LABEL, value=root.aggression_setting_var.get())
|
70 |
else:
|
71 |
raise gr.Error(f"Unkown arch type: {arch}")
|
72 |
return [model_update, setting1_update, setting2_update]
|
@@ -160,7 +152,7 @@ class UVRWebUI:
|
|
160 |
with gr.TabItem("process"):
|
161 |
with gr.Row():
|
162 |
self.arch_choice = gr.Dropdown(
|
163 |
-
choices=[VR_ARCH_TYPE, MDX_ARCH_TYPE
|
164 |
label=CHOOSE_PROC_METHOD_MAIN_LABEL, interactive=True)
|
165 |
self.model_choice = gr.Dropdown(
|
166 |
choices=self.get_local_models(VR_ARCH_TYPE), value=CHOOSE_MODEL,
|
@@ -197,39 +189,10 @@ class UVRWebUI:
|
|
197 |
|
198 |
with gr.TabItem("settings"):
|
199 |
with gr.Tabs():
|
200 |
-
with gr.TabItem("Settings Guide"):
|
201 |
-
pass
|
202 |
with gr.TabItem("Additional Settigns"):
|
203 |
self.wav_type = gr.Dropdown(choices=WAV_TYPE, label="Wav Type", value="PCM_16", interactive=True)
|
204 |
self.mp3_rate = gr.Dropdown(choices=MP3_BIT_RATES, label="MP3 Bitrate", value="320k",interactive=True)
|
205 |
-
|
206 |
-
|
207 |
-
def md_url(url, text=None):
|
208 |
-
if text is None:
|
209 |
-
text = url
|
210 |
-
return f"[{url}]({url})"
|
211 |
-
|
212 |
-
with gr.Row():
|
213 |
-
vr_models = self.models_url[VR_ARCH_TYPE]
|
214 |
-
self.vr_download_choice = gr.Dropdown(choices=list(vr_models.keys()), label=f"Select {VR_ARCH_TYPE} Model", interactive=True)
|
215 |
-
self.vr_download_url = gr.Markdown()
|
216 |
-
self.vr_download_choice.change(lambda model: md_url(vr_models[model]), inputs=self.vr_download_choice, outputs=self.vr_download_url)
|
217 |
-
with gr.Row(variant="panel"):
|
218 |
-
mdx_models = self.models_url[MDX_ARCH_TYPE]
|
219 |
-
self.mdx_download_choice = gr.Dropdown(choices=list(mdx_models.keys()), label=f"Select {MDX_ARCH_TYPE} Model", interactive=True)
|
220 |
-
self.mdx_download_url = gr.Markdown()
|
221 |
-
self.mdx_download_choice.change(lambda model: md_url(mdx_models[model]), inputs=self.mdx_download_choice, outputs=self.mdx_download_url)
|
222 |
-
with gr.Row(variant="panel"):
|
223 |
-
demucs_models: Dict[str, Dict] = self.models_url[DEMUCS_ARCH_TYPE]
|
224 |
-
self.demucs_download_choice = gr.Dropdown(choices=list(demucs_models.keys()), label=f"Select {DEMUCS_ARCH_TYPE} Model", interactive=True)
|
225 |
-
self.demucs_download_url = gr.Markdown()
|
226 |
-
|
227 |
-
self.demucs_download_choice.change(
|
228 |
-
lambda model: "\n".join([
|
229 |
-
"- " + md_url(url, text=filename) for filename, url in demucs_models[model].items()]),
|
230 |
-
inputs=self.demucs_download_choice,
|
231 |
-
outputs=self.demucs_download_url)
|
232 |
-
|
233 |
self.arch_choice.change(
|
234 |
self.arch_select_update, inputs=self.arch_choice,
|
235 |
outputs=[self.model_choice, self.arch_setting1, self.arch_setting2])
|
@@ -270,8 +233,6 @@ for category, models in model_dict.items():
|
|
270 |
model_path = 'models/VR_Models'
|
271 |
elif category == 'MDX-Net':
|
272 |
model_path = 'models/MDX_Net_Models'
|
273 |
-
elif category == 'Demucs':
|
274 |
-
model_path = 'models/Demucs_Models'
|
275 |
for model_name, model_url in models.items():
|
276 |
cmd = f"aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {model_path} -Z {model_url}"
|
277 |
os.system(cmd)
|
|
|
6 |
import numpy as np
|
7 |
|
8 |
import gradio as gr
|
9 |
+
from UVR_interface import root, UVRInterface, VR_MODELS_DIR, MDX_MODELS_DIR
|
10 |
from gui_data.constants import *
|
11 |
from typing import List, Dict, Callable, Union
|
12 |
|
|
|
28 |
models_url = {}
|
29 |
for arch, download_list_key in zip([VR_ARCH_TYPE, MDX_ARCH_TYPE], ["vr_download_list", "mdx_download_list"]):
|
30 |
models_url[arch] = {model: NORMAL_REPO+model_path for model, model_path in online_data[download_list_key].items()}
|
|
|
31 |
return models_url
|
32 |
|
33 |
def get_local_models(self, arch: str) -> List[str]:
|
34 |
model_config = {
|
35 |
VR_ARCH_TYPE: (VR_MODELS_DIR, ".pth"),
|
36 |
MDX_ARCH_TYPE: (MDX_MODELS_DIR, ".onnx"),
|
|
|
37 |
}
|
38 |
try:
|
39 |
model_dir, suffix = model_config[arch]
|
|
|
48 |
elif arch == MDX_ARCH_TYPE:
|
49 |
root.mdx_batch_size_var.set(setting1)
|
50 |
root.compensate_var.set(setting2)
|
|
|
|
|
51 |
|
52 |
def arch_select_update(self, arch: str) -> List[Dict]:
|
53 |
choices = self.get_local_models(arch)
|
|
|
59 |
model_update = self.model_choice.update(choices=choices, value=CHOOSE_MODEL, label=CHOOSE_MDX_MODEL_MAIN_LABEL)
|
60 |
setting1_update = self.arch_setting1.update(choices=BATCH_SIZE, label=BATCHES_MDX_MAIN_LABEL, value=root.mdx_batch_size_var.get())
|
61 |
setting2_update = self.arch_setting2.update(choices=VOL_COMPENSATION, label=VOL_COMP_MDX_MAIN_LABEL, value=root.compensate_var.get())
|
|
|
|
|
|
|
|
|
62 |
else:
|
63 |
raise gr.Error(f"Unkown arch type: {arch}")
|
64 |
return [model_update, setting1_update, setting2_update]
|
|
|
152 |
with gr.TabItem("process"):
|
153 |
with gr.Row():
|
154 |
self.arch_choice = gr.Dropdown(
|
155 |
+
choices=[VR_ARCH_TYPE, MDX_ARCH_TYPE], value=VR_ARCH_TYPE, # choices=[VR_ARCH_TYPE, MDX_ARCH_TYPE, DEMUCS_ARCH_TYPE], value=VR_ARCH_TYPE,
|
156 |
label=CHOOSE_PROC_METHOD_MAIN_LABEL, interactive=True)
|
157 |
self.model_choice = gr.Dropdown(
|
158 |
choices=self.get_local_models(VR_ARCH_TYPE), value=CHOOSE_MODEL,
|
|
|
189 |
|
190 |
with gr.TabItem("settings"):
|
191 |
with gr.Tabs():
|
|
|
|
|
192 |
with gr.TabItem("Additional Settigns"):
|
193 |
self.wav_type = gr.Dropdown(choices=WAV_TYPE, label="Wav Type", value="PCM_16", interactive=True)
|
194 |
self.mp3_rate = gr.Dropdown(choices=MP3_BIT_RATES, label="MP3 Bitrate", value="320k",interactive=True)
|
195 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
self.arch_choice.change(
|
197 |
self.arch_select_update, inputs=self.arch_choice,
|
198 |
outputs=[self.model_choice, self.arch_setting1, self.arch_setting2])
|
|
|
233 |
model_path = 'models/VR_Models'
|
234 |
elif category == 'MDX-Net':
|
235 |
model_path = 'models/MDX_Net_Models'
|
|
|
|
|
236 |
for model_name, model_url in models.items():
|
237 |
cmd = f"aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {model_path} -Z {model_url}"
|
238 |
os.system(cmd)
|