Pendrokar commited on
Commit
1973202
Β·
1 Parent(s): 48445ab

make_link for prev_model

Browse files
Files changed (4) hide show
  1. app/leaderboard.py +1 -40
  2. app/models.py +40 -1
  3. app/ui_vote.py +12 -6
  4. app/vote.py +2 -2
app/leaderboard.py CHANGED
@@ -88,43 +88,4 @@ def get_leaderboard(reveal_prelim = False):
88
 
89
  df['score'] = df['score_diff']
90
  df = df[['order', 'name', 'score', 'votes']]
91
- return df
92
-
93
- def make_link_to_space(model_name, for_leaderboard=False):
94
- # create a anchor link if a HF space
95
- style = 'text-decoration: underline;text-decoration-style: dotted;'
96
- title = ''
97
-
98
- if model_name in AVAILABLE_MODELS:
99
- style += 'color: var(--link-text-color);'
100
- title = model_name
101
- else:
102
- style += 'font-style: italic;'
103
- title = 'Disabled for Arena (See AVAILABLE_MODELS within code for why)'
104
-
105
- model_basename = model_name
106
- if model_name in HF_SPACES:
107
- model_basename = HF_SPACES[model_name]['name']
108
-
109
- try:
110
- if(
111
- for_leaderboard
112
- and HF_SPACES[model_name]['is_proprietary']
113
- ):
114
- model_basename += ' πŸ”'
115
- title += '; πŸ” = online only or proprietary'
116
- except:
117
- pass
118
-
119
- if '/' in model_name:
120
- return 'πŸ€— <a target="_blank" style="'+ style +'" title="'+ title +'" href="'+ 'https://huggingface.co/spaces/'+ model_name +'">'+ model_basename +'</a>'
121
-
122
- # otherwise just return the model name
123
- return '<span style="'+ style +'" title="'+ title +'" href="'+ 'https://huggingface.co/spaces/'+ model_name +'">'+ model_name +'</span>'
124
-
125
- def markdown_link_to_space(model_name):
126
- # create a anchor link if a HF space using markdown syntax
127
- if '/' in model_name:
128
- return 'πŸ€— [' + model_name + '](https://huggingface.co/spaces/' + model_name + ')'
129
- # otherwise just return the model name
130
- return model_name
 
88
 
89
  df['score'] = df['score_diff']
90
  df = df[['order', 'name', 'score', 'votes']]
91
+ return df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/models.py CHANGED
@@ -364,4 +364,43 @@ model_names = {
364
  'pheme': 'PolyAI Pheme',
365
  'speecht5': 'SpeechT5',
366
  'metavoice': 'MetaVoice-1B',
367
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  'pheme': 'PolyAI Pheme',
365
  'speecht5': 'SpeechT5',
366
  'metavoice': 'MetaVoice-1B',
367
+ }
368
+
369
+ def make_link_to_space(model_name, for_leaderboard=False):
370
+ # create a anchor link if a HF space
371
+ style = 'text-decoration: underline;text-decoration-style: dotted;'
372
+ title = ''
373
+
374
+ if model_name in AVAILABLE_MODELS:
375
+ style += 'color: var(--link-text-color);'
376
+ title = model_name
377
+ else:
378
+ style += 'font-style: italic;'
379
+ title = 'Disabled for Arena (See AVAILABLE_MODELS within code for why)'
380
+
381
+ model_basename = model_name
382
+ if model_name in HF_SPACES:
383
+ model_basename = HF_SPACES[model_name]['name']
384
+
385
+ try:
386
+ if(
387
+ for_leaderboard
388
+ and HF_SPACES[model_name]['is_proprietary']
389
+ ):
390
+ model_basename += ' πŸ”'
391
+ title += '; πŸ” = online only or proprietary'
392
+ except:
393
+ pass
394
+
395
+ if '/' in model_name:
396
+ return 'πŸ€— <a target="_blank" style="'+ style +'" title="'+ title +'" href="'+ 'https://huggingface.co/spaces/'+ model_name +'">'+ model_basename +'</a>'
397
+
398
+ # otherwise just return the model name
399
+ return '<span style="'+ style +'" title="'+ title +'" href="'+ 'https://huggingface.co/spaces/'+ model_name +'">'+ model_name +'</span>'
400
+
401
+ def markdown_link_to_space(model_name):
402
+ # create a anchor link if a HF space using markdown syntax
403
+ if '/' in model_name:
404
+ return 'πŸ€— [' + model_name + '](https://huggingface.co/spaces/' + model_name + ')'
405
+ # otherwise just return the model name
406
+ return model_name
app/ui_vote.py CHANGED
@@ -45,9 +45,7 @@ with gr.Blocks() as vote:
45
  .then(None, js="() => "+ unblur_text_js)
