Spaces:
Runtime error
Runtime error
two-pane layout: video left, questions right with independent scrolling
Browse files
app.py
CHANGED
|
@@ -329,6 +329,24 @@ def first_unanswered(annotator):
|
|
| 329 |
|
| 330 |
|
| 331 |
# ---------------------------------------------------------------- app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
with gr.Blocks(title="Object-centric annotation eval") as demo:
|
| 333 |
idx_state = gr.State(0)
|
| 334 |
name_state = gr.State("")
|
|
@@ -340,49 +358,52 @@ with gr.Blocks(title="Object-centric annotation eval") as demo:
|
|
| 340 |
|
| 341 |
with gr.Column(visible=False) as main_col:
|
| 342 |
header = gr.Markdown()
|
| 343 |
-
gr.
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
outputs = [idx_state, header, video, gallery, ann_md, xc_md] + q_mds + radios + narr_mds + narr_radios + [comment]
|
| 388 |
|
|
@@ -425,4 +446,4 @@ if __name__ == "__main__":
|
|
| 425 |
ap.add_argument("--host", default="0.0.0.0")
|
| 426 |
ap.add_argument("--share", action="store_true")
|
| 427 |
a = ap.parse_args()
|
| 428 |
-
demo.launch(server_name=a.host, server_port=a.port, share=a.share, allowed_paths=[str(MEDIA)], show_error=True)
|
|
|
|
| 329 |
|
| 330 |
|
| 331 |
# ---------------------------------------------------------------- app
|
| 332 |
+
# Side-by-side layout: the video stays put on the left while the questions scroll on the
|
| 333 |
+
# right, so nobody has to scroll away from the clip to answer. Stacks again on narrow screens.
|
| 334 |
+
CSS = """
|
| 335 |
+
#eval-row { align-items: flex-start; flex-wrap: nowrap; }
|
| 336 |
+
#left-pane, #right-pane { max-height: calc(100vh - 70px); overflow-y: auto; flex-wrap: nowrap; }
|
| 337 |
+
/* a column is a flex box: without this its children are squeezed to fit instead of scrolling */
|
| 338 |
+
#left-pane > *, #right-pane > * { flex-shrink: 0; }
|
| 339 |
+
#right-pane { padding-right: 10px; }
|
| 340 |
+
#eval-video video { max-height: 62vh; width: 100%; object-fit: contain; }
|
| 341 |
+
.q-stem { margin-top: 14px !important; margin-bottom: 2px !important; }
|
| 342 |
+
.q-stem p, .q-stem li { font-size: 15px; line-height: 1.35; }
|
| 343 |
+
.q-ans { margin-bottom: 6px !important; }
|
| 344 |
+
@media (max-width: 1000px) {
|
| 345 |
+
#eval-row { flex-wrap: wrap; }
|
| 346 |
+
#left-pane, #right-pane { max-height: none; overflow-y: visible; }
|
| 347 |
+
}
|
| 348 |
+
"""
|
| 349 |
+
|
| 350 |
with gr.Blocks(title="Object-centric annotation eval") as demo:
|
| 351 |
idx_state = gr.State(0)
|
| 352 |
name_state = gr.State("")
|
|
|
|
| 358 |
|
| 359 |
with gr.Column(visible=False) as main_col:
|
| 360 |
header = gr.Markdown()
|
| 361 |
+
with gr.Row(elem_id="eval-row"):
|
| 362 |
+
# ---- left: what to look at (stays in view) ----
|
| 363 |
+
with gr.Column(scale=5, elem_id="left-pane"):
|
| 364 |
+
video = gr.Video(show_label=False, autoplay=True, loop=True, elem_id="eval-video")
|
| 365 |
+
gallery = gr.Gallery(label="Keyframes: green = mask, red = box, red dot = gaze", columns=4, rows=1, height=190,
|
| 366 |
+
object_fit="contain")
|
| 367 |
+
with gr.Accordion("Legend — what the overlays mean", open=False):
|
| 368 |
+
gr.Markdown(
|
| 369 |
+
"- **VIDEO TIME** (top-right, boxed) = seconds of the full recording; every annotation time uses it "
|
| 370 |
+
"(the player's own 0–30 s counter does not).\n"
|
| 371 |
+
"- **red box** = the object, near each keyframe · **red dot** = where the wearer is looking.\n"
|
| 372 |
+
"- yellow **GAZE ON OBJECT** = the memory claims a look at the object.\n"
|
| 373 |
+
"- **blue NARRATION** = annotator text (not audio), with [start–end] · **purple SPEECH** = words "
|
| 374 |
+
"actually spoken · **green SOUND** = sound events.\n"
|
| 375 |
+
"- bottom bar = timeline: lanes sound / narration / speech / dwell, white ticks = narration "
|
| 376 |
+
"start/end, red ticks = keyframes, white line = now.")
|
| 377 |
+
# ---- right: the questions (scrolls on its own) ----
|
| 378 |
+
with gr.Column(scale=6, elem_id="right-pane"):
|
| 379 |
+
with gr.Accordion("How to judge — read this once", open=True):
|
| 380 |
+
gr.Markdown(
|
| 381 |
+
"- Each question states **one claim** of an auto-generated memory about **one object**. Say whether it matches the video.\n"
|
| 382 |
+
"- **Correct** / **Partially correct** (right idea, a place / time / detail is off) / **Incorrect** / **Can't tell**.\n"
|
| 383 |
+
"- **Times** = seconds of the full recording → read the boxed **VIDEO TIME** (top-right). Differences under ~1 s are fine.\n"
|
| 384 |
+
"- **Places** like “the counter #2”: judge the **kind of place**; ignore the number.\n"
|
| 385 |
+
"- **Sound**: 🔊 turn it on (audio is amplified).\n"
|
| 386 |
+
"- **Gaze**: the red dot is always shown; the gaze question is only about the **moment right before the hand touches the object**.")
|
| 387 |
+
q_mds, radios = [], []
|
| 388 |
+
for key, _ in DIMENSIONS:
|
| 389 |
+
q_mds.append(gr.Markdown(elem_classes="q-stem"))
|
| 390 |
+
radios.append(gr.Radio(CHOICES, show_label=False, container=False, elem_classes="q-ans"))
|
| 391 |
+
gr.Markdown("### Narrations — judge **each one** separately (blue subtitles; compare with **VIDEO TIME**)")
|
| 392 |
+
narr_mds, narr_radios = [], []
|
| 393 |
+
for k in range(NARR_MAX):
|
| 394 |
+
narr_mds.append(gr.Markdown(visible=(k == 0), elem_classes="q-stem"))
|
| 395 |
+
narr_radios.append(gr.Radio(CHOICES, show_label=False, container=False, visible=(k == 0),
|
| 396 |
+
elem_classes="q-ans"))
|
| 397 |
+
comment = gr.Textbox(label="Comment (optional)", lines=2)
|
| 398 |
+
with gr.Row():
|
| 399 |
+
prev_btn = gr.Button("◀ Prev")
|
| 400 |
+
skip_btn = gr.Button("Skip ▶")
|
| 401 |
+
submit_btn = gr.Button("Submit & Next ▶", variant="primary")
|
| 402 |
+
msg = gr.Markdown()
|
| 403 |
+
with gr.Accordion("Full memory record of this object (reference)", open=False):
|
| 404 |
+
ann_md = gr.Markdown()
|
| 405 |
+
with gr.Accordion("Cross-check vs original HD-EPIC annotation (reference)", open=False):
|
| 406 |
+
xc_md = gr.Markdown()
|
| 407 |
|
| 408 |
outputs = [idx_state, header, video, gallery, ann_md, xc_md] + q_mds + radios + narr_mds + narr_radios + [comment]
|
| 409 |
|
|
|
|
| 446 |
ap.add_argument("--host", default="0.0.0.0")
|
| 447 |
ap.add_argument("--share", action="store_true")
|
| 448 |
a = ap.parse_args()
|
| 449 |
+
demo.launch(server_name=a.host, server_port=a.port, share=a.share, allowed_paths=[str(MEDIA)], show_error=True, css=CSS)
|