TutuAwad commited on
Commit
c5c2b68
·
verified ·
1 Parent(s): ea0adfa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -13
app.py CHANGED
@@ -166,8 +166,12 @@ body,.gradio-container{
166
  """
167
 
168
  # ---------- Gradio UI ----------
169
- with gr.Blocks(css=app_css, title="HarmoniFind") as demo:
 
 
 
170
  bg_style = gr.HTML(make_bg_style_html())
 
171
  gr.HTML("""
172
  <div id="hf-shell">
173
  <div id="lux-header">
@@ -177,6 +181,7 @@ with gr.Blocks(css=app_css, title="HarmoniFind") as demo:
177
  </div>
178
  </div>
179
  """)
 
180
  with gr.Column():
181
  with gr.Row(variant="compact"):
182
  input_box = gr.Textbox(
@@ -185,20 +190,41 @@ with gr.Blocks(css=app_css, title="HarmoniFind") as demo:
185
  lines=3,
186
  scale=5,
187
  )
188
- with gr.Column(scale=2,min_width=160):
189
- search_btn = gr.Button("Search",elem_classes=["primary-btn"])
190
- surprise_btn = gr.Button("🎲 Surprise me",elem_classes=["secondary-btn"])
191
- clear_btn = gr.Button("Clear",elem_classes=["secondary-btn"])
192
- with gr.Accordion("Search settings",open=False):
 
193
  with gr.Row():
194
- k_slider = gr.Slider(5,50,value=10,step=1,label="# semantic matches")
195
- rand_slider = gr.Slider(0,10,value=2,step=1,label="# extra random tracks")
 
196
  output_html = gr.HTML()
197
 
198
- input_box.submit(search_with_bg,[input_box,k_slider,rand_slider],[output_html,bg_style])
199
- search_btn.click(search_with_bg,[input_box,k_slider,rand_slider],[output_html,bg_style])
200
- surprise_btn.click(get_random_vibe,outputs=input_box).then(search_with_bg,[input_box,k_slider,rand_slider],[output_html,bg_style])
201
- clear_btn.click(clear_all,None,[input_box,output_html,bg_style])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
  if __name__ == "__main__":
204
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
166
  """
167
 
168
  # ---------- Gradio UI ----------
169
+ with gr.Blocks(title="HarmoniFind") as demo:
170
+ # inject CSS manually (Gradio version on Spaces doesn't support css=...)
171
+ gr.HTML(f"<style>{app_css}</style>")
172
+
173
  bg_style = gr.HTML(make_bg_style_html())
174
+
175
  gr.HTML("""
176
  <div id="hf-shell">
177
  <div id="lux-header">
 
181
  </div>
182
  </div>
183
  """)
184
+
185
  with gr.Column():
186
  with gr.Row(variant="compact"):
187
  input_box = gr.Textbox(
 
190
  lines=3,
191
  scale=5,
192
  )
193
+ with gr.Column(scale=2, min_width=160):
194
+ search_btn = gr.Button("Search", elem_classes=["primary-btn"])
195
+ surprise_btn = gr.Button("🎲 Surprise me", elem_classes=["secondary-btn"])
196
+ clear_btn = gr.Button("Clear", elem_classes=["secondary-btn"])
197
+
198
+ with gr.Accordion("Search settings", open=False):
199
  with gr.Row():
200
+ k_slider = gr.Slider(5, 50, value=10, step=1, label="# semantic matches")
201
+ rand_slider = gr.Slider(0, 10, value=2, step=1, label="# extra random tracks")
202
+
203
  output_html = gr.HTML()
204
 
205
+ input_box.submit(
206
+ search_with_bg,
207
+ [input_box, k_slider, rand_slider],
208
+ [output_html, bg_style],
209
+ )
210
+ search_btn.click(
211
+ search_with_bg,
212
+ [input_box, k_slider, rand_slider],
213
+ [output_html, bg_style],
214
+ )
215
+ surprise_btn.click(
216
+ get_random_vibe,
217
+ outputs=input_box,
218
+ ).then(
219
+ search_with_bg,
220
+ [input_box, k_slider, rand_slider],
221
+ [output_html, bg_style],
222
+ )
223
+ clear_btn.click(
224
+ clear_all,
225
+ None,
226
+ [input_box, output_html, bg_style],
227
+ )
228
 
229
  if __name__ == "__main__":
230
+ demo.launch(server_name="0.0.0.0", server_port=7860)