mrfakename commited on
Commit
1f4eba7
1 Parent(s): 8c761e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -383,6 +383,7 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, cho
383
  else:
384
  out.append(gr.update(value=f'{chosenmodel1}', interactive=False, visible=True))
385
  out.append(gr.update(value=f'Your vote: {chosenmodel2}', interactive=False, visible=True))
 
386
  return out
387
 
388
  with gr.Blocks() as leaderboard:
@@ -447,7 +448,6 @@ def synthandreturn(text):
447
  raise gr.Error(f'You did not enter any text')
448
  # Get two random models
449
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
450
- print("Using models:", mdl1, mdl2)
451
  return (
452
  text,
453
  "Synthesize",
@@ -470,7 +470,10 @@ def synthandreturn(text):
470
  gr.update(visible=True, interactive=True),
471
  gr.update(visible=False),
472
  gr.update(visible=False),
 
473
  )
 
 
474
  with gr.Blocks() as vote:
475
  useridstate = gr.State()
476
  gr.Markdown(INSTR)
@@ -490,12 +493,14 @@ with gr.Blocks() as vote:
490
  aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
491
  bbetter = gr.Button("B is better", variant='primary')
492
  prevmodel2 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model B", text_align="center", lines=1, max_lines=1, visible=False)
 
493
  # outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
494
- outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2]
495
  btn.click(synthandreturn, inputs=[text], outputs=outputs)
 
496
 
497
  # nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
498
- nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2]
499
  abetter.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
500
  bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
501
  # skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
 
383
  else:
384
  out.append(gr.update(value=f'{chosenmodel1}', interactive=False, visible=True))
385
  out.append(gr.update(value=f'Your vote: {chosenmodel2}', interactive=False, visible=True))
386
+ out.append(gr.update(visible=True))
387
  return out
388
 
389
  with gr.Blocks() as leaderboard:
 
448
  raise gr.Error(f'You did not enter any text')
449
  # Get two random models
450
  mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
 
451
  return (
452
  text,
453
  "Synthesize",
 
470
  gr.update(visible=True, interactive=True),
471
  gr.update(visible=False),
472
  gr.update(visible=False),
473
+ gr.update(visible=False), #nxt round btn
474
  )
475
+ def clear_stuff():
476
+ return "", "Synthesize", gr.update(visible=False), '', '', gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
477
  with gr.Blocks() as vote:
478
  useridstate = gr.State()
479
  gr.Markdown(INSTR)
 
493
  aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
494
  bbetter = gr.Button("B is better", variant='primary')
495
  prevmodel2 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model B", text_align="center", lines=1, max_lines=1, visible=False)
496
+ nxtroundbtn = gr.Button('Next Round', visible=False)
497
  # outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
498
+ outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
499
  btn.click(synthandreturn, inputs=[text], outputs=outputs)
500
+ nxtroundbtn.click(clear_stuff, outputs=outputs)
501
 
502
  # nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
503
+ nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
504
  abetter.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
505
  bbetter.click(b_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate])
506
  # skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])