ElLokoAkrata commited on
Commit
82feb26
1 Parent(s): 0eec4f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -1,9 +1,12 @@
1
  import gradio as gr
2
  from PIL import Image
3
- from elo import Elo
4
 
5
- # Inicializa el sistema de puntuación Elo
6
- elo_system = Elo(k=32)
 
 
 
 
7
 
8
  # Inicializa puntuaciones Elo
9
  elo_scores = {
@@ -24,17 +27,29 @@ def load_images():
24
  def update_elo(first, second, third):
25
  global elo_scores
26
 
 
27
  if first == "DALL-E 3":
28
- elo_scores["DALL-E 3"], elo_scores["Midjourney 6.1"] = elo_system.rate_match(elo_scores["DALL-E 3"], elo_scores["Midjourney 6.1"])
29
- elo_scores["DALL-E 3"], elo_scores["Flux"] = elo_system.rate_match(elo_scores["DALL-E 3"], elo_scores["Flux"])
30
  elif first == "Midjourney 6.1":
31
- elo_scores["Midjourney 6.1"], elo_scores["DALL-E 3"] = elo_system.rate_match(elo_scores["Midjourney 6.1"], elo_scores["DALL-E 3"])
32
- elo_scores["Midjourney 6.1"], elo_scores["Flux"] = elo_system.rate_match(elo_scores["Midjourney 6.1"], elo_scores["Flux"])
33
  elif first == "Flux":
34
- elo_scores["Flux"], elo_scores["DALL-E 3"] = elo_system.rate_match(elo_scores["Flux"], elo_scores["DALL-E 3"])
35
- elo_scores["Flux"], elo_scores["Midjourney 6.1"] = elo_system.rate_match(elo_scores["Flux"], elo_scores["Midjourney 6.1"])
36
 
37
- return f"DALL-E 3: {elo_scores['DALL-E 3']}, Midjourney 6.1: {elo_scores['Midjourney 6.1']}, Flux: {elo_scores['Flux']}"
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  # Interfaz Gradio
40
  def vote(first, second, third):
 
1
  import gradio as gr
2
  from PIL import Image
 
3
 
4
+ # Función para calcular la actualización de Elo
5
+ def elo_update(winner_elo, loser_elo, k=32):
6
+ expected_score_winner = 1 / (1 + 10 ** ((loser_elo - winner_elo) / 400))
7
+ new_winner_elo = winner_elo + k * (1 - expected_score_winner)
8
+ new_loser_elo = loser_elo + k * (0 - (1 - expected_score_winner))
9
+ return new_winner_elo, new_loser_elo
10
 
11
  # Inicializa puntuaciones Elo
12
  elo_scores = {
 
27
  def update_elo(first, second, third):
28
  global elo_scores
29
 
30
+ # Primera elección
31
  if first == "DALL-E 3":
32
+ elo_scores["DALL-E 3"], elo_scores["Midjourney 6.1"] = elo_update(elo_scores["DALL-E 3"], elo_scores["Midjourney 6.1"])
33
+ elo_scores["DALL-E 3"], elo_scores["Flux"] = elo_update(elo_scores["DALL-E 3"], elo_scores["Flux"])
34
  elif first == "Midjourney 6.1":
35
+ elo_scores["Midjourney 6.1"], elo_scores["DALL-E 3"] = elo_update(elo_scores["Midjourney 6.1"], elo_scores["DALL-E 3"])
36
+ elo_scores["Midjourney 6.1"], elo_scores["Flux"] = elo_update(elo_scores["Midjourney 6.1"], elo_scores["Flux"])
37
  elif first == "Flux":
38
+ elo_scores["Flux"], elo_scores["DALL-E 3"] = elo_update(elo_scores["Flux"], elo_scores["DALL-E 3"])
39
+ elo_scores["Flux"], elo_scores["Midjourney 6.1"] = elo_update(elo_scores["Flux"], elo_scores["Midjourney 6.1"])
40
 
41
+ # Segunda elección
42
+ if second == "DALL-E 3":
43
+ elo_scores["DALL-E 3"], elo_scores["Midjourney 6.1"] = elo_update(elo_scores["DALL-E 3"], elo_scores["Midjourney 6.1"])
44
+ elo_scores["DALL-E 3"], elo_scores["Flux"] = elo_update(elo_scores["DALL-E 3"], elo_scores["Flux"])
45
+ elif second == "Midjourney 6.1":
46
+ elo_scores["Midjourney 6.1"], elo_scores["DALL-E 3"] = elo_update(elo_scores["Midjourney 6.1"], elo_scores["DALL-E 3"])
47
+ elo_scores["Midjourney 6.1"], elo_scores["Flux"] = elo_update(elo_scores["Midjourney 6.1"], elo_scores["Flux"])
48
+ elif second == "Flux":
49
+ elo_scores["Flux"], elo_scores["DALL-E 3"] = elo_update(elo_scores["Flux"], elo_scores["DALL-E 3"])
50
+ elo_scores["Flux"], elo_scores["Midjourney 6.1"] = elo_update(elo_scores["Flux"], elo_scores["Midjourney 6.1"])
51
+
52
+ return f"DALL-E 3: {round(elo_scores['DALL-E 3'])}, Midjourney 6.1: {round(elo_scores['Midjourney 6.1'])}, Flux: {round(elo_scores['Flux'])}"
53
 
54
  # Interfaz Gradio
55
  def vote(first, second, third):