tianleliphoebe commited on
Commit
73eb3ef
1 Parent(s): 94bd22c
Files changed (2) hide show
  1. serve/gradio_web.py +1 -2
  2. serve/vote_utils.py +57 -15
serve/gradio_web.py CHANGED
@@ -36,7 +36,6 @@ Find out who is the 🥇conditional image generation models! More models are goi
36
 
37
  state0 = gr.State()
38
  state1 = gr.State()
39
- anony = True
40
  gen_func = partial(generate_igm_annoy, models.generate_image_ig_parallel_anony)
41
 
42
  gr.Markdown(notice_markdown, elem_id="notice_markdown")
@@ -53,7 +52,7 @@ Find out who is the 🥇conditional image generation models! More models are goi
53
 
54
  with gr.Row():
55
  with gr.Column():
56
- model_selector_left =gr.Markdown("", visible=False)
57
  with gr.Column():
58
  model_selector_right = gr.Markdown("", visible=False)
59
  with gr.Row():
 
36
 
37
  state0 = gr.State()
38
  state1 = gr.State()
 
39
  gen_func = partial(generate_igm_annoy, models.generate_image_ig_parallel_anony)
40
 
41
  gr.Markdown(notice_markdown, elem_id="notice_markdown")
 
52
 
53
  with gr.Row():
54
  with gr.Column():
55
+ model_selector_left = gr.Markdown("", visible=False)
56
  with gr.Column():
57
  model_selector_right = gr.Markdown("", visible=False)
58
  with gr.Row():
