|
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__": |
|
|
|
|
|
demo = build_demo() |
|
demo.queue(max_size=20).launch(server_name="0.0.0.0") |
|
|