bishmoy's picture
Sensitivity and Specificity
10f9d9c verified
raw
history blame
2.93 kB
import gradio as gr
from utils import *
import os
from leaderboard import build_leaderboard
def build_demo():
last_updated_path = 'results/last_updated.txt'
last_updated_str = ''
if os.path.exists(last_updated_path):
with open(last_updated_path, 'r') as f:
date = f.read()
last_updated_str = f"\nLast Updated : {date}"
with gr.Blocks() as demo:
state = gr.State()
with gr.Tab("Song Generation", id=0):
gr.Markdown("# 🎡 Song Arena\nCan you detect if a song is AI-generated or real?")
with gr.Row():
with gr.Column():
gr.Markdown("### πŸ‘‡ Click on **New Round** for a song!")
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]
fake_btn.click(
fake_last_response,
inputs=[state],
outputs=[fake_btn, real_btn, model_selector]
)
real_btn.click(
real_last_response,
inputs=[state],
outputs=[fake_btn, real_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 πŸ†" + last_updated_str)
gr.Dataframe(
headers=[
"πŸ€–/ πŸ˜ƒ",
"πŸ—³οΈ Num Votes",
"πŸ“Š Sensitivity",
"πŸ“Š Specificity",
"πŸ“Š F-1",
],
datatype=[
"str",
"number",
"number",
],
value=build_leaderboard().values,
height=1200,
column_widths=[200, 100, 100, 100, 100, 100, 100],
wrap=False,
)
return demo
if __name__ == "__main__":
demo = build_demo()
demo.queue(max_size=20).launch(server_name="0.0.0.0")