atnikos commited on
Commit
8d1378a
·
1 Parent(s): 3f9191a

fix examples

Browse files
Files changed (1) hide show
  1. app.py +119 -5
app.py CHANGED
@@ -24,7 +24,31 @@ try:
24
  print("Available EGL libraries:", egl_libs)
25
  except Exception as e:
26
  print(f"Error finding libraries: {e}")
27
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  class MotionEditor:
30
  def __init__(self):
@@ -226,8 +250,8 @@ def create_gradio_interface():
226
  random_key = random.choice(list(current_set.keys()))
227
  motion = current_set[random_key]['motion_a']
228
  text_annot = current_set[random_key]['annotation']
229
-
230
- return motion, text_annot, random_key, text_annot
231
 
232
  def clear():
233
  return ""
@@ -243,6 +267,8 @@ def create_gradio_interface():
243
  with gr.Row():
244
  random_button = gr.Button("Random", scale=0)
245
  clear_button_retrieval = gr.Button("Clear", scale=0)
 
 
246
 
247
  suggested_edit_text = gr.Textbox(
248
  placeholder="Texts likely to edit the motion:",
@@ -259,8 +285,43 @@ def create_gradio_interface():
259
  retrieved_video_output = gr.Video(
260
  label="Retrieved Motion",
261
  height=360,
262
- width=480
 
263
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
  with gr.Column(scale=5):
266
  gr.HTML(WEB_target)
@@ -297,7 +358,60 @@ def create_gradio_interface():
297
  input_text
298
  ]
299
  )
300
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  clear_button_edit.click(clear, outputs=input_text)
302
  clear_button_retrieval.click(clear, outputs=suggested_edit_text)
303
 
 
24
  print("Available EGL libraries:", egl_libs)
25
  except Exception as e:
26
  print(f"Error finding libraries: {e}")
27
+
28
+ # Example videos
29
+ example_videos = [
30
+ "./examples/000652_0_120.mp4", # Replace with actual video paths
31
+ "./examples/000652_0_120.mp4", # Replace with actual video paths
32
+ "./examples/000652_0_120.mp4", # Replace with actual video paths
33
+ "./examples/000652_0_120.mp4", # Replace with actual video paths
34
+ ]
35
+ # Example videos
36
+ example_keys = [
37
+ "000091", # Replace with actual video paths
38
+ "000091", # Replace with actual video paths
39
+ "000091", # Replace with actual video paths
40
+ "000091", # Replace with actual video paths
41
+ ]
42
+ # Example videos
43
+ example_texts = [
44
+ "need to use the opposite leg", # Replace with actual video paths
45
+ "need to use the opposite leg2", # Replace with actual video paths
46
+ "need to use the opposite leg3", # Replace with actual video paths
47
+ "need to use the opposite leg4", # Replace with actual video paths
48
+ ]
49
+ example_video_outputs = [gr.Video(label=f"Example {i+1}",
50
+ value=example_videos[i])
51
+ for i in range(4)]
52
 
53
  class MotionEditor:
54
  def __init__(self):
 
250
  random_key = random.choice(list(current_set.keys()))
251
  motion = current_set[random_key]['motion_a']
252
  text_annot = current_set[random_key]['annotation']
253
+ return gr.update(value=motion,
254
+ visible=True), text_annot, random_key, text_annot
255
 
256
  def clear():
257
  return ""
 
267
  with gr.Row():
268
  random_button = gr.Button("Random", scale=0)
269
  clear_button_retrieval = gr.Button("Clear", scale=0)
270
+ # Example videos grid with buttons
271
+
272
 
273
  suggested_edit_text = gr.Textbox(
274
  placeholder="Texts likely to edit the motion:",
 
285
  retrieved_video_output = gr.Video(
286
  label="Retrieved Motion",
287
  height=360,
288
+ width=480,
289
+ visible=False # Initially hidden
290
  )
291
+ gr.Markdown("### Examples")
292
+ with gr.Row():
293
+ # First example
294
+ with gr.Column():
295
+ gr.Video(value=example_videos[0],
296
+ height=180,width=240,
297
+ label="Example 1")
298
+ example_button1 = gr.Button("Select Example 1",
299
+ size='sm')
300
+
301
+ # Second example
302
+ with gr.Column(scale=2):
303
+ gr.Video(value=example_videos[1],
304
+ height=180,width=240,
305
+ label="Example 2")
306
+ example_button2 = gr.Button("Select Example 2",
307
+ size='sm',scale=1)
308
+ with gr.Row():
309
+
310
+ # Third example
311
+ with gr.Column():
312
+ gr.Video(value=example_videos[2],
313
+ height=180,width=240,
314
+ label="Example 3")
315
+ example_button3 = gr.Button("Select Example 3",
316
+ size='sm')
317
+
318
+ # Fourth example
319
+ with gr.Column():
320
+ gr.Video(value=example_videos[3],
321
+ height=180,width=240,
322
+ label="Example 4")
323
+ example_button4 = gr.Button("Select Example 4",
324
+ size='sm')
325
 
326
  with gr.Column(scale=5):
327
  gr.HTML(WEB_target)
 
358
  input_text
359
  ]
360
  )
361
+ # def load_example_video(example_path):
362
+ # # motion = current_set[random_key]['motion_a']
363
+ # # text_annot = current_set[random_key]['annotation']
364
+ # import ipdb; ipdb.set_trace()
365
+ # return gr.update(value=example_path, visible=True)
366
+ def load_example(example_video, example_key, example_text):
367
+ # Update all outputs
368
+ return (
369
+ gr.update(value=example_video, visible=True), # Update video output
370
+ example_text, # Update suggested edit text
371
+ example_key, # Update random key state
372
+ example_text # Update input text
373
+ )
374
+ example_button1.click(
375
+ fn=lambda: load_example(example_videos[0], example_keys[0], example_texts[0]),
376
+ inputs=None,
377
+ outputs=[
378
+ retrieved_video_output,
379
+ suggested_edit_text,
380
+ random_key_state,
381
+ input_text
382
+ ]
383
+ )
384
+ example_button2.click(
385
+ fn=lambda: load_example(example_videos[1], example_keys[1], example_texts[1]),
386
+ inputs=None,
387
+ outputs=[
388
+ retrieved_video_output,
389
+ suggested_edit_text,
390
+ random_key_state,
391
+ input_text
392
+ ]
393
+ )
394
+ example_button3.click(
395
+ fn=lambda: load_example(example_videos[2], example_keys[2], example_texts[2]),
396
+ inputs=None,
397
+ outputs=[
398
+ retrieved_video_output,
399
+ suggested_edit_text,
400
+ random_key_state,
401
+ input_text
402
+ ]
403
+ )
404
+ example_button4.click(
405
+ fn=lambda: load_example(example_videos[3], example_keys[3], example_texts[3]),
406
+ inputs=None,
407
+ outputs=[
408
+ retrieved_video_output,
409
+ suggested_edit_text,
410
+ random_key_state,
411
+ input_text
412
+ ]
413
+ )
414
+
415
  clear_button_edit.click(clear, outputs=input_text)
416
  clear_button_retrieval.click(clear, outputs=suggested_edit_text)
417