File size: 2,664 Bytes
f75fbc2 50d66f5 f75fbc2 50d66f5 f75fbc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
import gradio as gr
from utils import *
import os
from leaderboard import build_leaderboard
def build_demo():
with gr.Blocks() as demo:
state = gr.State()
with gr.Tab("Song Generation", id=0):
gr.Markdown("# π Arena Elo\nFind out who is the π₯ song generation models!")
with gr.Row():
with gr.Column():
gr.Markdown("### π Generating now!")
with gr.Row():
with gr.Column():
model_selector = gr.Markdown("", visible=True)
with gr.Row():
with gr.Column():
heard_btn = gr.Button(
value="π© Heard this song before", visible=False, interactive=False
)
audio = gr.Audio(show_download_button = False)
with gr.Row():
real_btn = gr.Button(value="π€ Real", visible=False, interactive=False)
fake_btn = gr.Button(
value="π Fake", visible=False, interactive=False
)
btn_list = [fake_btn, real_btn, heard_btn]
fake_btn.click(
fake_last_response,
inputs=[state],
outputs=[fake_btn, real_btn, heard_btn, model_selector]
)
real_btn.click(
real_last_response,
inputs=[state],
outputs=[fake_btn, real_btn, heard_btn, model_selector]
)
heard_btn.click(generate_songs, state, [state, audio, model_selector])
new_round_button = gr.Button("New Round")
new_round_button.click(generate_songs, state, [state, audio, model_selector]).then(
enable_buttons_side_by_side,
inputs=None,
outputs=btn_list
)
with gr.Tab("Leaderboard", id=1):
gr.Markdown("# π Leaderboard π")
gr.Dataframe(
headers=[
"β±οΈ Duration",
"π³οΈ Votes",
"π Accuracy",
"Organization",
"License",
],
datatype=[
"str",
"number",
"number",
],
value=build_leaderboard().values,
height=700,
column_widths=[50, 200, 100, 100, 100, 150, 150],
wrap=True,
)
return demo
if __name__ == "__main__":
demo = build_demo()
demo.queue(max_size=20).launch(server_name="0.0.0.0") |