Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 167 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
"""Handle the user's choice and update rankings."""
|
| 176 |
-
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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=
|
| 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,
|