Raffael-Kultyshev commited on
Commit
57d371c
·
1 Parent(s): abe51d3

Add sidebar with stats and video player

Browse files
Files changed (1) hide show
  1. app.py +85 -6
app.py CHANGED
@@ -1,16 +1,95 @@
1
  """
2
- Minimal test version
3
  """
4
  import gradio as gr
 
5
  from pathlib import Path
6
 
7
  DATA_DIR = Path(__file__).parent / "data"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  video_path = DATA_DIR / "video.mp4"
9
 
10
- with gr.Blocks() as demo:
11
- gr.Markdown("# Test")
12
- gr.Video(value=str(video_path) if video_path.exists() else None)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- if __name__ == "__main__":
15
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  """
2
+ Dynamic Intelligence - Human Demo Visualizer
3
  """
4
  import gradio as gr
5
+ import json
6
  from pathlib import Path
7
 
8
  DATA_DIR = Path(__file__).parent / "data"
9
+
10
+ def load_json_safe(path):
11
+ try:
12
+ with open(path, 'r') as f:
13
+ return json.load(f)
14
+ except:
15
+ return {}
16
+
17
+ # Load data
18
+ metadata = load_json_safe(DATA_DIR / "metadata.json")
19
+ end_effector = load_json_safe(DATA_DIR / "end_effector.json")
20
+ hands_2d = load_json_safe(DATA_DIR / "hands_2d.json")
21
+
22
+ total_frames = max(1, len(metadata.get('poses', [])))
23
+ fps = metadata.get('fps', 60)
24
+ hand_detection_rate = len(hands_2d) / total_frames * 100
25
+
26
+ left_poses = sum(1 for f in end_effector.values() if f and isinstance(f, dict) and f.get('left_hand'))
27
+ right_poses = sum(1 for f in end_effector.values() if f and isinstance(f, dict) and f.get('right_hand'))
28
+
29
  video_path = DATA_DIR / "video.mp4"
30
 
31
+ CUSTOM_CSS = """
32
+ :root, .gradio-container, body {
33
+ background-color: #050a18 !important;
34
+ color: #f8fafc !important;
35
+ }
36
+ .side-panel {
37
+ background: #0f172a;
38
+ padding: 20px;
39
+ border-radius: 18px;
40
+ border: 1px solid #1f2b47;
41
+ }
42
+ .stats-card ul {
43
+ list-style: none;
44
+ padding: 0;
45
+ margin: 0;
46
+ font-size: 0.92rem;
47
+ }
48
+ .stats-card li {
49
+ margin-bottom: 10px;
50
+ color: #e2e8f0;
51
+ }
52
+ .stats-card span {
53
+ display: inline-block;
54
+ margin-right: 6px;
55
+ color: #7dd3fc;
56
+ }
57
+ """
58
 
59
+ stats_html = f"""
60
+ <div class="stats-card">
61
+ <ul>
62
+ <li><span>Number of samples/frames:</span> {total_frames:,}</li>
63
+ <li><span>Hand detection rate:</span> {hand_detection_rate:.1f}%</li>
64
+ <li><span>Left hand poses:</span> {left_poses}</li>
65
+ <li><span>Right hand poses:</span> {right_poses}</li>
66
+ <li><span>Frames per second:</span> {fps:.1f}</li>
67
+ </ul>
68
+ </div>
69
+ """
70
+
71
+ theme = gr.themes.Soft(
72
+ primary_hue="cyan", secondary_hue="blue", neutral_hue="slate"
73
+ ).set(
74
+ body_background_fill="#0c1424",
75
+ body_text_color="#f8fafc",
76
+ block_background_fill="#111a2c",
77
+ )
78
 
79
+ with gr.Blocks(theme=theme, css=CUSTOM_CSS) as demo:
80
+ gr.Markdown("# 🤖 Dynamic Intelligence - Human Demo Visualizer")
81
+ gr.Markdown("Egocentric hand tracking dataset for humanoid robot training")
82
+
83
+ with gr.Row(equal_height=True):
84
+ with gr.Column(scale=1, min_width=260, elem_classes=["side-panel"]):
85
+ gr.HTML(stats_html)
86
+ with gr.Column(scale=2, min_width=640):
87
+ gr.Markdown("### RGB Video")
88
+ video = gr.Video(
89
+ height=360,
90
+ value=str(video_path) if video_path.exists() else None,
91
+ show_label=False,
92
+ )
93
+
94
+ if __name__ == "__main__":
95
+ demo.queue().launch(show_api=False)