Tachyeon commited on
Commit
57cad62
·
verified ·
1 Parent(s): 5f6cebb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -54
app.py CHANGED
@@ -7,7 +7,7 @@ import numpy as np
7
  from huggingface_hub import hf_hub_download
8
 
9
  # =====================================================
10
- # 1. MODEL LOGIC (UNCHANGED)
11
  # =====================================================
12
  try:
13
  from bs_roformer import BSRoformer
@@ -87,22 +87,22 @@ def separate_audio(audio_path):
87
  return files
88
 
89
  # =====================================================
90
- # 2. POLISHED UI (FIXED LAYOUT, NO SCROLL)
91
  # =====================================================
92
  css = """
93
- @import url('https://fonts.googleapis.com/css2?family=Anton&family=Playfair+Display:ital@1&family=Poppins:wght@400;600;700&display=swap');
94
 
95
  :root {
96
  --bg1:#2b1620;
97
  --bg2:#1c0d14;
98
- --panel:rgba(255,255,255,0.04);
99
- --border:rgba(255,255,255,0.08);
100
  --ink:#f6efe8;
101
- --muted:#c7bfbf;
102
  --accent:#ff73a6;
103
  }
104
 
105
- /* HARD RESET */
106
  html, body, .gradio-container {
107
  height:100%;
108
  width:100%;
@@ -114,15 +114,15 @@ html, body, .gradio-container {
114
  font-family:Poppins,sans-serif;
115
  }
116
 
117
- /* CENTERED APP */
118
  .app {
119
- max-width:1100px;
120
  height:100%;
121
  margin:0 auto;
122
- padding:32px;
123
  display:grid;
124
  grid-template-rows:auto 1fr;
125
- gap:28px;
126
  box-sizing:border-box;
127
  }
128
 
@@ -130,12 +130,12 @@ html, body, .gradio-container {
130
  .header {
131
  display:flex;
132
  justify-content:space-between;
133
- align-items:center;
134
  }
135
 
136
  .title {
137
  font-family:Anton,sans-serif;
138
- font-size:44px;
139
  letter-spacing:1px;
140
  }
141
 
@@ -143,14 +143,14 @@ html, body, .gradio-container {
143
  font-family:'Playfair Display',serif;
144
  font-style:italic;
145
  color:var(--accent);
146
- margin-left:14px;
147
  }
148
 
149
  /* MAIN GRID */
150
  .main {
151
  display:grid;
152
- grid-template-columns:1fr 1fr;
153
- gap:32px;
154
  height:100%;
155
  }
156
 
@@ -158,101 +158,118 @@ html, body, .gradio-container {
158
  .panel {
159
  background:var(--panel);
160
  border:1px solid var(--border);
161
- border-radius:16px;
162
- padding:28px;
163
  display:flex;
164
  flex-direction:column;
165
  gap:22px;
166
  box-sizing:border-box;
167
  }
168
 
169
- /* INPUT */
170
- .drop {
171
- border:1px dashed var(--border);
172
- border-radius:12px;
173
- padding:32px;
174
  text-align:center;
 
175
  }
176
 
177
- .drop h3 {
178
  margin:0;
179
  font-size:18px;
180
- letter-spacing:1px;
 
 
 
 
 
 
 
181
  }
182
 
183
- /* BUTTON */
184
  .run {
 
185
  background:linear-gradient(90deg,#ff73a6,#ffd58a) !important;
186
  color:#160c10 !important;
187
- font-weight:800 !important;
188
  border-radius:10px !important;
189
  border:none !important;
190
  }
191
 
192
  /* STEMS */
193
- .stems {
194
  display:grid;
195
  grid-template-columns:1fr 1fr;
196
- gap:18px;
197
  }
198
 
199
  .stem {
200
- background:rgba(255,255,255,0.03);
201
- border:1px solid var(--border);
202
- border-radius:12px;
203
- padding:16px;
 
 
204
  }
205
 
206
- .label {
207
  font-family:'Playfair Display',serif;
208
  font-style:italic;
209
  color:var(--accent);
210
- margin-bottom:6px;
211
  }
212
 
213
- /* AUDIO FIX */
214
  audio {
215
  width:100%;
216
- max-height:36px;
 
 
217
  }
218
  """
