Spaces:
Running
on
Zero
Running
on
Zero
Links to spaces
Browse files
app.py
CHANGED
@@ -426,6 +426,7 @@ def get_leaderboard(reveal_prelim = False):
|
|
426 |
df = pd.DataFrame(data, columns=['name', 'upvote', 'downvote'])
|
427 |
# df['license'] = df['name'].map(model_license)
|
428 |
df['name'] = df['name'].replace(model_names)
|
|
|
429 |
df['votes'] = df['upvote'] + df['downvote']
|
430 |
# df['score'] = round((df['upvote'] / df['votes']) * 100, 2) # Percentage score
|
431 |
|
@@ -448,6 +449,13 @@ def get_leaderboard(reveal_prelim = False):
|
|
448 |
# df = df[['order', 'name', 'score', 'license', 'votes']]
|
449 |
df = df[['order', 'name', 'score', 'votes']]
|
450 |
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
def mkuuid(uid):
|
452 |
if not uid:
|
453 |
uid = uuid.uuid4()
|
@@ -538,16 +546,19 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, cho
|
|
538 |
# return out
|
539 |
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
540 |
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
|
|
|
|
541 |
out = [
|
542 |
gr.update(interactive=False, visible=False),
|
543 |
gr.update(interactive=False, visible=False)
|
544 |
]
|
|
|
545 |
if chose_a == True:
|
546 |
-
out.append(gr.update(value=f'Your vote: {chosenmodel1}',
|
547 |
-
out.append(gr.update(value=f'{chosenmodel2}',
|
548 |
else:
|
549 |
-
out.append(gr.update(value=f'{chosenmodel1}',
|
550 |
-
out.append(gr.update(value=f'Your vote: {chosenmodel2}',
|
551 |
out.append(gr.update(visible=True))
|
552 |
return out
|
553 |
|
@@ -643,12 +654,15 @@ def synthandreturn(text):
|
|
643 |
except:
|
644 |
pass
|
645 |
# Get two random models
|
646 |
-
# your TTS model versus The World!!!
|
647 |
mdl1 = 'Pendrokar/xVASynth'
|
648 |
vsModels = dict(AVAILABLE_MODELS)
|
649 |
del vsModels[mdl1]
|
|
|
650 |
mdl2 = random.sample(list(vsModels.keys()), 1)
|
|
|
651 |
mdl1, mdl2 = random.sample(list([mdl1, mdl2[0]]), 2)
|
|
|
652 |
# mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
|
653 |
log_text(text)
|
654 |
print("[debug] Using", mdl1, mdl2)
|
@@ -832,13 +846,13 @@ with gr.Blocks() as vote:
|
|
832 |
with gr.Column():
|
833 |
with gr.Group():
|
834 |
aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
835 |
-
abetter = gr.Button("A is better", variant='primary')
|
836 |
-
prevmodel1 = gr.
|
837 |
with gr.Column():
|
838 |
with gr.Group():
|
839 |
aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
840 |
-
bbetter = gr.Button("B is better", variant='primary')
|
841 |
-
prevmodel2 = gr.
|
842 |
nxtroundbtn = gr.Button('Next round', visible=False)
|
843 |
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
844 |
outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
|
|
|
426 |
df = pd.DataFrame(data, columns=['name', 'upvote', 'downvote'])
|
427 |
# df['license'] = df['name'].map(model_license)
|
428 |
df['name'] = df['name'].replace(model_names)
|
429 |
+
df['name'] = make_link_to_space(df['name'])
|
430 |
df['votes'] = df['upvote'] + df['downvote']
|
431 |
# df['score'] = round((df['upvote'] / df['votes']) * 100, 2) # Percentage score
|
432 |
|
|
|
449 |
# df = df[['order', 'name', 'score', 'license', 'votes']]
|
450 |
df = df[['order', 'name', 'score', 'votes']]
|
451 |
return df
|
452 |
+
|
453 |
+
def make_link_to_space(model_name):
|
454 |
+
# create a anchor link if a HF space
|
455 |
+
if '/' in model_name:
|
456 |
+
return '🤗 <a href="'+ 'https://huggingface.co/spaces/' + model_name + '">' + model_name + '</a>'
|
457 |
+
# otherwise just return the model name
|
458 |
+
return model_name
|
459 |
def mkuuid(uid):
|
460 |
if not uid:
|
461 |
uid = uuid.uuid4()
|
|
|
546 |
# return out
|
547 |
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
548 |
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
549 |
+
chosenmodel1 = make_link_to_space(chosenmodel1)
|
550 |
+
chosenmodel2 = make_link_to_space(chosenmodel2)
|
551 |
out = [
|
552 |
gr.update(interactive=False, visible=False),
|
553 |
gr.update(interactive=False, visible=False)
|
554 |
]
|
555 |
+
style = 'text-align: center; font-size: 1rem; margin-bottom: 0; padding: var(--input-padding)'
|
556 |
if chose_a == True:
|
557 |
+
out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel1}</p>', visible=True))
|
558 |
+
out.append(gr.update(value=f'<p style="{style}">{chosenmodel2}</p>', visible=True))
|
559 |
else:
|
560 |
+
out.append(gr.update(value=f'<p style="{style}">{chosenmodel1}</p>', visible=True))
|
561 |
+
out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel2}</p>', visible=True))
|
562 |
out.append(gr.update(visible=True))
|
563 |
return out
|
564 |
|
|
|
654 |
except:
|
655 |
pass
|
656 |
# Get two random models
|
657 |
+
# forced model: your TTS model versus The World!!!
|
658 |
mdl1 = 'Pendrokar/xVASynth'
|
659 |
vsModels = dict(AVAILABLE_MODELS)
|
660 |
del vsModels[mdl1]
|
661 |
+
# randomize position of the forced model
|
662 |
mdl2 = random.sample(list(vsModels.keys()), 1)
|
663 |
+
# forced random
|
664 |
mdl1, mdl2 = random.sample(list([mdl1, mdl2[0]]), 2)
|
665 |
+
# actual random
|
666 |
# mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
|
667 |
log_text(text)
|
668 |
print("[debug] Using", mdl1, mdl2)
|
|
|
846 |
with gr.Column():
|
847 |
with gr.Group():
|
848 |
aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
849 |
+
abetter = gr.Button("A is better", variant='primary', interactive=False)
|
850 |
+
prevmodel1 = gr.HTML(show_label=False, value="Vote to reveal model A", visible=False)
|
851 |
with gr.Column():
|
852 |
with gr.Group():
|
853 |
aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
854 |
+
bbetter = gr.Button("B is better", variant='primary', interactive=False)
|
855 |
+
prevmodel2 = gr.HTML(show_label=False, value="Vote to reveal model B", visible=False)
|
856 |
nxtroundbtn = gr.Button('Next round', visible=False)
|
857 |
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
858 |
outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
|