Create single song app.py
Browse files
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from utils import *
|
3 |
+
import os
|
4 |
+
|
5 |
+
def build_demo():
|
6 |
+
|
7 |
+
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
state = gr.State()
|
10 |
+
with gr.Tab("Song Generation", id=0):
|
11 |
+
gr.Markdown("# π Arena Elo\nFind out who is the π₯ song generation models!")
|
12 |
+
|
13 |
+
with gr.Row():
|
14 |
+
with gr.Column():
|
15 |
+
gr.Markdown("### π Generating now!")
|
16 |
+
with gr.Row():
|
17 |
+
with gr.Column():
|
18 |
+
model_selector = gr.Markdown("", visible=True)
|
19 |
+
|
20 |
+
with gr.Row():
|
21 |
+
with gr.Column():
|
22 |
+
heard_btn = gr.Button(
|
23 |
+
value="π© Heard this song before", visible=False, interactive=False
|
24 |
+
)
|
25 |
+
audio = gr.Audio(show_download_button = False)
|
26 |
+
|
27 |
+
with gr.Row():
|
28 |
+
real_btn = gr.Button(value="π€ Real", visible=False, interactive=False)
|
29 |
+
fake_btn = gr.Button(
|
30 |
+
value="π Fake", visible=False, interactive=False
|
31 |
+
)
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
btn_list = [fake_btn, real_btn, heard_btn]
|
36 |
+
|
37 |
+
|
38 |
+
fake_btn.click(
|
39 |
+
fake_last_response,
|
40 |
+
inputs=[state],
|
41 |
+
outputs=[fake_btn, real_btn, heard_btn, model_selector]
|
42 |
+
)
|
43 |
+
|
44 |
+
real_btn.click(
|
45 |
+
real_last_response,
|
46 |
+
inputs=[state],
|
47 |
+
outputs=[fake_btn, real_btn, heard_btn, model_selector]
|
48 |
+
)
|
49 |
+
|
50 |
+
heard_btn.click(generate_songs, state, [state, audio, model_selector])
|
51 |
+
|
52 |
+
new_round_button = gr.Button("New Round")
|
53 |
+
new_round_button.click(generate_songs, state, [state, audio, model_selector]).then(
|
54 |
+
enable_buttons_side_by_side,
|
55 |
+
inputs=None,
|
56 |
+
outputs=btn_list
|
57 |
+
)
|
58 |
+
|
59 |
+
with gr.Tab("Leaderboard", id=1):
|
60 |
+
gr.Markdown("# π Leaderboard work in progress ! π")
|
61 |
+
return demo
|
62 |
+
|
63 |
+
if __name__ == "__main__":
|
64 |
+
|
65 |
+
# elo_results_file, leaderboard_table_file = load_elo_results(elo_results_dir)
|
66 |
+
demo = build_demo()
|
67 |
+
demo.queue(max_size=20).launch(server_name="0.0.0.0")
|