Raffael-Kultyshev commited on
Commit
9e02de3
·
1 Parent(s): 045f914

Make plots optional with try-except

Browse files
Files changed (1) hide show
  1. app.py +33 -17
app.py CHANGED
@@ -365,23 +365,39 @@ with gr.Blocks(theme=theme, css=CUSTOM_CSS) as demo:
365
  elem_classes=["download-button"],
366
  )
367
 
368
- gr.Markdown("### Left Hand Trajectories", elem_classes=["plots-title"])
369
- plot_outputs_left = []
370
- with gr.Column(elem_classes=["plots-wrap"]):
371
- for row in PLOT_GRID:
372
- with gr.Row():
373
- for metric in row:
374
- plot = gr.HTML(value=build_plot_html(metric, "left"), elem_classes=["plot-html"])
375
- plot_outputs_left.append(plot)
376
-
377
- gr.Markdown("### Right Hand Trajectories", elem_classes=["plots-title"])
378
- plot_outputs_right = []
379
- with gr.Column(elem_classes=["plots-wrap"]):
380
- for row in PLOT_GRID:
381
- with gr.Row():
382
- for metric in row:
383
- plot = gr.HTML(value=build_plot_html(metric, "right"), elem_classes=["plot-html"])
384
- plot_outputs_right.append(plot)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
 
386
  if __name__ == "__main__":
387
  demo.queue().launch(show_api=False)
 
365
  elem_classes=["download-button"],
366
  )
367
 
368
+ try:
369
+ gr.Markdown("### Left Hand Trajectories", elem_classes=["plots-title"])
370
+ plot_outputs_left = []
371
+ with gr.Column(elem_classes=["plots-wrap"]):
372
+ for row in PLOT_GRID:
373
+ with gr.Row():
374
+ for metric in row:
375
+ try:
376
+ plot_html = build_plot_html(metric, "left")
377
+ plot = gr.HTML(value=plot_html, elem_classes=["plot-html"])
378
+ plot_outputs_left.append(plot)
379
+ except Exception as e:
380
+ print(f"Error creating plot {metric} for left hand: {e}")
381
+ plot = gr.HTML(value="<p>Plot unavailable</p>", elem_classes=["plot-html"])
382
+ plot_outputs_left.append(plot)
383
+
384
+ gr.Markdown("### Right Hand Trajectories", elem_classes=["plots-title"])
385
+ plot_outputs_right = []
386
+ with gr.Column(elem_classes=["plots-wrap"]):
387
+ for row in PLOT_GRID:
388
+ with gr.Row():
389
+ for metric in row:
390
+ try:
391
+ plot_html = build_plot_html(metric, "right")
392
+ plot = gr.HTML(value=plot_html, elem_classes=["plot-html"])
393
+ plot_outputs_right.append(plot)
394
+ except Exception as e:
395
+ print(f"Error creating plot {metric} for right hand: {e}")
396
+ plot = gr.HTML(value="<p>Plot unavailable</p>", elem_classes=["plot-html"])
397
+ plot_outputs_right.append(plot)
398
+ except Exception as e:
399
+ print(f"Error creating plots section: {e}")
400
+ gr.Markdown("### Plots unavailable")
401
 
402
  if __name__ == "__main__":
403
  demo.queue().launch(show_api=False)