toninio19 commited on
Commit
a40e443
·
verified ·
1 Parent(s): dd0787d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -131,8 +131,8 @@ def create_arena_interface():
131
  )
132
 
133
  # State variables
134
- current_video = gr.State("")
135
- current_models = gr.State([])
136
 
137
  with gr.Row():
138
  # Display two videos side by side
@@ -163,18 +163,25 @@ def create_arena_interface():
163
  video_left.label = model_pair[0]["name"]
164
  video_right.label = model_pair[1]["name"]
165
 
166
- return {
167
- video_left: video_paths[0],
168
- video_right: video_paths[1],
169
- current_video: video_name,
170
- current_models: [model["name"] for model in model_pair],
171
- rankings_table: manager.get_rankings(),
172
- }
173
 
174
- def handle_choice(choice_index: int, video_name: str, current_models: List[str]) -> Dict:
 
 
 
 
 
 
 
 
175
  """Handle the user's choice and update rankings."""
176
- winner = current_models[choice_index]
177
- loser = current_models[1 - choice_index]
 
 
 
 
178
 
179
  # Save the comparison result
180
  manager.save_comparison(video_name, winner, loser)
@@ -210,7 +217,7 @@ def create_arena_interface():
210
  # Initial load
211
  demo.load(
212
  fn=load_new_comparison,
213
- inputs=None,
214
  outputs=[
215
  video_left,
216
  video_right,
 
131
  )
132
 
133
  # State variables
134
+ current_video = gr.State()
135
+ current_models = gr.State()
136
 
137
  with gr.Row():
138
  # Display two videos side by side
 
163
  video_left.label = model_pair[0]["name"]
164
  video_right.label = model_pair[1]["name"]
165
 
166
+ current_video_value = video_name
167
+ current_models_value = [model["name"] for model in model_pair]
 
 
 
 
 
168
 
169
+ return (
170
+ video_paths[0], # video_left
171
+ video_paths[1], # video_right
172
+ current_video_value, # current_video
173
+ current_models_value, # current_models
174
+ manager.get_rankings(), # rankings_table
175
+ )
176
+
177
+ def handle_choice(choice_index: int, video_name: str, current_models_value: List[str]):
178
  """Handle the user's choice and update rankings."""
179
+ if not current_models_value or len(current_models_value) < 2:
180
+ print("Error: current_models is invalid:", current_models_value)
181
+ return gr.update(visible=False), gr.update(visible=False), "", [], manager.get_rankings()
182
+
183
+ winner = current_models_value[choice_index]
184
+ loser = current_models_value[1 - choice_index]
185
 
186
  # Save the comparison result
187
  manager.save_comparison(video_name, winner, loser)
 
217
  # Initial load
218
  demo.load(
219
  fn=load_new_comparison,
220
+ inputs=[],
221
  outputs=[
222
  video_left,
223
  video_right,