46
  btn = gr.Button("Synthesize", variant='primary')
47
  model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=False)
48
- #model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=True)
49
  model2 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=False)
50
- #model2 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=True)
51
  with gr.Row(visible=False) as r2:
52
  with gr.Column():
53
  with gr.Group():
@@ -65,7 +63,11 @@ with gr.Blocks() as vote:
65
  variant='primary',
66
  interactive=False,
67
  )
68
- prevmodel1 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model A", text_align="center", lines=1, max_lines=1, visible=False)
 
 
 
 
69
  with gr.Column():
70
  with gr.Group():
71
  aud2 = gr.Audio(
@@ -82,7 +84,11 @@ with gr.Blocks() as vote:
82
  variant='primary',
83
  interactive=False,
84
  )
85
- 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)
 
 
 
 
86
  nxtroundbtn = gr.Button(
87
  '⚑ [N]ext round',
88
  elem_id='arena-next-round',
@@ -133,7 +139,7 @@ with gr.Blocks() as vote:
133
  nxtroundbtn\
134
  .click(clear_stuff, outputs=outputs)\
135
  .then(disable, outputs=[btn, abetter, bbetter, cachedt])\
136
- .then(give_cached_sample, inputs=[session_hash], outputs=[*outputs, cachedt])\
137
  .then(enable, outputs=[btn, gr.State(), gr.State(), gr.State()])
138
  # blur text
139
  nxtroundbtn.click(None, js="() => "+ blur_text_js)
@@ -141,7 +147,7 @@ with gr.Blocks() as vote:
141
  # fetch a comparison pair from cache
142
  cachedt\
143
  .click(disable, outputs=[btn, abetter, bbetter, cachedt])\
144
- .then(give_cached_sample, inputs=[session_hash], outputs=[*outputs, cachedt])\
145
  .then(enable, outputs=[btn, gr.State(), gr.State(), gr.State()])
146
  # TODO: await download of sample before allowing playback
147
 
 
45
  .then(None, js="() => "+ unblur_text_js)
46
  btn = gr.Button("Synthesize", variant='primary')
47
  model1 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=False)
 
48
  model2 = gr.Textbox(interactive=False, lines=1, max_lines=1, visible=False)
 
49
  with gr.Row(visible=False) as r2:
50
  with gr.Column():
51
  with gr.Group():
 
63
  variant='primary',
64
  interactive=False,
65
  )
66
+ prevmodel1 = gr.HTML(
67
+ show_label=False,
68
+ value="Vote to reveal model A",
69
+ visible=False,
70
+ )
71
  with gr.Column():
72
  with gr.Group():
73
  aud2 = gr.Audio(
 
84
  variant='primary',
85
  interactive=False,
86
  )
87
+ prevmodel2 = gr.HTML(
88
+ show_label=False,
89
+ value="Vote to reveal model B",
90
+ visible=False,
91
+ )
92
  nxtroundbtn = gr.Button(
93
  '⚑ [N]ext round',
94
  elem_id='arena-next-round',
 
139
  nxtroundbtn\
140
  .click(clear_stuff, outputs=outputs)\
141
  .then(disable, outputs=[btn, abetter, bbetter, cachedt])\
142
+ .then(give_cached_sample, inputs=[session_hash, autoplay], outputs=[*outputs, cachedt])\
143
  .then(enable, outputs=[btn, gr.State(), gr.State(), gr.State()])
144
  # blur text
145
  nxtroundbtn.click(None, js="() => "+ blur_text_js)
 
147
  # fetch a comparison pair from cache
148
  cachedt\
149
  .click(disable, outputs=[btn, abetter, bbetter, cachedt])\
150
+ .then(give_cached_sample, inputs=[session_hash, autoplay], outputs=[*outputs, cachedt])\
151
  .then(enable, outputs=[btn, gr.State(), gr.State(), gr.State()])
152
  # TODO: await download of sample before allowing playback
153
 
app/vote.py CHANGED
@@ -109,8 +109,8 @@ def is_better(model1, model2, userid, text, chose_a):
109
 
110
  # Reload
111
  def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, chose_b=False):
112
- # chosenmodel1 = make_link_to_space(chosenmodel1)
113
- # chosenmodel2 = make_link_to_space(chosenmodel2)
114
  out = [
115
  gr.update(interactive=False, visible=False),
116
  gr.update(interactive=False, visible=False)
 
109
 
110
  # Reload
111
  def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, chose_b=False):
112
+ chosenmodel1 = make_link_to_space(chosenmodel1)
113
+ chosenmodel2 = make_link_to_space(chosenmodel2)
114
  out = [
115
  gr.update(interactive=False, visible=False),
116
  gr.update(interactive=False, visible=False)