serve/vote_utils.py CHANGED
@@ -172,7 +172,7 @@ def leftvote_last_response_igm(
172
  vote_last_response_igm(
173
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
174
  )
175
- if model_selector0 == gr.State(""):
176
  return ("",) + (disable_btn,) * 4 + (
177
  gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
178
  gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
@@ -186,9 +186,11 @@ def rightvote_last_response_igm(
186
  vote_last_response_igm(
187
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
188
  )
189
- if model_selector0 == gr.State(""):
 
190
  return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
191
  else:
 
192
  return ("",) + (disable_btn,) * 4 + (gr.Markdown('', visible=True), gr.Markdown('', visible=True))
193
 
194
 
@@ -199,7 +201,7 @@ def tievote_last_response_igm(
199
  vote_last_response_igm(
200
  [state0, state1], "tievote", [model_selector0, model_selector1], request
201
  )
202
- if model_selector0 == gr.State(""):
203
  return ("",) + (disable_btn,) * 4 + (
204
  gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
205
  gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
@@ -214,7 +216,7 @@ def bothbad_vote_last_response_igm(
214
  vote_last_response_igm(
215
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
216
  )
217
- if model_selector0 == gr.State(""):
218
  return ("",) + (disable_btn,) * 4 + (
219
  gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
220
  gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
@@ -254,7 +256,10 @@ def leftvote_last_response_iem(
254
  # "### Model B: " + state1.model_name,
255
  # )
256
  # names = (state0.model_name, state1.model_name)
257
- names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
258
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
259
 
260
  def rightvote_last_response_iem(
@@ -268,7 +273,11 @@ def rightvote_last_response_iem(
268
  # "### Model A: " + state0.model_name,
269
  # "### Model B: " + state1.model_name,
270
  # )
271
- names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
 
272
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
273
 
274
  def tievote_last_response_iem(
@@ -278,7 +287,11 @@ def tievote_last_response_iem(
278
  vote_last_response_iem(
279
  [state0, state1], "tievote", [model_selector0, model_selector1], request
280
  )
281
- names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
 
282
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
283
 
284
  def bothbad_vote_last_response_iem(
@@ -288,7 +301,11 @@ def bothbad_vote_last_response_iem(
288
  vote_last_response_iem(
289
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
290
  )
291
- names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
 
292
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
293
 
294
 
@@ -321,7 +338,12 @@ def leftvote_last_response_vgm(
321
  vote_last_response_vgm(
322
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
323
  )
324
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
 
 
325
 
326
 
327
  def rightvote_last_response_vgm(
@@ -331,8 +353,14 @@ def rightvote_last_response_vgm(
331
  vote_last_response_vgm(
332
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
333
  )
334
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
335
-
 
 
 
 
 
 
336
 
337
  def tievote_last_response_vgm(
338
  state0, state1, model_selector0, model_selector1, request: gr.Request
@@ -341,7 +369,14 @@ def tievote_last_response_vgm(
341
  vote_last_response_vgm(
342
  [state0, state1], "tievote", [model_selector0, model_selector1], request
343
  )
344
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
 
 
 
 
345
 
346
 
347
  def bothbad_vote_last_response_vgm(
@@ -351,7 +386,14 @@ def bothbad_vote_last_response_vgm(
351
  vote_last_response_vgm(
352
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
353
  )
354
- return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
 
 
 
 
 
 
355
 
356
  share_js = """
357
  function (a, b, c, d) {
@@ -827,7 +869,7 @@ def generate_vg(gen_func, state, text, model_name, request: gr.Request):
827
  state.output = generated_video
828
  state.model_name = model_name
829
 
830
- yield state, generated_video
831
 
832
  finish_tstamp = time.time()
833
 
@@ -857,7 +899,7 @@ def generate_vg(gen_func, state, text, model_name, request: gr.Request):
857
  imageio.mimwrite(output_file, state.output, fps=8, quality=9)
858
 
859
  save_video_file_on_log_server(output_file)
860
- # yield state, output_file
861
 
862
  def generate_vgm(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
863
  if not text:
 
172
  vote_last_response_igm(
173
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
174
  )
175
+ if model_selector0 == "":
176
  return ("",) + (disable_btn,) * 4 + (
177
  gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
178
  gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
186
  vote_last_response_igm(
187
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
188
  )
189
+ print(model_selector0)
190
+ if model_selector0 == "":
191
  return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
192
  else:
193
+ print("no")
194
  return ("",) + (disable_btn,) * 4 + (gr.Markdown('', visible=True), gr.Markdown('', visible=True))
195
 
196
 
 
201
  vote_last_response_igm(
202
  [state0, state1], "tievote", [model_selector0, model_selector1], request
203
  )
204
+ if model_selector0 == "":
205
  return ("",) + (disable_btn,) * 4 + (
206
  gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
207
  gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
216
  vote_last_response_igm(
217
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
218
  )
219
+ if model_selector0 == "":
220
  return ("",) + (disable_btn,) * 4 + (
221
  gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
222
  gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
 
256
  # "### Model B: " + state1.model_name,
257
  # )
258
  # names = (state0.model_name, state1.model_name)
259
+ if model_selector0 == "":
260
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
261
+ else:
262
+ names = (gr.Markdown('', visible=False), gr.Markdown('', visible=False))
263
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
264
 
265
  def rightvote_last_response_iem(
 
273
  # "### Model A: " + state0.model_name,
274
  # "### Model B: " + state1.model_name,
275
  # )
276
+ if model_selector0 == "":
277
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
278
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
279
+ else:
280
+ names = (gr.Markdown('', visible=False), gr.Markdown('', visible=False))
281
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
282
 
283
  def tievote_last_response_iem(
 
287
  vote_last_response_iem(
288
  [state0, state1], "tievote", [model_selector0, model_selector1], request
289
  )
290
+ if model_selector0 == "":
291
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
292
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
293
+ else:
294
+ names = (gr.Markdown('', visible=False), gr.Markdown('', visible=False))
295
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
296
 
297
  def bothbad_vote_last_response_iem(
 
301
  vote_last_response_iem(
302
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
303
  )
304
+ if model_selector0 == "":
305
+ names = (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
306
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
307
+ else:
308
+ names = (gr.Markdown('', visible=False), gr.Markdown('', visible=False))
309
  return names + ("", "", gr.Image(height=512, width=512, type="pil"), "") + (disable_btn,) * 4
310
 
311
 
 
338
  vote_last_response_vgm(
339
  [state0, state1], "leftvote", [model_selector0, model_selector1], request
340
  )
341
+ if model_selector0 == "":
342
+ return ("",) + (disable_btn,) * 4 + (gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True), gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
343
+ else:
344
+ return ("",) + (disable_btn,) * 4 + (
345
+ gr.Markdown("", visible=False),
346
+ gr.Markdown("", visible=False))
347
 
348
 
349
  def rightvote_last_response_vgm(
 
353
  vote_last_response_vgm(
354
  [state0, state1], "rightvote", [model_selector0, model_selector1], request
355
  )
356
+ if model_selector0 == "":
357
+ return ("",) + (disable_btn,) * 4 + (
358
+ gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
359
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
360
+ else:
361
+ return ("",) + (disable_btn,) * 4 + (
362
+ gr.Markdown("", visible=False),
363
+ gr.Markdown("", visible=False))
364
 
365
  def tievote_last_response_vgm(
366
  state0, state1, model_selector0, model_selector1, request: gr.Request
 
369
  vote_last_response_vgm(
370
  [state0, state1], "tievote", [model_selector0, model_selector1], request
371
  )
372
+ if model_selector0 == "":
373
+ return ("",) + (disable_btn,) * 4 + (
374
+ gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
375
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
376
+ else:
377
+ return ("",) + (disable_btn,) * 4 + (
378
+ gr.Markdown("", visible=False),
379
+ gr.Markdown("", visible=False))
380
 
381
 
382
  def bothbad_vote_last_response_vgm(
 
386
  vote_last_response_vgm(
387
  [state0, state1], "bothbad_vote", [model_selector0, model_selector1], request
388
  )
389
+ if model_selector0 == "":
390
+ return ("",) + (disable_btn,) * 4 + (
391
+ gr.Markdown(f"### Model A: {state0.model_name.split('_')[1]}", visible=True),
392
+ gr.Markdown(f"### Model B: {state1.model_name.split('_')[1]}", visible=True))
393
+ else:
394
+ return ("",) + (disable_btn,) * 4 + (
395
+ gr.Markdown("", visible=False),
396
+ gr.Markdown("", visible=False))
397
 
398
  share_js = """
399
  function (a, b, c, d) {
 
869
  state.output = generated_video
870
  state.model_name = model_name
871
 
872
+ # yield state, generated_video
873
 
874
  finish_tstamp = time.time()
875
 
 
899
  imageio.mimwrite(output_file, state.output, fps=8, quality=9)
900
 
901
  save_video_file_on_log_server(output_file)
902
+ yield state, output_file
903
 
904
  def generate_vgm(gen_func, state0, state1, text, model_name0, model_name1, request: gr.Request):
905
  if not text: