Spaces:
Running
Running
Commit
·
e88f4b9
1
Parent(s):
d17c6a5
fix
Browse files
app.py
CHANGED
@@ -147,48 +147,6 @@ def update_interface(responses, state):
|
|
147 |
state
|
148 |
)
|
149 |
|
150 |
-
def skip_pair(state):
|
151 |
-
pair_index = state['pair_index']
|
152 |
-
|
153 |
-
# Update state
|
154 |
-
pair_index += 1
|
155 |
-
state['pair_index'] = pair_index
|
156 |
-
|
157 |
-
video1_url, video2_url = get_video_pair(state)
|
158 |
-
if video1_url is None:
|
159 |
-
# No more pairs
|
160 |
-
output_message = "Thank you for participating! No more videos."
|
161 |
-
return (
|
162 |
-
gr.update(visible=False), # video_row
|
163 |
-
gr.update(value=""), # video1
|
164 |
-
gr.update(value=""), # video2
|
165 |
-
gr.update(visible=False), # question_column
|
166 |
-
gr.update(visible=False), # button_row
|
167 |
-
output_message, # output
|
168 |
-
gr.update(value=None), # q1
|
169 |
-
gr.update(value=None), # q2
|
170 |
-
gr.update(value=None), # q3
|
171 |
-
gr.update(interactive=False), # next_btn
|
172 |
-
state
|
173 |
-
)
|
174 |
-
else:
|
175 |
-
video1_html = generate_video_html(video1_url)
|
176 |
-
video2_html = generate_video_html(video2_url)
|
177 |
-
# Update videos and reset questions
|
178 |
-
return (
|
179 |
-
gr.update(visible=True), # video_row
|
180 |
-
gr.update(value=video1_html), # video1
|
181 |
-
gr.update(value=video2_html), # video2
|
182 |
-
gr.update(visible=True), # question_column
|
183 |
-
gr.update(visible=True), # button_row
|
184 |
-
"You chose to skip this pair.", # output
|
185 |
-
gr.update(value=None), # q1
|
186 |
-
gr.update(value=None), # q2
|
187 |
-
gr.update(value=None), # q3
|
188 |
-
gr.update(interactive=False), # next_btn
|
189 |
-
state
|
190 |
-
)
|
191 |
-
|
192 |
def check_all_answers(visual_quality, temporal_consistency, realistic_dynamics):
|
193 |
if visual_quality and temporal_consistency and realistic_dynamics:
|
194 |
return gr.update(interactive=True)
|
@@ -204,6 +162,7 @@ def authenticate_user(email, state):
|
|
204 |
if not email or not is_valid_email(email):
|
205 |
return (
|
206 |
gr.update(), # email_input (remains visible)
|
|
|
207 |
"Please enter a valid email.", # email_output
|
208 |
gr.update(visible=False), # video_row
|
209 |
gr.update(value=""), # video1
|
@@ -238,7 +197,8 @@ def authenticate_user(email, state):
|
|
238 |
if video1_url is None:
|
239 |
output_message = "No new videos available for you."
|
240 |
return (
|
241 |
-
gr.update(),
|
|
|
242 |
"", # email_output
|
243 |
gr.update(visible=False), # video_row
|
244 |
gr.update(value=""), # video1
|
@@ -253,6 +213,7 @@ def authenticate_user(email, state):
|
|
253 |
video2_html = generate_video_html(video2_url)
|
254 |
return (
|
255 |
gr.update(visible=False), # email_input
|
|
|
256 |
"", # email_output
|
257 |
gr.update(visible=True), # video_row
|
258 |
gr.update(value=video1_html), # video1
|
@@ -302,7 +263,7 @@ with gr.Blocks() as demo:
|
|
302 |
# Buttons (initially hidden)
|
303 |
with gr.Row(visible=False) as button_row:
|
304 |
next_btn = gr.Button("Next", interactive=False)
|
305 |
-
skip_btn = gr.Button("Skip")
|
306 |
|
307 |
output = gr.Markdown()
|
308 |
|
@@ -330,22 +291,6 @@ with gr.Blocks() as demo:
|
|
330 |
]
|
331 |
)
|
332 |
|
333 |
-
skip_btn.click(
|
334 |
-
fn=skip_pair,
|
335 |
-
inputs=state,
|
336 |
-
outputs=[
|
337 |
-
video_row, # Update video_row
|
338 |
-
video1, # Update video1
|
339 |
-
video2, # Update video2
|
340 |
-
question_column, # Update question_column
|
341 |
-
button_row, # Update button_row
|
342 |
-
output, # Update output message
|
343 |
-
q1, q2, q3, # Reset questions
|
344 |
-
next_btn, # Update next_btn
|
345 |
-
state
|
346 |
-
]
|
347 |
-
)
|
348 |
-
|
349 |
def on_change(visual_quality, temporal_consistency, realistic_dynamics):
|
350 |
return check_all_answers(visual_quality, temporal_consistency, realistic_dynamics)
|
351 |
|
@@ -369,14 +314,15 @@ with gr.Blocks() as demo:
|
|
369 |
fn=authenticate_user,
|
370 |
inputs=[email_input, state],
|
371 |
outputs=[
|
372 |
-
email_input, #
|
373 |
-
|
374 |
-
|
|
|
375 |
video1, # Update video1
|
376 |
video2, # Update video2
|
377 |
-
question_column, #
|
378 |
-
button_row, #
|
379 |
-
output, #
|
380 |
state
|
381 |
]
|
382 |
)
|
|
|
147 |
state
|
148 |
)
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
def check_all_answers(visual_quality, temporal_consistency, realistic_dynamics):
|
151 |
if visual_quality and temporal_consistency and realistic_dynamics:
|
152 |
return gr.update(interactive=True)
|
|
|
162 |
if not email or not is_valid_email(email):
|
163 |
return (
|
164 |
gr.update(), # email_input (remains visible)
|
165 |
+
gr.update(), # submit_email (remains visible)
|
166 |
"Please enter a valid email.", # email_output
|
167 |
gr.update(visible=False), # video_row
|
168 |
gr.update(value=""), # video1
|
|
|
197 |
if video1_url is None:
|
198 |
output_message = "No new videos available for you."
|
199 |
return (
|
200 |
+
gr.update(visible=False), # email_input
|
201 |
+
gr.update(visible=False), # submit_email
|
202 |
"", # email_output
|
203 |
gr.update(visible=False), # video_row
|
204 |
gr.update(value=""), # video1
|
|
|
213 |
video2_html = generate_video_html(video2_url)
|
214 |
return (
|
215 |
gr.update(visible=False), # email_input
|
216 |
+
gr.update(visible=False), # submit_email
|
217 |
"", # email_output
|
218 |
gr.update(visible=True), # video_row
|
219 |
gr.update(value=video1_html), # video1
|
|
|
263 |
# Buttons (initially hidden)
|
264 |
with gr.Row(visible=False) as button_row:
|
265 |
next_btn = gr.Button("Next", interactive=False)
|
266 |
+
# skip_btn = gr.Button("Skip") # Commented out if not used
|
267 |
|
268 |
output = gr.Markdown()
|
269 |
|
|
|
291 |
]
|
292 |
)
|
293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
def on_change(visual_quality, temporal_consistency, realistic_dynamics):
|
295 |
return check_all_answers(visual_quality, temporal_consistency, realistic_dynamics)
|
296 |
|
|
|
314 |
fn=authenticate_user,
|
315 |
inputs=[email_input, state],
|
316 |
outputs=[
|
317 |
+
email_input, # Update email_input
|
318 |
+
submit_email, # Update submit_email
|
319 |
+
email_output, # Update email_output
|
320 |
+
video_row, # Update video_row
|
321 |
video1, # Update video1
|
322 |
video2, # Update video2
|
323 |
+
question_column, # Update question_column
|
324 |
+
button_row, # Update button_row
|
325 |
+
output, # Update output message
|
326 |
state
|
327 |
]
|
328 |
)
|