219
 
220
  with gr.Blocks() as demo:
221
  with gr.Column(elem_classes="app"):
222
 
 
223
  with gr.Row(elem_classes="header"):
224
  gr.HTML('<div class="title">SWARA STUDIO</div>')
225
- gr.HTML('<div class="subtitle">Audio Source Separation</div>')
226
 
 
227
  with gr.Row(elem_classes="main"):
228
 
 
229
  with gr.Column(elem_classes="panel"):
230
  gr.HTML("""
231
- <div class="drop">
232
- <h3>MASTER AUDIO</h3>
233
- <p>Drop or upload WAV / MP3</p>
234
  </div>
235
  """)
236
- inp = gr.Audio(type="filepath")
237
- btn = gr.Button("RUN SEPARATION", elem_classes="run")
238
 
 
239
  with gr.Column(elem_classes="panel"):
240
- gr.HTML('<div class="label">STEMS</div>')
241
- with gr.Row(elem_classes="stems"):
242
  with gr.Column(elem_classes="stem"):
243
- gr.HTML('<div class="label">Vocals</div>')
244
- o1 = gr.Audio(interactive=False)
245
  with gr.Column(elem_classes="stem"):
246
- gr.HTML('<div class="label">Drums</div>')
247
- o2 = gr.Audio(interactive=False)
248
  with gr.Column(elem_classes="stem"):
249
- gr.HTML('<div class="label">Bass</div>')
250
- o3 = gr.Audio(interactive=False)
251
  with gr.Column(elem_classes="stem"):
252
- gr.HTML('<div class="label">Other</div>')
253
- o4 = gr.Audio(interactive=False)
254
 
255
- btn.click(separate_audio, inp, [o1, o2, o3, o4])
 
 
 
 
256
 
257
  if __name__ == "__main__":
258
  demo.launch(css=css, theme=gr.themes.Base())
 
7
  from huggingface_hub import hf_hub_download
8
 
9
  # =====================================================
10
+ # MODEL LOGIC (UNCHANGED)
11
  # =====================================================
12
  try:
13
  from bs_roformer import BSRoformer
 
87
  return files
88
 
89
  # =====================================================
90
+ # UI FINAL POLISHED VERSION
91
  # =====================================================
