bishmoy commited on
Commit
9a43628
Β·
verified Β·
1 Parent(s): 13db177

added placeholder for flagging

Browse files
Files changed (1) hide show
  1. app.py +31 -14
app.py CHANGED
@@ -1,10 +1,9 @@
1
  import gradio as gr
2
  from utils import *
3
  import os
4
- from huggingface_hub import snapshot_download
5
 
6
  def build_demo():
7
-
8
 
9
  with gr.Blocks() as demo:
10
  state0 = gr.State()
@@ -23,9 +22,15 @@ def build_demo():
23
 
24
  with gr.Row():
25
  with gr.Column():
26
- audio_a = gr.Audio(label="Model A")
 
 
 
27
  with gr.Column():
28
- audio_b = gr.Audio(label="Model B")
 
 
 
29
  with gr.Row():
30
  leftvote_btn = gr.Button(
31
  value="πŸ‘ˆ A is Fake", visible=False, interactive=False
@@ -38,29 +43,40 @@ def build_demo():
38
  value="πŸ‘Ž Both are Real", visible=False, interactive=False
39
  )
40
 
41
- btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn]
42
 
43
  leftvote_btn.click(
44
  leftvote_last_response,
45
  inputs=[state0, state1],
46
- outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, model_selector_left, model_selector_right]
47
- )
48
  rightvote_btn.click(
49
  rightvote_last_response,
50
  inputs=[state0, state1],
51
- outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, model_selector_left, model_selector_right]
52
- )
53
  tie_btn.click(
54
  tievote_last_response,
55
  inputs=[state0, state1],
56
- outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, model_selector_left, model_selector_right]
57
- )
58
  bothbad_btn.click(
59
  bothbadvote_last_response,
60
  inputs=[state0, state1],
61
- outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, model_selector_left, model_selector_right]
62
- )
63
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  new_round_button = gr.Button("New Round")
66
  new_round_button.click(generate_songs, [state0, state1], [state0, audio_a, state1, audio_b, model_selector_left, model_selector_right]).then(
@@ -77,7 +93,8 @@ def build_demo():
77
  if __name__ == "__main__":
78
 
79
  SONG_SOURCE = os.getenv("SONG_SOURCE")
80
- snapshot_download(repo_id=SONG_SOURCE, repo_type="dataset", token = access_token, local_dir = '/data/')
 
81
  # elo_results_file, leaderboard_table_file = load_elo_results(elo_results_dir)
82
  demo = build_demo()
83
  demo.queue(max_size=20).launch(server_name="0.0.0.0")
 
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
  state0 = gr.State()
 
22
 
23
  with gr.Row():
24
  with gr.Column():
25
+ leftheard_btn = gr.Button(
26
+ value="🚩 Heard this song before", visible=False, interactive=False
27
+ )
28
+ audio_a = gr.Audio(label="Model A", max_length = 100, show_download_button = False)
29
  with gr.Column():
30
+ rightheard_btn = gr.Button(
31
+ value="🚩 Heard this song before", visible=False, interactive=False
32
+ )
33
+ audio_b = gr.Audio(label="Model B", max_length = 100, show_download_button = False)
34
  with gr.Row():
35
  leftvote_btn = gr.Button(
36
  value="πŸ‘ˆ A is Fake", visible=False, interactive=False
 
43
  value="πŸ‘Ž Both are Real", visible=False, interactive=False
44
  )
45
 
46
+ btn_list = [leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn]
47
 
48
  leftvote_btn.click(
49
  leftvote_last_response,
50
  inputs=[state0, state1],
51
+ outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
52
+ )
53
  rightvote_btn.click(
54
  rightvote_last_response,
55
  inputs=[state0, state1],
56
+ outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
57
+ )
58
  tie_btn.click(
59
  tievote_last_response,
60
  inputs=[state0, state1],
61
+ outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
62
+ )
63
  bothbad_btn.click(
64
  bothbadvote_last_response,
65
  inputs=[state0, state1],
66
+ outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
67
+ )
68
 
69
+ leftheard_btn.click(
70
+ leftheard_last_response,
71
+ inputs=state0,
72
+ outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
73
+ )
74
+
75
+ rightheard_btn.click(
76
+ rightheard_last_response,
77
+ inputs=state1,
78
+ outputs=[leftvote_btn, rightvote_btn, tie_btn, bothbad_btn, leftheard_btn, rightheard_btn, model_selector_left, model_selector_right]
79
+ )
80
 
81
  new_round_button = gr.Button("New Round")
82
  new_round_button.click(generate_songs, [state0, state1], [state0, audio_a, state1, audio_b, model_selector_left, model_selector_right]).then(
 
93
  if __name__ == "__main__":
94
 
95
  SONG_SOURCE = os.getenv("SONG_SOURCE")
96
+ TOKEN = os.getenv("TOKEN")
97
+ snapshot_download(repo_id=SONG_SOURCE, repo_type="dataset", token = TOKEN, local_dir = '/data/')
98
  # elo_results_file, leaderboard_table_file = load_elo_results(elo_results_dir)
99
  demo = build_demo()
100
  demo.queue(max_size=20).launch(server_name="0.0.0.0")