Eddycrack864 commited on
Commit
f5cfb96
·
verified ·
1 Parent(s): cbdf8e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +83 -334
app.py CHANGED
@@ -1,14 +1,14 @@
1
- import os
2
- import glob
3
- from pathlib import Path
4
  import gradio as gr
 
5
 
6
- roformer_models = [
7
- 'BS-Roformer-Viperx-1297.ckpt',
8
- 'BS-Roformer-Viperx-1296.ckpt',
9
- 'BS-Roformer-Viperx-1053.ckpt',
10
- 'Mel-Roformer-Viperx-1143.ckpt',
11
- ]
 
 
12
 
13
  mdx23c_models = [
14
  'MDX23C_D1581.ckpt',
@@ -88,336 +88,85 @@ vrarch_models = [
88
  ]
89
 
90
  demucs_models = [
91
- 'htdemucs_ft.yaml',
92
  'htdemucs.yaml',
93
  'hdemucs_mmi.yaml',
94
- 'htdemucs_6s.yaml',
95
  ]
96
 
97
- output_format = [
98
- 'wav',
99
- 'flac',
100
- 'mp3',
101
- ]
 
 
102
 
103
- mdxnet_overlap_values = [
104
- '0.25',
105
- '0.5',
106
- '0.75',
107
- '0.99',
108
- ]
109
 
110
- vrarch_window_size_values = [
111
- '320',
112
- '512',
113
- '1024',
114
- ]
 
 
 
115
 
116
- with gr.Blocks(title="🎵 UVR5 UI 🎵") as app:
117
  gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
118
- with gr.Tabs():
119
- with gr.TabItem("BS-Roformer"):
120
- with gr.Row():
121
- roformer_model = gr.Dropdown(
122
- label = "Select the Model",
123
- choices = roformer_models,
124
- interactive = True
125
- )
126
- roformer_output_format = gr.Dropdown(
127
- label = "Select the Output Format",
128
- choices = output_format,
129
- interactive = True
130
- )
131
- with gr.Row():
132
- roformer_overlap = gr.Slider(
133
- minimum = 2,
134
- maximum = 4,
135
- step = 1,
136
- label = "Overlap",
137
- info = "Amount of overlap between prediction windows.",
138
- value = 4,
139
- interactive = True
140
- )
141
- with gr.Row():
142
- roformer_audio = gr.Audio(
143
- label = "Input Audio",
144
- interactive = True
145
- )
146
- with gr.Row():
147
- roformer_button = gr.Button("Separate", variant = "primary") #revisar esto
148
- #resto del codigo de lo que hace el boton
149
- with gr.Row():
150
- roformer_stem_1 = gr.Audio(
151
- show_download_button = True,
152
- interactive = False,
153
- label = "Stem 1"
154
- )
155
- roformer_stem_2 = gr.Audio(
156
- show_download_button = True,
157
- interactive = False,
158
- label = "Stem 2"
159
- )
160
- with gr.Row():
161
- roformer_status = gr.Textbox(
162
- label = "Output Information",
163
- interactive = False
164
- #añadir algo que muestre aqui todo
165
- )
166
- with gr.TabItem("MDX23C"):
167
- with gr.Row():
168
- mdx23c_model = gr.Dropdown(
169
- label = "Select the Model",
170
- choices = mdx23c_models,
171
- interactive = True
172
- )
173
- mdx23c_output_format = gr.Dropdown(
174
- label = "Select the Output Format",
175
- choices = output_format,
176
- interactive = True
177
- )
178
- with gr.Row():
179
- mdx23c_segment_size = gr.Slider(
180
- minimum = 32,
181
- maximum = 4000,
182
- step = 32,
183
- label = "Segment Size",
184
- info = "Larger consumes more resources, but may give better results.",
185
- value = 256,
186
- interactive = True
187
- )
188
- mdx23c_overlap = gr.Slider(
189
- minimum = 2,
190
- maximum = 50,
191
- step = 1,
192
- label = "Overlap",
193
- info = "Amount of overlap between prediction windows.",
194
- value = 8,
195
- interactive = True
196
- )
197
- with gr.Row():
198
- mdx23c_audio = gr.Audio(
199
- label = "Input Audio",
200
- interactive = True
201
- )
202
- with gr.Row():
203
- mdx23c_button = gr.Button("Separate", variant = "primary") #revisar esto
204
- #resto del codigo de lo que hace el boton
205
- with gr.Row():
206
- mdx23c_stem_1 = gr.Audio(
207
- show_download_button = True,
208
- interactive = False,
209
- label = "Stem 1"
210
- )
211
- mdx23c_stem_2 = gr.Audio(
212
- show_download_button = True,
213
- interactive = False,
214
- label = "Stem 2"
215
- )
216
- with gr.Row():
217
- mdx23c_status = gr.Textbox(
218
- label = "Output Information",
219
- interactive = False
220
- #añadir algo que muestre aqui todo
221
- )
222
- with gr.TabItem("MDX-NET"):
223
- with gr.Row():
224
- mdxnet_model = gr.Dropdown(
225
- label = "Select the Model",
226
- choices = mdxnet_models,
227
- interactive = True
228
- )
229
- mdxnet_output_format = gr.Dropdown(
230
- label = "Select the Output Format",
231
- choices = output_format,
232
- interactive = True
233
- )
234
- with gr.Row():
235
- mdxnet_segment_size = gr.Slider(
236
- minimum = 32,
237
- maximum = 4000,
238
- step = 32,
239
- label = "Segment Size",
240
- info = "Larger consumes more resources, but may give better results.",
241
- value = 256,
242
- interactive = True
243
- )
244
- mdxnet_overlap = gr.Dropdown(
245
- label = "Overlap",
246
- choices = mdxnet_overlap_values,
247
- value = mdxnet_overlap_values[0],
248
- interactive = True
249
- )
250
- mdxnet_denoise = gr.Checkbox(
251
- label = "Denoise",
252
- info = "Enable denoising during separation.",
253
- value = True,
254
- interactive = True
255
- )
256
- with gr.Row():
257
- mdxnet_audio = gr.Audio(
258
- label = "Input Audio",
259
- interactive = True
260
- )
261
- with gr.Row():
262
- mdxnet_button = gr.Button("Separate", variant = "primary") #revisar esto
263
- #resto del codigo de lo que hace el boton
264
- with gr.Row():
265
- mdxnet_stem_1 = gr.Audio(
266
- show_download_button = True,
267
- interactive = False,
268
- label = "Stem 1"
269
- )
270
- mdxnet_stem_2 = gr.Audio(
271
- show_download_button = True,
272
- interactive = False,
273
- label = "Stem 2"
274
- )
275
- with gr.Row():
276
- mdxnet_status = gr.Textbox(
277
- label = "Output Information",
278
- interactive = False
279
- #añadir algo que muestre aqui todo
280
- )
281
- with gr.TabItem("VR ARCH"):
282
- with gr.Row():
283
- vrarch_model = gr.Dropdown(
284
- label = "Select the Model",
285
- choices = vrarch_models,
286
- interactive = True
287
- )
288
- vrarch_output_format = gr.Dropdown(
289
- label = "Select the Output Format",
290
- choices = output_format,
291
- interactive = True
292
- )
293
- with gr.Row():
294
- vrarch_window_size = gr.Dropdown(
295
- label = "Window Size",
296
- choices = vrarch_window_size_values,
297
- value = vrarch_window_size_values[0],
298
- interactive = True
299
- )
300
- vrarch_agression = gr.Slider(
301
- minimum = 1,
302
- maximum = 50,
303
- step = 1,
304
- label = "Agression",
305
- info = "Intensity of primary stem extraction.",
306
- value = 5,
307
- interactive = True
308
- )
309
- vrarch_tta = gr.Checkbox(
310
- label = "TTA",
311
- info = "Enable Test-Time-Augmentation; slow but improves quality.",
312
- value = True,
313
- interactive = True
314
- )
315
- vrarch_high_end_process = gr.Checkbox(
316
- label = "High End Process",
317
- info = "Mirror the missing frequency range of the output.",
318
- value = False,
319
- interactive = True
320
- )
321
- with gr.Row():
322
- vrarch_audio = gr.Audio(
323
- label = "Input Audio",
324
- interactive = True
325
- )
326
- with gr.Row():
327
- vrarch_button = gr.Button("Separate", variant = "primary") #revisar esto
328
- #resto del codigo de lo que hace el boton
329
- with gr.Row():
330
- vrarch_stem_1 = gr.Audio(
331
- show_download_button = True,
332
- interactive = False,
333
- label = "Stem 1"
334
- )
335
- vrarch_stem_2 = gr.Audio(
336
- show_download_button = True,
337
- interactive = False,
338
- label = "Stem 2"
339
- )
340
- with gr.Row():
341
- vrarch_status = gr.Textbox(
342
- label = "Output Information",
343
- interactive = False
344
- #añadir algo que muestre aqui todo
345
- )
346
- with gr.TabItem("Demucs"):
347
- with gr.Row():
348
- demucs_model = gr.Dropdown(
349
- label = "Select the Model",
350
- choices = demucs_models,
351
- interactive = True
352
- )
353
- demucs_output_format = gr.Dropdown(
354
- label = "Select the Output Format",
355
- choices = output_format,
356
- interactive = True
357
- )
358
- with gr.Row():
359
- demucs_shifts = gr.Slider(
360
- minimum = 1,
361
- maximum = 20,
362
- step = 1,
363
- label = "Shifts",
364
- info = "Number of predictions with random shifts, higher = slower but better quality.",
365
- value = 2,
366
- interactive = True
367
- )
368
- demucs_overlap = gr.Slider(
369
- minimum = 0.001,
370
- maximum = 0.999,
371
- step = 0.001,
372
- label = "Overlap",
373
- info = "Amount of overlap between prediction windows.",
374
- value = 0.025,
375
- interactive = True
376
- )
377
- with gr.Row():
378
- demucs_audio = gr.Audio(
379
- label = "Input Audio",
380
- interactive = True
381
- )
382
- with gr.Row():
383
- demucs_button = gr.Button("Separate", variant = "primary") #revisar esto
384
- #resto del codigo de lo que hace el boton
385
- with gr.Row():
386
- demucs_stem_1 = gr.Audio(
387
- show_download_button = True,
388
- interactive = False,
389
- label = "Stem 1"
390
- )
391
- demucs_stem_2 = gr.Audio(
392
- show_download_button = True,
393
- interactive = False,
394
- label = "Stem 2"
395
- )
396
- demucs_stem_3 = gr.Audio(
397
- show_download_button = True,
398
- interactive = False,
399
- label = "Stem 3"
400
- )
401
- demucs_stem_4 = gr.Audio(
402
- show_download_button = True,
403
- interactive = False,
404
- label = "Stem 4"
405
- )
406
- with gr.Row():
407
- demucs_stem_5 = gr.Audio(
408
- show_download_button = True,
409
- interactive = False,
410
- label = "Stem 5"
411
- )
412
- demucs_stem_6 = gr.Audio(
413
- show_download_button = True,
414
- interactive = False,
415
- label = "Stem 6"
416
- )
417
- with gr.Row():
418
- demucs_status = gr.Textbox(
419
- label = "Output Information",
420
- interactive = False
421
- #añadir algo que muestre aqui todo
422
- )
423
- app.launch()
 
 
 
 
1
  import gradio as gr
2
+ from audio_separator.separator import Separator
3
 
4
+ separator = Separator()
5
+
6
+ roformer_models = {
7
+ 'BS-Roformer-Viperx-1297.ckpt': 'model_bs_roformer_ep_317_sdr_12.9755.ckpt',
8
+ 'BS-Roformer-Viperx-1296.ckpt': 'model_bs_roformer_ep_368_sdr_12.9628.ckpt',
9
+ 'BS-Roformer-Viperx-1053.ckpt': 'model_bs_roformer_ep_937_sdr_10.5309.ckpt',
10
+ 'Mel-Roformer-Viperx-1143.ckpt': 'model_mel_band_roformer_ep_3005_sdr_11.4360.ckpt'
11
+ }
12
 
13
  mdx23c_models = [
14
  'MDX23C_D1581.ckpt',
 
88
  ]
89
 
90
  demucs_models = [
91
+ 'htdemucs_ft.yaml',
92
  'htdemucs.yaml',
93
  'hdemucs_mmi.yaml',
 
94
  ]
95
 
96
+ def roformer_separator(audio, checkpoint_name):
97
+ full_checkpoint_name = roformer_models[checkpoint_name]
98
+ separator.load_model(full_checkpoint_name)
99
+ output_files = separator.separate(audio)
100
+ stem1 = output_files[0]
101
+ stem2 = output_files[1]
102
+ return stem1, stem2
103
 
104
+ def mdx_vr_separator(audio, checkpoint_name):
105
+ separator.load_model(checkpoint_name)
106
+ output_files = separator.separate(audio)
107
+ stem1 = output_files[0]
108
+ stem2 = output_files[1]
109
+ return stem1, stem2
110
 
111
+ def demucs_separator(audio, checkpoint_name):
112
+ separator.load_model(checkpoint_name)
113
+ output_files = separator.separate(audio)
114
+ stem1 = output_files[0]
115
+ stem2 = output_files[1]
116
+ stem3 = output_files[2]
117
+ stem4 = output_files[3]
118
+ return stem1, stem2, stem3, stem4
119
 
120
+ with gr.Blocks(title="🎵 UVR5 UI 🎵") as demo:
121
  gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
122
+ with gr.Tab("Vocal Separator (UVR)"):
123
+ gr.Markdown("Separate vocals and instruments from an audio file using UVR models.")
124
+ with gr.Tab("Mel/BS Roformer"):
125
+ roformer_audio_file = gr.Audio(label="Audio File", type="filepath")
126
+ with gr.Row():
127
+ roformer_model = gr.Dropdown(label="Model", choices=list(roformer_models.keys()))
128
+ roformer_button = gr.Button("Separate", variant="primary")
129
+ roformer_stem1 = gr.Audio(type="filepath", label="Stem 1")
130
+ roformer_stem2 = gr.Audio(type="filepath", label="Stem 2")
131
+
132
+ roformer_button.click(roformer_separator, [roformer_audio_file, roformer_model], [roformer_stem1, roformer_stem2])
133
+ with gr.Tab("MDX23C"):
134
+ mdx23c_audio_file = gr.Audio(label="Audio File", type="filepath")
135
+ with gr.Row():
136
+ mdx23c_model = gr.Dropdown(label="Model", choices=mdx23c_models)
137
+ mdx23c_button = gr.Button("Separate", variant="primary")
138
+ mdx23c_stem1 = gr.Audio(type="filepath", label="Stem 1")
139
+ mdx23c_stem2 = gr.Audio(type="filepath", label="Stem 2")
140
+
141
+ mdx23c_button.click(mdx_vr_separator, [mdx23c_audio_file, mdx23c_model], [mdx23c_stem1, mdx23c_stem2])
142
+ with gr.Tab("MDX-NET"):
143
+ mdxnet_audio_file = gr.Audio(label="Audio File", type="filepath")
144
+ with gr.Row():
145
+ mdxnet_model = gr.Dropdown(label="Model", choices=mdxnet_models)
146
+ mdxnet_button = gr.Button("Separate", variant="primary")
147
+ mdxnet_stem1 = gr.Audio(type="filepath", label="Stem 1")
148
+ mdxnet_stem2 = gr.Audio(type="filepath", label="Stem 2")
149
+
150
+ mdxnet_button.click(mdx_vr_separator, [mdxnet_audio_file, mdxnet_model], [mdxnet_stem1, mdxnet_stem2])
151
+ with gr.Tab("VR-ARCH"):
152
+ vr_audio_file = gr.Audio(label="Audio File", type="filepath")
153
+ with gr.Row():
154
+ vr_model = gr.Dropdown(label="Model", choices=vrarch_models)
155
+ vr_button = gr.Button("Separate", variant="primary")
156
+ vr_stem1 = gr.Audio(type="filepath", label="Stem 1")
157
+ vr_stem2 = gr.Audio(type="filepath", label="Stem 2")
158
+
159
+ vr_button.click(mdx_vr_separator, [vr_audio_file, vr_model], [vr_stem1, vr_stem2])
160
+ with gr.Tab("Demucs"):
161
+ demucs_audio_file = gr.Audio(label="Audio File", type="filepath")
162
+ with gr.Row():
163
+ demucs_model = gr.Dropdown(label="Model", choices=demucs_models)
164
+ demucs_button = gr.Button("Separate", variant="primary")
165
+ demucs_stem1 = gr.Audio(type="filepath", label="Stem 1")
166
+ demucs_stem2 = gr.Audio(type="filepath", label="Stem 2")
167
+ demucs_stem3 = gr.Audio(type="filepath", label="Stem 3")
168
+ demucs_stem4 = gr.Audio(type="filepath", label="Stem 4")
169
+
170
+ demucs_button.click(demucs_separator, [demucs_audio_file, demucs_model], [demucs_stem1, demucs_stem2, demucs_stem3, demucs_stem4])
171
+
172
+ demo.launch()