mlabonne commited on
Commit
5091a94
1 Parent(s): f21083c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -25
app.py CHANGED
@@ -371,36 +371,33 @@ def update(model_id_white, model_id_black):
371
  if result == "1-0":
372
  new_elo_white = calculate_elo(current_elo_white, current_elo_black, 1)
373
  new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0)
374
- print(f"{model_id_white} wins! ({termination})")
375
- print("ELO change:")
376
- print(
377
- f"* {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})"
378
- )
379
- print(
380
- f"* {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})"
381
- )
382
  elif result == "0-1":
383
  new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0)
384
  new_elo_black = calculate_elo(current_elo_black, current_elo_white, 1)
385
- print(f"{model_id_black} wins! ({termination})")
386
- print("ELO change:")
387
- print(
388
- f"* {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})"
389
- )
390
- print(
391
- f"* {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})"
392
- )
393
  elif result == "1/2-1/2":
394
  new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0.5)
395
  new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0.5)
396
- print(f"Draw! ({termination})")
397
- print("ELO change:")
398
- print(
399
- f"* {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})"
400
- )
401
- print(
402
- f"* {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})"
403
- )
404
  elif result == "*":
405
  print(f"Ongoing game! ({termination})")
406
 
@@ -457,7 +454,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
457
  btn = gr.Button("Fight!")
458
  with gr.Row():
459
  gr.HTML("""<div id='chessboard' style='width: 50%; display: block;'></div>""")
460
- out = gr.Image(value=image, show_label=False, show_share_button=False, show_download_button=False, elem_id="chessboard")
461
  gr.HTML("""<div id='rightblock' style='width: 50%; display: block;'></div>""")
462
  btn.click(fn=update, inputs=[model_id_white, model_id_black], outputs=out)
463
  gr.Markdown('<div align="center"><p style="font-size: 30px;">🏆 Leaderboard</p></div>')
 
371
  if result == "1-0":
372
  new_elo_white = calculate_elo(current_elo_white, current_elo_black, 1)
373
  new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0)
374
+ update_str = f"""{model_id_white} wins! ({termination})
375
+ ELO change:
376
+ * {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})
377
+ * {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})
378
+ """
379
+ gr.Info(update_str)
380
+ print(update_str)
 
381
  elif result == "0-1":
382
  new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0)
383
  new_elo_black = calculate_elo(current_elo_black, current_elo_white, 1)
384
+ update_str = f"""{model_id_black} wins! ({termination})
385
+ ELO change:
386
+ * {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})
387
+ * {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})
388
+ """
389
+ gr.Info(update_str)
390
+ print(update_str)
 
391
  elif result == "1/2-1/2":
392
  new_elo_white = calculate_elo(current_elo_white, current_elo_black, 0.5)
393
  new_elo_black = calculate_elo(current_elo_black, current_elo_white, 0.5)
394
+ update_str = f"""Draw! ({termination})
395
+ ELO change:
396
+ * {model_id_white}: {current_elo_white} -> {new_elo_white} ({new_elo_white - current_elo_white:+})
397
+ * {model_id_black}: {current_elo_black} -> {new_elo_black} ({new_elo_black - current_elo_black:+})
398
+ """
399
+ gr.Info(update_str)
400
+ print(update_str)
 
401
  elif result == "*":
402
  print(f"Ongoing game! ({termination})")
403
 
 
454
  btn = gr.Button("Fight!")
455
  with gr.Row():
456
  gr.HTML("""<div id='chessboard' style='width: 50%; display: block;'></div>""")
457
+ out = gr.Image(value=image, show_label=False, show_share_button=False, elem_id="chessboard")
458
  gr.HTML("""<div id='rightblock' style='width: 50%; display: block;'></div>""")
459
  btn.click(fn=update, inputs=[model_id_white, model_id_black], outputs=out)
460
  gr.Markdown('<div align="center"><p style="font-size: 30px;">🏆 Leaderboard</p></div>')