Raffael-Kultyshev commited on
Commit
a8115f2
·
1 Parent(s): 1985afa

Fix NoneType error and Gradio compatibility

Browse files
Files changed (1) hide show
  1. app.py +12 -48
app.py CHANGED
@@ -36,17 +36,19 @@ def get_frame_info(frame_idx):
36
  frame_key = str(frame_idx)
37
 
38
  # Hand detection status
39
- hand_data = hands_2d.get(frame_key, {})
40
  left_detected = hand_data.get('left_hand') is not None
41
  right_detected = hand_data.get('right_hand') is not None
42
 
43
  # End effector pose
44
- ee_data = end_effector.get(frame_key, {})
45
- left_pose = ee_data.get('left_hand', {}).get('pose_6dof', None)
46
- right_pose = ee_data.get('right_hand', {}).get('pose_6dof', None)
 
 
47
 
48
  # Action
49
- action_data = actions.get(frame_key, {})
50
  left_action = action_data.get('left_hand_action', None)
51
  camera_action = action_data.get('camera_action', None)
52
 
@@ -107,25 +109,7 @@ def update_display(frame_idx):
107
  return img, info
108
 
109
  # Build Gradio Interface
110
- with gr.Blocks(
111
- title="DI Human Demo Visualizer",
112
- theme=gr.themes.Soft(
113
- primary_hue="cyan",
114
- secondary_hue="purple",
115
- ),
116
- css="""
117
- .header { text-align: center; margin-bottom: 20px; }
118
- .stat-box {
119
- background: linear-gradient(135deg, #1a1a2e, #16213e);
120
- padding: 20px;
121
- border-radius: 12px;
122
- text-align: center;
123
- color: white;
124
- }
125
- .stat-value { font-size: 32px; font-weight: bold; color: #00d4ff; }
126
- .stat-label { font-size: 14px; color: #888; }
127
- """
128
- ) as demo:
129
 
130
  # Header
131
  gr.Markdown("""
@@ -143,33 +127,13 @@ with gr.Blocks(
143
  # Stats row
144
  with gr.Row():
145
  with gr.Column(scale=1):
146
- gr.Markdown(f"""
147
- <div class="stat-box">
148
- <div class="stat-value">{total_frames}</div>
149
- <div class="stat-label">Total Frames</div>
150
- </div>
151
- """)
152
  with gr.Column(scale=1):
153
- gr.Markdown(f"""
154
- <div class="stat-box">
155
- <div class="stat-value">{hand_detection_rate:.1f}%</div>
156
- <div class="stat-label">Hand Detection Rate</div>
157
- </div>
158
- """)
159
  with gr.Column(scale=1):
160
- gr.Markdown(f"""
161
- <div class="stat-box">
162
- <div class="stat-value">{left_poses}</div>
163
- <div class="stat-label">Left Hand Poses</div>
164
- </div>
165
- """)
166
  with gr.Column(scale=1):
167
- gr.Markdown(f"""
168
- <div class="stat-box">
169
- <div class="stat-value">{fps}</div>
170
- <div class="stat-label">FPS</div>
171
- </div>
172
- """)
173
 
174
  gr.Markdown("---")
175
 
 
36
  frame_key = str(frame_idx)
37
 
38
  # Hand detection status
39
+ hand_data = hands_2d.get(frame_key, {}) or {}
40
  left_detected = hand_data.get('left_hand') is not None
41
  right_detected = hand_data.get('right_hand') is not None
42
 
43
  # End effector pose
44
+ ee_data = end_effector.get(frame_key, {}) or {}
45
+ left_hand_data = ee_data.get('left_hand') or {}
46
+ right_hand_data = ee_data.get('right_hand') or {}
47
+ left_pose = left_hand_data.get('pose_6dof', None) if left_hand_data else None
48
+ right_pose = right_hand_data.get('pose_6dof', None) if right_hand_data else None
49
 
50
  # Action
51
+ action_data = actions.get(frame_key, {}) or {}
52
  left_action = action_data.get('left_hand_action', None)
53
  camera_action = action_data.get('camera_action', None)
54
 
 
109
  return img, info
110
 
111
  # Build Gradio Interface
112
+ with gr.Blocks(title="DI Human Demo Visualizer") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  # Header
115
  gr.Markdown("""
 
127
  # Stats row
128
  with gr.Row():
129
  with gr.Column(scale=1):
130
+ gr.Markdown(f"### {total_frames}\n**Total Frames**")
 
 
 
 
 
131
  with gr.Column(scale=1):
132
+ gr.Markdown(f"### {hand_detection_rate:.1f}%\n**Hand Detection**")
 
 
 
 
 
133
  with gr.Column(scale=1):
134
+ gr.Markdown(f"### {left_poses}\n**Left Hand Poses**")
 
 
 
 
 
135
  with gr.Column(scale=1):
136
+ gr.Markdown(f"### {fps}\n**FPS**")
 
 
 
 
 
137
 
138
  gr.Markdown("---")
139