Spaces:
Running
Running
prev model visible fix
Browse files- app/sample_caching.py +7 -3
- app/vote.py +6 -6
app/sample_caching.py
CHANGED
|
@@ -131,10 +131,14 @@ def give_cached_sample(session_hash: str, autoplay: bool, request: gr.Request):
|
|
| 131 |
return None
|
| 132 |
|
| 133 |
pair = get_next_pair(voting_users[userid])
|
|
|
|
| 134 |
if pair is None:
|
| 135 |
comp_defaults = []
|
| 136 |
for i in range(0, 14):
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
return [
|
| 139 |
*comp_defaults,
|
| 140 |
# *clear_stuff(),
|
|
@@ -152,8 +156,8 @@ def give_cached_sample(session_hash: str, autoplay: bool, request: gr.Request):
|
|
| 152 |
gr.update(visible=True, value=pair[1].filename, interactive=False, autoplay=False, playback_position=0), # aud2
|
| 153 |
gr.update(visible=True, interactive=False), #abetter
|
| 154 |
gr.update(visible=True, interactive=False), #bbetter
|
| 155 |
-
gr.
|
| 156 |
-
gr.
|
| 157 |
gr.update(visible=True, value="β‘ Skip Round", elem_classes=['skip-round']), #nxt round btn
|
| 158 |
# reset aplayed, bplayed audio playback events
|
| 159 |
False, #aplayed
|
|
|
|
| 131 |
return None
|
| 132 |
|
| 133 |
pair = get_next_pair(voting_users[userid])
|
| 134 |
+
# no other cached pair, generate default outputs
|
| 135 |
if pair is None:
|
| 136 |
comp_defaults = []
|
| 137 |
for i in range(0, 14):
|
| 138 |
+
if (i >= 9 and i <= 10): # prevmodel1 || prevmodel2
|
| 139 |
+
comp_defaults.append(gr.update(visible=False))
|
| 140 |
+
else:
|
| 141 |
+
comp_defaults.append(gr.update())
|
| 142 |
return [
|
| 143 |
*comp_defaults,
|
| 144 |
# *clear_stuff(),
|
|
|
|
| 156 |
gr.update(visible=True, value=pair[1].filename, interactive=False, autoplay=False, playback_position=0), # aud2
|
| 157 |
gr.update(visible=True, interactive=False), #abetter
|
| 158 |
gr.update(visible=True, interactive=False), #bbetter
|
| 159 |
+
gr.HTML(value='', visible=False), #prevmodel1 FIXME: Gradio ignores visible=False
|
| 160 |
+
gr.HTML(value='', visible=False), #prevmodel2 FIXME: Gradio ignores visible=False
|
| 161 |
gr.update(visible=True, value="β‘ Skip Round", elem_classes=['skip-round']), #nxt round btn
|
| 162 |
# reset aplayed, bplayed audio playback events
|
| 163 |
False, #aplayed
|
app/vote.py
CHANGED
|
@@ -114,17 +114,17 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, cho
|
|
| 114 |
chosenmodel1 = make_link_to_space(chosenmodel1)
|
| 115 |
chosenmodel2 = make_link_to_space(chosenmodel2)
|
| 116 |
out = [
|
| 117 |
-
gr.update(interactive=False, visible=
|
| 118 |
-
gr.update(interactive=False, visible=
|
| 119 |
]
|
| 120 |
style = 'text-align: center; font-size: 1rem; margin-bottom: 0; padding: var(--input-padding)'
|
| 121 |
if chose_a == True:
|
| 122 |
-
out.append(gr.
|
| 123 |
-
out.append(gr.
|
| 124 |
gr.Info(f'{chosenmodel1}πΌπ > {chosenmodel2}π½', duration=5)
|
| 125 |
else:
|
| 126 |
-
out.append(gr.
|
| 127 |
-
out.append(gr.
|
| 128 |
gr.Info(f'{chosenmodel1}π½ < {chosenmodel2}πΌπ', duration=5)
|
| 129 |
out.append(gr.update(visible=True, value="β‘ [N]ext Round", elem_classes=['next-round']))
|
| 130 |
return out
|
|
|
|
| 114 |
chosenmodel1 = make_link_to_space(chosenmodel1)
|
| 115 |
chosenmodel2 = make_link_to_space(chosenmodel2)
|
| 116 |
out = [
|
| 117 |
+
gr.update(interactive=False, visible=True),
|
| 118 |
+
gr.update(interactive=False, visible=True)
|
| 119 |
]
|
| 120 |
style = 'text-align: center; font-size: 1rem; margin-bottom: 0; padding: var(--input-padding)'
|
| 121 |
if chose_a == True:
|
| 122 |
+
out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel1}</p>', visible=True))
|
| 123 |
+
out.append(gr.update(value=f'<p style="{style}">{chosenmodel2}</p>', visible=True))
|
| 124 |
gr.Info(f'{chosenmodel1}πΌπ > {chosenmodel2}π½', duration=5)
|
| 125 |
else:
|
| 126 |
+
out.append(gr.update(value=f'<p style="{style}">{chosenmodel1}</p>', visible=True))
|
| 127 |
+
out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel2}</p>', visible=True))
|
| 128 |
gr.Info(f'{chosenmodel1}π½ < {chosenmodel2}πΌπ', duration=5)
|
| 129 |
out.append(gr.update(visible=True, value="β‘ [N]ext Round", elem_classes=['next-round']))
|
| 130 |
return out
|