Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import torch
|
| 3 |
import shutil
|
| 4 |
import logging
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
from PolUVR.separator import Separator
|
|
@@ -179,7 +181,23 @@ def rename_stems(audio, vocals_stem, instrumental_stem, other_stem, drums_stem,
|
|
| 179 |
}
|
| 180 |
return stems
|
| 181 |
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, batch_size, vocals_stem, instrumental_stem, other_stem, drums_stem, bass_stem, guitar_stem, piano_stem, progress=gr.Progress(track_tqdm=True)):
|
| 184 |
"""Separate audio using Roformer model."""
|
| 185 |
stemname = rename_stems(audio, vocals_stem, instrumental_stem, other_stem, drums_stem, bass_stem, guitar_stem, piano_stem, model_key)
|
|
@@ -508,7 +526,16 @@ with gr.Blocks(
|
|
| 508 |
with gr.Row():
|
| 509 |
guitar_stem = gr.Textbox(value="NAME_(STEM)_MODEL", label="Guitar Stem", info="Output example: Music_(Guitar)_BS-Roformer-Viperx-1297", placeholder="NAME_(STEM)_MODEL")
|
| 510 |
piano_stem = gr.Textbox(value="NAME_(STEM)_MODEL", label="Piano Stem", info="Output example: Music_(Piano)_BS-Roformer-Viperx-1297", placeholder="NAME_(STEM)_MODEL")
|
| 511 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
with gr.Tab("Credits"):
|
| 513 |
gr.Markdown(
|
| 514 |
"""
|
|
@@ -517,9 +544,11 @@ with gr.Blocks(
|
|
| 517 |
* Thanks to **[Hev832](https://huggingface.co/Hev832)** for the help with the code.
|
| 518 |
"""
|
| 519 |
)
|
| 520 |
-
|
| 521 |
demucs_model.change(update_stems, inputs=[demucs_model], outputs=stem6)
|
| 522 |
|
|
|
|
|
|
|
| 523 |
roformer_button.click(
|
| 524 |
roformer_separator,
|
| 525 |
inputs=[
|
|
|
|
| 1 |
import os
|
| 2 |
+
import re
|
| 3 |
import torch
|
| 4 |
import shutil
|
| 5 |
import logging
|
| 6 |
+
import subprocess
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
from PolUVR.separator import Separator
|
|
|
|
| 181 |
}
|
| 182 |
return stems
|
| 183 |
|
| 184 |
+
def leaderboard(list_filter, list_limit):
|
| 185 |
+
result = subprocess.run(
|
| 186 |
+
["PolUVR", "-l", f"--list_filter={list_filter}", f"--list_limit={list_limit}"],
|
| 187 |
+
capture_output=True,
|
| 188 |
+
text=True,
|
| 189 |
+
shell=True,
|
| 190 |
+
)
|
| 191 |
+
if result.returncode != 0:
|
| 192 |
+
return f"Error: {result.stderr}"
|
| 193 |
+
|
| 194 |
+
return "<table border='1'>" + "".join(
|
| 195 |
+
f"<tr style='{'font-weight: bold; font-size: 1.2em;' if i == 0 else ''}'>" +
|
| 196 |
+
"".join(f"<td>{cell}</td>" for cell in re.split(r"\s{2,}", line.strip())) +
|
| 197 |
+
"</tr>"
|
| 198 |
+
for i, line in enumerate(re.findall(r"^(?!-+)(.+)$", result.stdout.strip(), re.MULTILINE))
|
| 199 |
+
) + "</table>"
|
| 200 |
+
|
| 201 |
def roformer_separator(audio, model_key, seg_size, override_seg_size, overlap, pitch_shift, model_dir, out_dir, out_format, norm_thresh, amp_thresh, batch_size, vocals_stem, instrumental_stem, other_stem, drums_stem, bass_stem, guitar_stem, piano_stem, progress=gr.Progress(track_tqdm=True)):
|
| 202 |
"""Separate audio using Roformer model."""
|
| 203 |
stemname = rename_stems(audio, vocals_stem, instrumental_stem, other_stem, drums_stem, bass_stem, guitar_stem, piano_stem, model_key)
|
|
|
|
| 526 |
with gr.Row():
|
| 527 |
guitar_stem = gr.Textbox(value="NAME_(STEM)_MODEL", label="Guitar Stem", info="Output example: Music_(Guitar)_BS-Roformer-Viperx-1297", placeholder="NAME_(STEM)_MODEL")
|
| 528 |
piano_stem = gr.Textbox(value="NAME_(STEM)_MODEL", label="Piano Stem", info="Output example: Music_(Piano)_BS-Roformer-Viperx-1297", placeholder="NAME_(STEM)_MODEL")
|
| 529 |
+
|
| 530 |
+
with gr.Tab("Leaderboard"):
|
| 531 |
+
with gr.Group():
|
| 532 |
+
with gr.Row(equal_height=True):
|
| 533 |
+
list_filter = gr.Dropdown(value="vocals", choices=["vocals", "instrumental", "drums", "bass", "guitar", "piano", "other"], label="List filter", info="Filter and sort the model list by 'stem'")
|
| 534 |
+
list_limit = gr.Slider(minimum=1, maximum=10, step=1, value=5, label="List limit", info="Limit the number of models shown.")
|
| 535 |
+
list_button = gr.Button("Show list", variant="primary")
|
| 536 |
+
|
| 537 |
+
output_list = gr.HTML(label="Leaderboard")
|
| 538 |
+
|
| 539 |
with gr.Tab("Credits"):
|
| 540 |
gr.Markdown(
|
| 541 |
"""
|
|
|
|
| 544 |
* Thanks to **[Hev832](https://huggingface.co/Hev832)** for the help with the code.
|
| 545 |
"""
|
| 546 |
)
|
| 547 |
+
|
| 548 |
demucs_model.change(update_stems, inputs=[demucs_model], outputs=stem6)
|
| 549 |
|
| 550 |
+
list_button.click(leaderboard, inputs=[list_filter, list_limit], outputs=output_list)
|
| 551 |
+
|
| 552 |
roformer_button.click(
|
| 553 |
roformer_separator,
|
| 554 |
inputs=[
|