Commit
·
07f7141
1
Parent(s):
57d371c
Add error handling for data loading
Browse files
app.py
CHANGED
|
@@ -14,17 +14,25 @@ def load_json_safe(path):
|
|
| 14 |
except:
|
| 15 |
return {}
|
| 16 |
|
| 17 |
-
# Load data
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
video_path = DATA_DIR / "video.mp4"
|
| 30 |
|
|
|
|
| 14 |
except:
|
| 15 |
return {}
|
| 16 |
|
| 17 |
+
# Load data with error handling
|
| 18 |
+
try:
|
| 19 |
+
metadata = load_json_safe(DATA_DIR / "metadata.json")
|
| 20 |
+
end_effector = load_json_safe(DATA_DIR / "end_effector.json")
|
| 21 |
+
hands_2d = load_json_safe(DATA_DIR / "hands_2d.json")
|
| 22 |
+
|
| 23 |
+
total_frames = max(1, len(metadata.get('poses', [])))
|
| 24 |
+
fps = metadata.get('fps', 60)
|
| 25 |
+
hand_detection_rate = len(hands_2d) / total_frames * 100 if total_frames > 0 else 0
|
| 26 |
+
|
| 27 |
+
left_poses = sum(1 for f in end_effector.values() if f and isinstance(f, dict) and f.get('left_hand'))
|
| 28 |
+
right_poses = sum(1 for f in end_effector.values() if f and isinstance(f, dict) and f.get('right_hand'))
|
| 29 |
+
except Exception as e:
|
| 30 |
+
print(f"Error loading data: {e}")
|
| 31 |
+
total_frames = 0
|
| 32 |
+
fps = 60
|
| 33 |
+
hand_detection_rate = 0
|
| 34 |
+
left_poses = 0
|
| 35 |
+
right_poses = 0
|
| 36 |
|
| 37 |
video_path = DATA_DIR / "video.mp4"
|
| 38 |
|