Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
mrfakename
commited on
Commit
β’
2b0c2d0
1
Parent(s):
88f76ee
Update app.py
Browse files
app.py
CHANGED
@@ -333,13 +333,13 @@ def a_is_better(model1, model2, userid):
|
|
333 |
if model1 and model2:
|
334 |
upvote_model(model1, str(userid))
|
335 |
downvote_model(model2, str(userid))
|
336 |
-
return reload(model1, model2, userid)
|
337 |
def b_is_better(model1, model2, userid):
|
338 |
userid = mkuuid(userid)
|
339 |
if model1 and model2:
|
340 |
upvote_model(model2, str(userid))
|
341 |
downvote_model(model1, str(userid))
|
342 |
-
return reload(model1, model2, userid)
|
343 |
def both_bad(model1, model2, userid):
|
344 |
userid = mkuuid(userid)
|
345 |
if model1 and model2:
|
@@ -352,7 +352,7 @@ def both_good(model1, model2, userid):
|
|
352 |
upvote_model(model1, str(userid))
|
353 |
upvote_model(model2, str(userid))
|
354 |
return reload(model1, model2, userid)
|
355 |
-
def reload(chosenmodel1=None, chosenmodel2=None, userid=None):
|
356 |
# Select random splits
|
357 |
# row = random.choice(list(audio_dataset['train']))
|
358 |
# options = list(random.choice(list(audio_dataset['train'])).keys())
|
@@ -374,12 +374,20 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None):
|
|
374 |
# return out
|
375 |
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
376 |
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
377 |
-
|
378 |
gr.update(interactive=False, visible=False),
|
379 |
gr.update(interactive=False, visible=False),
|
380 |
-
gr.update(value=chosenmodel1, interactive=False, visible=True),
|
381 |
gr.update(value=chosenmodel2, interactive=False, visible=True),
|
382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
with gr.Blocks() as leaderboard:
|
385 |
gr.Markdown(LDESC)
|
@@ -461,8 +469,10 @@ def synthandreturn(text):
|
|
461 |
AVAILABLE_MODELS[mdl2],
|
462 |
api_name="/synthesize"
|
463 |
), # aud2
|
464 |
-
gr.update(visible=True),
|
465 |
-
gr.update(visible=True)
|
|
|
|
|
466 |
)
|
467 |
with gr.Blocks() as vote:
|
468 |
useridstate = gr.State()
|
@@ -484,7 +494,7 @@ with gr.Blocks() as vote:
|
|
484 |
bbetter = gr.Button("B is better", variant='primary')
|
485 |
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)
|
486 |
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
487 |
-
outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter]
|
488 |
btn.click(synthandreturn, inputs=[text], outputs=outputs)
|
489 |
|
490 |
# nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
|
|
|
333 |
if model1 and model2:
|
334 |
upvote_model(model1, str(userid))
|
335 |
downvote_model(model2, str(userid))
|
336 |
+
return reload(model1, model2, userid, chose_a=True)
|
337 |
def b_is_better(model1, model2, userid):
|
338 |
userid = mkuuid(userid)
|
339 |
if model1 and model2:
|
340 |
upvote_model(model2, str(userid))
|
341 |
downvote_model(model1, str(userid))
|
342 |
+
return reload(model1, model2, userid, chose_b=True)
|
343 |
def both_bad(model1, model2, userid):
|
344 |
userid = mkuuid(userid)
|
345 |
if model1 and model2:
|
|
|
352 |
upvote_model(model1, str(userid))
|
353 |
upvote_model(model2, str(userid))
|
354 |
return reload(model1, model2, userid)
|
355 |
+
def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, chose_b=False):
|
356 |
# Select random splits
|
357 |
# row = random.choice(list(audio_dataset['train']))
|
358 |
# options = list(random.choice(list(audio_dataset['train'])).keys())
|
|
|
374 |
# return out
|
375 |
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
376 |
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
377 |
+
out = [
|
378 |
gr.update(interactive=False, visible=False),
|
379 |
gr.update(interactive=False, visible=False),
|
|
|
380 |
gr.update(value=chosenmodel2, interactive=False, visible=True),
|
381 |
+
]
|
382 |
+
if chose_a:
|
383 |
+
out.append(gr.update(value=f'π {chosenmodel1}', interactive=False, visible=True))
|
384 |
+
else:
|
385 |
+
out.append(gr.update(value=chosenmodel1, interactive=False, visible=True))
|
386 |
+
if chose_b:
|
387 |
+
out.append(gr.update(value=f'π {chosenmodel2}', interactive=False, visible=True))
|
388 |
+
else:
|
389 |
+
out.append(gr.update(value=chosenmodel2, interactive=False, visible=True))
|
390 |
+
return out
|
391 |
|
392 |
with gr.Blocks() as leaderboard:
|
393 |
gr.Markdown(LDESC)
|
|
|
469 |
AVAILABLE_MODELS[mdl2],
|
470 |
api_name="/synthesize"
|
471 |
), # aud2
|
472 |
+
gr.update(visible=True, interactive=True),
|
473 |
+
gr.update(visible=True, interactive=True),
|
474 |
+
gr.update(visible=False),
|
475 |
+
gr.update(visible=False),
|
476 |
)
|
477 |
with gr.Blocks() as vote:
|
478 |
useridstate = gr.State()
|
|
|
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 |
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
497 |
+
outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2]
|
498 |
btn.click(synthandreturn, inputs=[text], outputs=outputs)
|
499 |
|
500 |
# nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
|