Spaces:
Running
Running
sigmatuse4
commited on
Commit
•
d02f2a3
0
Parent(s):
Duplicate from Kajise/Demucs_v4-FT_4s
Browse files- .gitattributes +35 -0
- README.md +14 -0
- app.py +104 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Demucs (Finetuned-4S)
|
3 |
+
emoji: 🐨
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: green
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.41.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: agpl-3.0
|
11 |
+
duplicated_from: Kajise/Demucs_v4-FT_4s
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
|
4 |
+
import os
|
5 |
+
from scipy.io.wavfile import write
|
6 |
+
|
7 |
+
import gradio as Gradio
|
8 |
+
from gradio.themes.base import Base
|
9 |
+
from gradio.themes.utils import colors, fonts, sizes
|
10 |
+
|
11 |
+
theme = Gradio.themes.Monochrome(
|
12 |
+
primary_hue="purple",
|
13 |
+
secondary_hue="purple",
|
14 |
+
neutral_hue="neutral",
|
15 |
+
radius_size=Gradio.themes.sizes.radius_sm,
|
16 |
+
font=[Gradio.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"],
|
17 |
+
)
|
18 |
+
|
19 |
+
class PurpleTheme(Base):
|
20 |
+
def __init__(
|
21 |
+
self,
|
22 |
+
*,
|
23 |
+
primary_hue: colors.Color | str = colors.purple,
|
24 |
+
secondary_hue: colors.Color | str = colors.purple,
|
25 |
+
neutral_hue: colors.Color | str = colors.neutral,
|
26 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
27 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
28 |
+
font: fonts.Font
|
29 |
+
| str
|
30 |
+
| Iterable[fonts.Font | str] = (
|
31 |
+
fonts.GoogleFont("Inter"),
|
32 |
+
"ui-sans-serif",
|
33 |
+
"sans-serif",
|
34 |
+
),
|
35 |
+
font_mono: fonts.Font
|
36 |
+
| str
|
37 |
+
| Iterable[fonts.Font | str] = (
|
38 |
+
fonts.GoogleFont("Space Grotesk"),
|
39 |
+
"ui-monospace",
|
40 |
+
"monospace",
|
41 |
+
),
|
42 |
+
):
|
43 |
+
super().__init__(
|
44 |
+
primary_hue=primary_hue,
|
45 |
+
secondary_hue=secondary_hue,
|
46 |
+
neutral_hue=neutral_hue,
|
47 |
+
spacing_size=spacing_size,
|
48 |
+
radius_size=radius_size,
|
49 |
+
font=font,
|
50 |
+
font_mono=font_mono,
|
51 |
+
)
|
52 |
+
super().set(
|
53 |
+
button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
|
54 |
+
button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
|
55 |
+
button_primary_text_color="white",
|
56 |
+
button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
|
57 |
+
block_shadow="*shadow_drop_lg",
|
58 |
+
button_shadow="*shadow_drop_lg",
|
59 |
+
input_background_fill="zinc",
|
60 |
+
input_border_color="*secondary_300",
|
61 |
+
input_shadow="*shadow_drop",
|
62 |
+
input_shadow_focus="*shadow_drop_lg",
|
63 |
+
)
|
64 |
+
|
65 |
+
custom_theme = PurpleTheme()
|
66 |
+
|
67 |
+
def run_demucs(audio):
|
68 |
+
os.makedirs("out", exist_ok=True)
|
69 |
+
write('test.wav', audio[0], audio[1])
|
70 |
+
result = os.system("python3 -m demucs.separate -n htdemucs_ft -d cpu test.wav -o out")
|
71 |
+
print(f"Demucs result: {result}")
|
72 |
+
|
73 |
+
# Check if files exist before returning
|
74 |
+
files = ["./out/htdemucs_ft/test/vocals.wav",
|
75 |
+
"./out/htdemucs_ft/test/bass.wav",
|
76 |
+
"./out/htdemucs_ft/test/drums.wav",
|
77 |
+
"./out/htdemucs_ft/test/other.wav"]
|
78 |
+
|
79 |
+
for file in files:
|
80 |
+
if not os.path.isfile(file):
|
81 |
+
print(f"File not found: {file}")
|
82 |
+
else:
|
83 |
+
print(f"File exists: {file}")
|
84 |
+
|
85 |
+
return files;
|
86 |
+
|
87 |
+
title = "Demucs (finetuned_4s)"
|
88 |
+
description = "<center>Uses the 'canary bleeding-edge' version of Demucs (v4) that introduces the latest Hybrid Transformer model <br/> Heavily inspired from <a href=\"https://huggingface.co/spaces/Thafx/Demucs_v4_2s_HT\">Thafx's Demucs v4 Space</a>, which is based on <a href=\"https://huggingface.co/spaces/akhaliq/demucs\">akhaliq's PIP Demucs Space</a></center>"
|
89 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1911.13254' target='_blank'>Music Source Separation in the Waveform Domain</a> | <a href='https://github.com/facebookresearch/demucs' target='_blank'>Github Repo</a></p>"
|
90 |
+
|
91 |
+
Gradio.Interface(
|
92 |
+
run_demucs,
|
93 |
+
Gradio.Audio(type="numpy", label="Input"),
|
94 |
+
[Gradio.Audio(type="filepath", label="Vocals", interactive=False),
|
95 |
+
Gradio.Audio(type="filepath", label="Bass", interactive=False),
|
96 |
+
Gradio.Audio(type="filepath", label="Drums", interactive=False),
|
97 |
+
Gradio.Audio(type="filepath", label="Other", interactive=False)],
|
98 |
+
title=title,
|
99 |
+
description=description,
|
100 |
+
article=article,
|
101 |
+
theme=custom_theme,
|
102 |
+
analytics_enabled=False,
|
103 |
+
css=".generating {visibility: hidden}"
|
104 |
+
).launch(enable_queue=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
git+https://github.com/facebookresearch/demucs#egg=demucs
|
2 |
+
gradio
|
3 |
+
scipy
|