Upload app.py
Browse files
app.py
CHANGED
|
@@ -121,19 +121,32 @@ def analyze_video(video_file, persona_choice, reference_video_choice):
|
|
| 121 |
# Process video and get pose analysis
|
| 122 |
video_path = video_file
|
| 123 |
|
| 124 |
-
#
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
-
# Process
|
| 134 |
print(f"Processing {video_path}...")
|
| 135 |
user_results = process_video(video_path)
|
| 136 |
-
ref_results = process_video(str(ref_path)) if ref_path.exists() else None
|
| 137 |
|
| 138 |
if not user_results or 'keypoints_3d' not in user_results:
|
| 139 |
return "Failed to process video - no pose detected", "", ""
|
|
|
|
| 121 |
# Process video and get pose analysis
|
| 122 |
video_path = video_file
|
| 123 |
|
| 124 |
+
# Download reference data from HF Dataset
|
| 125 |
+
from huggingface_hub import hf_hub_download
|
| 126 |
+
|
| 127 |
+
# Map exercise to reference
|
| 128 |
+
exercise_map = {
|
| 129 |
+
"Squat": "squat",
|
| 130 |
+
"Pushup": "pushup",
|
| 131 |
+
"Pullup": "pullup"
|
| 132 |
}
|
| 133 |
+
exercise_id = exercise_map.get(reference_video_choice, "pushup")
|
| 134 |
+
|
| 135 |
+
# Download reference keypoints from dataset
|
| 136 |
+
try:
|
| 137 |
+
ref_3d_path = hf_hub_download(
|
| 138 |
+
repo_id="rlogh/fitness-coach-references",
|
| 139 |
+
filename=f"{exercise_id}/keypoints_3D.npz",
|
| 140 |
+
repo_type="dataset"
|
| 141 |
+
)
|
| 142 |
+
ref_results = {'keypoints_3d': np.load(ref_3d_path)['reconstruction']}
|
| 143 |
+
except Exception as e:
|
| 144 |
+
print(f"Warning: Could not load reference: {e}")
|
| 145 |
+
ref_results = None
|
| 146 |
|
| 147 |
+
# Process user video
|
| 148 |
print(f"Processing {video_path}...")
|
| 149 |
user_results = process_video(video_path)
|
|
|
|
| 150 |
|
| 151 |
if not user_results or 'keypoints_3d' not in user_results:
|
| 152 |
return "Failed to process video - no pose detected", "", ""
|