Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ except NameError:
|
|
| 28 |
pass
|
| 29 |
|
| 30 |
def load_model():
|
| 31 |
-
print(">>>
|
| 32 |
try:
|
| 33 |
checkpoint_path = hf_hub_download(
|
| 34 |
repo_id="Tachyeon/IAM-RoFormer-Model-Weights",
|
|
@@ -98,159 +98,204 @@ def separate_audio(audio_path):
|
|
| 98 |
return outputs
|
| 99 |
|
| 100 |
# ==========================================
|
| 101 |
-
# 2.
|
| 102 |
# ==========================================
|
| 103 |
css = """
|
| 104 |
-
@import url('https://fonts.googleapis.com/css2?family=
|
| 105 |
|
| 106 |
:root {
|
| 107 |
-
--bg-
|
| 108 |
-
--
|
| 109 |
-
--
|
| 110 |
-
--
|
| 111 |
-
--
|
| 112 |
-
--
|
| 113 |
-
--text-
|
|
|
|
| 114 |
}
|
| 115 |
|
| 116 |
body, .gradio-container {
|
| 117 |
-
background-color: var(--bg-
|
| 118 |
-
color: var(--text-
|
| 119 |
-
font-family: '
|
| 120 |
margin: 0; padding: 0;
|
| 121 |
}
|
| 122 |
|
| 123 |
-
/* CONTAINER
|
| 124 |
-
.
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
-
/*
|
| 131 |
-
.
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
-
.
|
| 137 |
-
font-
|
| 138 |
-
font-size: 5rem;
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
text-transform: uppercase;
|
| 142 |
-
color: white;
|
| 143 |
-
letter-spacing: 2px;
|
| 144 |
}
|
| 145 |
-
.
|
| 146 |
-
font-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
font-weight: 600;
|
| 150 |
-
letter-spacing: 1px;
|
| 151 |
-
text-transform: uppercase;
|
| 152 |
-
margin-top: 5px;
|
| 153 |
}
|
| 154 |
|
| 155 |
-
/*
|
| 156 |
-
.
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
margin-bottom: 0px;
|
| 161 |
}
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
border
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
text-transform: uppercase;
|
| 171 |
letter-spacing: 1px;
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
padding:
|
| 175 |
}
|
| 176 |
|
| 177 |
-
/*
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
color: #000 !important;
|
| 181 |
-
font-family: 'Work Sans', sans-serif !important;
|
| 182 |
-
font-weight: 800 !important;
|
| 183 |
-
font-size: 1.2rem !important;
|
| 184 |
-
text-transform: uppercase !important;
|
| 185 |
-
border: none !important;
|
| 186 |
-
border-radius: 0px !important; /* Sharp Edges */
|
| 187 |
-
padding: 20px !important;
|
| 188 |
-
transition: all 0.2s ease-in-out !important;
|
| 189 |
}
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
|
|
|
| 193 |
}
|
| 194 |
|
| 195 |
-
/* AUDIO
|
| 196 |
-
.audio-
|
| 197 |
-
background:
|
| 198 |
-
border:
|
| 199 |
-
border-radius:
|
| 200 |
-
margin-bottom: 15px !important;
|
| 201 |
}
|
| 202 |
|
| 203 |
-
/*
|
| 204 |
-
|
| 205 |
-
|
|
|
|
| 206 |
font-weight: 600 !important;
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
font-size: 0.8rem;
|
|
|
|
|
|
|
|
|
|
| 209 |
}
|
| 210 |
"""
|
| 211 |
|
| 212 |
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
| 213 |
|
| 214 |
-
with gr.Column(elem_classes="
|
| 215 |
|
| 216 |
-
# 1.
|
| 217 |
-
with gr.
|
| 218 |
gr.HTML("""
|
| 219 |
-
<div>
|
| 220 |
-
<div class="
|
| 221 |
-
<div class="
|
| 222 |
</div>
|
| 223 |
""")
|
| 224 |
|
| 225 |
-
# 2. MAIN
|
| 226 |
-
with gr.Row(
|
| 227 |
|
| 228 |
-
# LEFT
|
| 229 |
-
with gr.Column(
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
gr.HTML('<div class="card-header">Stem Output</div>')
|
| 244 |
-
with gr.Column(elem_classes="card-content"):
|
| 245 |
-
with gr.Row():
|
| 246 |
-
out_vocals = gr.Audio(label="VOCALS", interactive=False, elem_classes="audio-player")
|
| 247 |
-
out_drums = gr.Audio(label="DRUMS / MRIDANGAM", interactive=False, elem_classes="audio-player")
|
| 248 |
-
with gr.Row():
|
| 249 |
-
out_bass = gr.Audio(label="BASS / TANPURA", interactive=False, elem_classes="audio-player")
|
| 250 |
-
out_other = gr.Audio(label="OTHER / VIOLIN", interactive=False, elem_classes="audio-player")
|
| 251 |
|
| 252 |
# LOGIC
|
| 253 |
-
|
| 254 |
fn=separate_audio,
|
| 255 |
inputs=[input_audio],
|
| 256 |
outputs=[out_vocals, out_drums, out_bass, out_other]
|
|
|
|
| 28 |
pass
|
| 29 |
|
| 30 |
def load_model():
|
| 31 |
+
print(">>> Loading Engine...")
|
| 32 |
try:
|
| 33 |
checkpoint_path = hf_hub_download(
|
| 34 |
repo_id="Tachyeon/IAM-RoFormer-Model-Weights",
|
|
|
|
| 98 |
return outputs
|
| 99 |
|
| 100 |
# ==========================================
|
| 101 |
+
# 2. PRO DAW INTERFACE STYLING
|
| 102 |
# ==========================================
|
| 103 |
css = """
|
| 104 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');
|
| 105 |
|
| 106 |
:root {
|
| 107 |
+
--bg-base: #121212;
|
| 108 |
+
--bg-panel: #1E1E1E;
|
| 109 |
+
--bg-input: #252525;
|
| 110 |
+
--border-dim: #333333;
|
| 111 |
+
--accent-blue: #3B82F6; /* Professional Studio Blue */
|
| 112 |
+
--accent-hover: #2563EB;
|
| 113 |
+
--text-main: #FFFFFF;
|
| 114 |
+
--text-muted: #A0A0A0;
|
| 115 |
}
|
| 116 |
|
| 117 |
body, .gradio-container {
|
| 118 |
+
background-color: var(--bg-base) !important;
|
| 119 |
+
color: var(--text-main) !important;
|
| 120 |
+
font-family: 'Inter', sans-serif !important;
|
| 121 |
margin: 0; padding: 0;
|
| 122 |
}
|
| 123 |
|
| 124 |
+
/* APP CONTAINER */
|
| 125 |
+
.app-wrapper {
|
| 126 |
+
max-width: 1600px;
|
| 127 |
+
margin: 0 auto;
|
| 128 |
+
padding: 20px;
|
| 129 |
+
height: 100vh;
|
| 130 |
+
display: flex;
|
| 131 |
+
flex-direction: column;
|
| 132 |
}
|
| 133 |
|
| 134 |
+
/* TOP NAVIGATION */
|
| 135 |
+
.nav-bar {
|
| 136 |
+
display: flex;
|
| 137 |
+
justify-content: space-between;
|
| 138 |
+
align-items: center;
|
| 139 |
+
border-bottom: 1px solid var(--border-dim);
|
| 140 |
+
padding-bottom: 15px;
|
| 141 |
+
margin-bottom: 20px;
|
| 142 |
}
|
| 143 |
+
.logo {
|
| 144 |
+
font-weight: 800;
|
| 145 |
+
font-size: 1.5rem;
|
| 146 |
+
letter-spacing: -0.5px;
|
| 147 |
+
color: var(--text-main);
|
|
|
|
|
|
|
|
|
|
| 148 |
}
|
| 149 |
+
.badge {
|
| 150 |
+
font-size: 0.75rem;
|
| 151 |
+
background: #333;
|
| 152 |
+
padding: 4px 8px;
|
| 153 |
+
border-radius: 4px;
|
| 154 |
+
color: var(--text-muted);
|
| 155 |
font-weight: 600;
|
|
|
|
|
|
|
|
|
|
| 156 |
}
|
| 157 |
|
| 158 |
+
/* MAIN DASHBOARD GRID */
|
| 159 |
+
.dashboard-grid {
|
| 160 |
+
display: flex;
|
| 161 |
+
gap: 20px;
|
| 162 |
+
height: 100%;
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
+
/* PANELS */
|
| 166 |
+
.panel {
|
| 167 |
+
background: var(--bg-panel);
|
| 168 |
+
border: 1px solid var(--border-dim);
|
| 169 |
+
border-radius: 8px;
|
| 170 |
+
padding: 20px;
|
| 171 |
+
display: flex;
|
| 172 |
+
flex-direction: column;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.panel-label {
|
| 176 |
+
font-size: 0.75rem;
|
| 177 |
+
font-weight: 600;
|
| 178 |
+
color: var(--text-muted);
|
| 179 |
text-transform: uppercase;
|
| 180 |
letter-spacing: 1px;
|
| 181 |
+
margin-bottom: 15px;
|
| 182 |
+
border-bottom: 1px solid #2a2a2a;
|
| 183 |
+
padding-bottom: 8px;
|
| 184 |
}
|
| 185 |
|
| 186 |
+
/* LEFT SIDE: MASTER TRACK */
|
| 187 |
+
.master-track {
|
| 188 |
+
flex: 1; /* 33% width */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
+
|
| 191 |
+
/* RIGHT SIDE: MIXER */
|
| 192 |
+
.mixer-rack {
|
| 193 |
+
flex: 2; /* 66% width */
|
| 194 |
}
|
| 195 |
|
| 196 |
+
/* AUDIO COMPONENTS */
|
| 197 |
+
.audio-comp {
|
| 198 |
+
background: var(--bg-input) !important;
|
| 199 |
+
border: none !important;
|
| 200 |
+
border-radius: 6px !important;
|
|
|
|
| 201 |
}
|
| 202 |
|
| 203 |
+
/* BUTTON */
|
| 204 |
+
#process-btn {
|
| 205 |
+
background: var(--accent-blue) !important;
|
| 206 |
+
color: white !important;
|
| 207 |
font-weight: 600 !important;
|
| 208 |
+
font-size: 0.9rem !important;
|
| 209 |
+
padding: 12px !important;
|
| 210 |
+
border-radius: 6px !important;
|
| 211 |
+
border: none !important;
|
| 212 |
+
margin-top: auto; /* Push to bottom */
|
| 213 |
+
transition: background 0.2s;
|
| 214 |
+
}
|
| 215 |
+
#process-btn:hover {
|
| 216 |
+
background: var(--accent-hover) !important;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
/* GRID FOR STEMS */
|
| 220 |
+
.stem-grid {
|
| 221 |
+
display: grid;
|
| 222 |
+
grid-template-columns: 1fr 1fr;
|
| 223 |
+
gap: 15px;
|
| 224 |
+
height: 100%;
|
| 225 |
+
}
|
| 226 |
+
.stem-slot {
|
| 227 |
+
background: var(--bg-input);
|
| 228 |
+
border-radius: 6px;
|
| 229 |
+
padding: 15px;
|
| 230 |
+
border: 1px solid var(--border-dim);
|
| 231 |
+
}
|
| 232 |
+
.stem-title {
|
| 233 |
font-size: 0.8rem;
|
| 234 |
+
font-weight: 600;
|
| 235 |
+
color: var(--text-muted);
|
| 236 |
+
margin-bottom: 10px;
|
| 237 |
}
|
| 238 |
"""
|
| 239 |
|
| 240 |
with gr.Blocks(css=css, theme=gr.themes.Base()) as demo:
|
| 241 |
|
| 242 |
+
with gr.Column(elem_classes="app-wrapper"):
|
| 243 |
|
| 244 |
+
# 1. TOP BAR
|
| 245 |
+
with gr.Row(elem_classes="nav-bar"):
|
| 246 |
gr.HTML("""
|
| 247 |
+
<div style="width:100%; display:flex; justify-content:space-between; align-items:center;">
|
| 248 |
+
<div class="logo">SWARA STUDIO</div>
|
| 249 |
+
<div class="badge">PRO EDITION</div>
|
| 250 |
</div>
|
| 251 |
""")
|
| 252 |
|
| 253 |
+
# 2. MAIN CONSOLE
|
| 254 |
+
with gr.Row(elem_classes="dashboard-grid"):
|
| 255 |
|
| 256 |
+
# LEFT: MASTER INPUT
|
| 257 |
+
with gr.Column(elem_classes="panel master-track"):
|
| 258 |
+
gr.HTML('<div class="panel-label">Master Input</div>')
|
| 259 |
+
|
| 260 |
+
input_audio = gr.Audio(
|
| 261 |
+
label="Source Audio",
|
| 262 |
+
type="filepath",
|
| 263 |
+
elem_classes="audio-comp"
|
| 264 |
+
)
|
| 265 |
+
|
| 266 |
+
gr.Markdown(
|
| 267 |
+
"Supports WAV, FLAC, MP3. \nProcessing time: ~10s per minute.",
|
| 268 |
+
elem_id="info-text"
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
process_btn = gr.Button("Separate Stems", elem_id="process-btn")
|
| 272 |
+
|
| 273 |
+
# RIGHT: STEM MIXER
|
| 274 |
+
with gr.Column(elem_classes="panel mixer-rack"):
|
| 275 |
+
gr.HTML('<div class="panel-label">Stem Mixer</div>')
|
| 276 |
+
|
| 277 |
+
with gr.Row():
|
| 278 |
+
# ROW 1
|
| 279 |
+
with gr.Column(elem_classes="stem-slot"):
|
| 280 |
+
gr.HTML('<div class="stem-title">VOCALS</div>')
|
| 281 |
+
out_vocals = gr.Audio(label=None, interactive=False, show_label=False, elem_classes="audio-comp")
|
| 282 |
+
|
| 283 |
+
with gr.Column(elem_classes="stem-slot"):
|
| 284 |
+
gr.HTML('<div class="stem-title">DRUMS (MRIDANGAM)</div>')
|
| 285 |
+
out_drums = gr.Audio(label=None, interactive=False, show_label=False, elem_classes="audio-comp")
|
| 286 |
+
|
| 287 |
+
with gr.Row():
|
| 288 |
+
# ROW 2
|
| 289 |
+
with gr.Column(elem_classes="stem-slot"):
|
| 290 |
+
gr.HTML('<div class="stem-title">BASS (TANPURA)</div>')
|
| 291 |
+
out_bass = gr.Audio(label=None, interactive=False, show_label=False, elem_classes="audio-comp")
|
| 292 |
|
| 293 |
+
with gr.Column(elem_classes="stem-slot"):
|
| 294 |
+
gr.HTML('<div class="stem-title">OTHER (VIOLIN)</div>')
|
| 295 |
+
out_other = gr.Audio(label=None, interactive=False, show_label=False, elem_classes="audio-comp")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
# LOGIC
|
| 298 |
+
process_btn.click(
|
| 299 |
fn=separate_audio,
|
| 300 |
inputs=[input_audio],
|
| 301 |
outputs=[out_vocals, out_drums, out_bass, out_other]
|