Tachyeon commited on
Commit
ea03b8f
·
verified ·
1 Parent(s): b22b079

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +155 -110
app.py CHANGED
@@ -28,7 +28,7 @@ except NameError:
28
  pass
29
 
30
  def load_model():
31
- print(">>> 📡 Connecting to Neural Engine...")
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. SHARP & PUNCHY UI DESIGN (No Blur)
102
  # ==========================================
103
  css = """
104
- @import url('https://fonts.googleapis.com/css2?family=Teko:wght@300;500;700&family=Work+Sans:wght@400;600;800&display=swap');
105
 
106
  :root {
107
- --bg-color: #050505;
108
- --card-bg: #111111;
109
- --border-color: #333333;
110
- --highlight-cyan: #00F0FF;
111
- --highlight-violet: #8F00FF;
112
- --text-white: #FFFFFF;
113
- --text-gray: #888888;
 
114
  }
115
 
116
  body, .gradio-container {
117
- background-color: var(--bg-color) !important;
118
- color: var(--text-white) !important;
119
- font-family: 'Work Sans', sans-serif !important;
120
  margin: 0; padding: 0;
121
  }
122
 
123
- /* CONTAINER RESET */
124
- .contain {
125
- padding: 30px !important;
126
- max-width: 1400px !important;
127
- margin: 0 auto !important;
 
 
 
128
  }
129
 
130
- /* HEADER STYLE */
131
- .header-wrapper {
132
- margin-bottom: 40px;
133
- border-bottom: 2px solid var(--border-color);
134
- padding-bottom: 20px;
 
 
 
135
  }
136
- .title-main {
137
- font-family: 'Teko', sans-serif;
138
- font-size: 5rem; /* Massive Title */
139
- line-height: 0.9;
140
- font-weight: 700;
141
- text-transform: uppercase;
142
- color: white;
143
- letter-spacing: 2px;
144
  }
145
- .title-sub {
146
- font-family: 'Work Sans', sans-serif;
147
- color: var(--highlight-cyan);
148
- font-size: 1.2rem;
 
 
149
  font-weight: 600;
150
- letter-spacing: 1px;
151
- text-transform: uppercase;
152
- margin-top: 5px;
153
  }
154
 
155
- /* SHARP CARD PANELS (No Blur) */
156
- .sharp-card {
157
- background-color: var(--card-bg);
158
- border: 1px solid var(--border-color);
159
- padding: 0px; /* Reset Padding */
160
- margin-bottom: 0px;
161
  }
162
 
163
- .card-header {
164
- background-color: #1A1A1A;
165
- padding: 15px 20px;
166
- border-bottom: 1px solid var(--border-color);
167
- font-family: 'Teko', sans-serif;
168
- font-size: 1.8rem;
169
- color: var(--text-gray);
 
 
 
 
 
 
 
170
  text-transform: uppercase;
171
  letter-spacing: 1px;
172
- }
173
- .card-content {
174
- padding: 25px;
175
  }
176
 
177
- /* BUTTON STYLING */
178
- #run-btn {
179
- background: linear-gradient(90deg, var(--highlight-violet), var(--highlight-cyan)) !important;
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
- #run-btn:hover {
191
- filter: brightness(1.2);
192
- transform: scale(1.01);
 
193
  }
194
 
195
- /* AUDIO PLAYERS */
196
- .audio-player {
197
- background: transparent !important;
198
- border: 1px solid var(--border-color) !important;
199
- border-radius: 0px !important;
200
- margin-bottom: 15px !important;
201
  }
202
 
203
- /* LABEL OVERRIDES */
204
- span.svelte-1gfkn6j {
205
- color: var(--highlight-cyan) !important;
 
206
  font-weight: 600 !important;
207
- text-transform: uppercase;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="contain"):
215
 
216
- # 1. HEADER AREA
217
- with gr.Group(elem_classes="header-wrapper"):
218
  gr.HTML("""
219
- <div>
220
- <div class="title-main">Swara Studio</div>
221
- <div class="title-sub">Neural Audio Source Separation Engine</div>
222
  </div>
223
  """)
224
 
225
- # 2. MAIN GRID
226
- with gr.Row(equal_height=True, variant="compact"):
227
 
228
- # LEFT COLUMN: INPUT
229
- with gr.Column(scale=1):
230
- with gr.Group(elem_classes="sharp-card"):
231
- gr.HTML('<div class="card-header">Input Source</div>')
232
- with gr.Column(elem_classes="card-content"):
233
- input_audio = gr.Audio(
234
- label="MASTER AUDIO TRACK",
235
- type="filepath",
236
- elem_classes="audio-player"
237
- )
238
- run_btn = gr.Button("RUN SEPARATION PROCESS", elem_id="run-btn")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
- # RIGHT COLUMN: OUTPUT
241
- with gr.Column(scale=2):
242
- with gr.Group(elem_classes="sharp-card"):
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
- run_btn.click(
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]