File size: 4,148 Bytes
b88f9b7 32a7d77 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 9a43628 b88f9b7 32a7d77 b88f9b7 9e220c9 |
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 88 89 90 91 92 93 94 95 96 97 98 99 |
import gradio as gr
from utils import *
import os
def build_demo():
with gr.Blocks() as demo:
state0 = gr.State()
state1 = 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_left = gr.Markdown("", visible=True)
with gr.Column():
model_selector_right = gr.Markdown("", visible=True)
with gr.Row():
with gr.Column():
leftheard_btn = gr.Button(
value="π© Heard this song before", visible=False, interactive=False
)
audio_a = gr.Audio(label="Model A", max_length = 100, show_download_button = False)
with gr.Column():
rightheard_btn = gr.Button(
value="π© Heard this song before", visible=False, interactive=False
)
audio_b = gr.Audio(label="Model B", max_length = 100, show_download_button = False)
with gr.Row():
leftvote_btn = gr.Button(
value="π A is Fake", visible=False, interactive=False
)
rightvote_btn = gr.Button(
value="π B is Fake", visible=False, interactive=False
)
tie_btn = gr.Button(value="π€ Both are Fake", visible=False, interactive=False)
bothbad_btn = gr.Button(
value="π Both are Real", visible=False, interactive=False
)
btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn]
leftvote_btn.click(
leftvote_last_response,
inputs=[state0, state1],
outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
)
rightvote_btn.click(
rightvote_last_response,
inputs=[state0, state1],
outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
)
tie_btn.click(
tievote_last_response,
inputs=[state0, state1],
outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
)
bothbad_btn.click(
bothbadvote_last_response,
inputs=[state0, state1],
outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
)
leftheard_btn.click(
leftheard_last_response,
inputs=state0,
outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
)
rightheard_btn.click(
rightheard_last_response,
inputs=state1,
outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
)
new_round_button = gr.Button("New Round")
new_round_button.click(generate_songs, [state0, state1], [state0, audio_a, state1, audio_b, model_selector_left, model_selector_right]).then(
enable_buttons_side_by_side,
inputs=None,
outputs=btn_list
)
with gr.Tab("Leaderboard", id=1):
gr.Markdown("# π Leaderboard work in progress ! π")
return demo
if __name__ == "__main__":
# elo_results_file, leaderboard_table_file = load_elo_results(elo_results_dir)
demo = build_demo()
demo.queue(max_size=20).launch(server_name="0.0.0.0")
|