92
  css = """
93
+ @import url('https://fonts.googleapis.com/css2?family=Anton&family=Playfair+Display:ital@1&family=Poppins:wght@400;500;600&display=swap');
94
 
95
  :root {
96
  --bg1:#2b1620;
97
  --bg2:#1c0d14;
98
+ --panel:rgba(255,255,255,0.035);
99
+ --border:rgba(255,255,255,0.06);
100
  --ink:#f6efe8;
101
+ --muted:#c2baba;
102
  --accent:#ff73a6;
103
  }
104
 
105
+ /* GLOBAL RESET */
106
  html, body, .gradio-container {
107
  height:100%;
108
  width:100%;
 
114
  font-family:Poppins,sans-serif;
115
  }
116
 
117
+ /* APP WRAPPER */
118
  .app {
119
+ max-width:1080px;
120
  height:100%;
121
  margin:0 auto;
122
+ padding:36px 32px;
123
  display:grid;
124
  grid-template-rows:auto 1fr;
125
+ gap:32px;
126
  box-sizing:border-box;
127
  }
128
 
 
130
  .header {
131
  display:flex;
132
  justify-content:space-between;
133
+ align-items:baseline;
134
  }
135
 
136
  .title {
137
  font-family:Anton,sans-serif;
138
+ font-size:42px;
139
  letter-spacing:1px;
140
  }
141
 
 
143
  font-family:'Playfair Display',serif;
144
  font-style:italic;
145
  color:var(--accent);
146
+ opacity:0.85;
147
  }
148
 
149
  /* MAIN GRID */
150
  .main {
151
  display:grid;
152
+ grid-template-columns:1.05fr 0.95fr;
153
+ gap:36px;
154
  height:100%;
155
  }
156
 
 
158
  .panel {
159
  background:var(--panel);
160
  border:1px solid var(--border);
161
+ border-radius:18px;
162
+ padding:28px 30px;
163
  display:flex;
164
  flex-direction:column;
165
  gap:22px;
166
  box-sizing:border-box;
167
  }
168
 
169
+ /* INPUT AREA */
170
+ .input-copy {
 
 
 
171
  text-align:center;
172
+ margin-bottom:4px;
173
  }
174
 
175
+ .input-copy h3 {
176
  margin:0;
177
  font-size:18px;
178
+ font-weight:500;
179
+ letter-spacing:0.5px;
180
+ }
181
+
182
+ .input-copy p {
183
+ margin-top:6px;
184
+ font-size:13px;
185
+ color:var(--muted);
186
  }
187
 
188
+ /* RUN BUTTON */
189
  .run {
190
+ margin-top:6px;
191
  background:linear-gradient(90deg,#ff73a6,#ffd58a) !important;
192
  color:#160c10 !important;
193
+ font-weight:700 !important;
194
  border-radius:10px !important;
195
  border:none !important;
196
  }
197
 
198
  /* STEMS */
199
+ .stems-grid {
200
  display:grid;
201
  grid-template-columns:1fr 1fr;
202
+ gap:22px;
203
  }
204
 
205
  .stem {
206
+ background:rgba(255,255,255,0.025);
207
+ border-radius:14px;
208
+ padding:16px 18px 18px;
209
+ display:flex;
210
+ flex-direction:column;
211
+ gap:8px;
212
  }
213
 
214
+ .stem-label {
215
  font-family:'Playfair Display',serif;
216
  font-style:italic;
217
  color:var(--accent);
218
+ opacity:0.9;
219
  }
220
 
221
+ /* AUDIO BLENDED */
222
  audio {
223
  width:100%;
224
+ max-height:34px;
225
+ opacity:0.9;
226
+ filter:brightness(0.95);
227
  }
228
  """
229
 
230
  with gr.Blocks() as demo:
231
  with gr.Column(elem_classes="app"):
232
 
233
+ # Header
234
  with gr.Row(elem_classes="header"):
235
  gr.HTML('<div class="title">SWARA STUDIO</div>')
236
+ gr.HTML('<div class="subtitle">audio source separation</div>')
237
 
238
+ # Main content
239
  with gr.Row(elem_classes="main"):
240
 
241
+ # Left: Input
242
  with gr.Column(elem_classes="panel"):
243
  gr.HTML("""
244
+ <div class="input-copy">
245
+ <h3>Choose an audio track</h3>
246
+ <p>Upload a song to extract individual parts</p>
247
  </div>
248
  """)
249
+ input_audio = gr.Audio(type="filepath")
250
+ run_btn = gr.Button("Separate", elem_classes="run")
251
 
252
+ # Right: Stems
253
  with gr.Column(elem_classes="panel"):
254
+ with gr.Row(elem_classes="stems-grid"):
 
255
  with gr.Column(elem_classes="stem"):
256
+ gr.HTML('<div class="stem-label">Vocals</div>')
257
+ out_vocals = gr.Audio(interactive=False)
258
  with gr.Column(elem_classes="stem"):
259
+ gr.HTML('<div class="stem-label">Drums</div>')
260
+ out_drums = gr.Audio(interactive=False)
261
  with gr.Column(elem_classes="stem"):
262
+ gr.HTML('<div class="stem-label">Bass</div>')
263
+ out_bass = gr.Audio(interactive=False)
264
  with gr.Column(elem_classes="stem"):
265
+ gr.HTML('<div class="stem-label">Other</div>')
266
+ out_other = gr.Audio(interactive=False)
267
 
268
+ run_btn.click(
269
+ separate_audio,
270
+ input_audio,
271
+ [out_vocals, out_drums, out_bass, out_other]
272
+ )
273
 
274
  if __name__ == "__main__":
275
  demo.launch(css=css, theme=gr.themes.Base())