rlogh commited on
Commit
443d8b1
·
verified ·
1 Parent(s): 36bc131

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -9
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
- # Reference video mapping
125
- ref_mapping = {
126
- "Squat": "demo_squat.mp4",
127
- "Pushup": "demo_pushup.mp4",
128
- "Pullup": "demo_pullup.mp4"
 
 
 
129
  }
130
- ref_video = ref_mapping.get(reference_video_choice, "demo_squat.mp4")
131
- ref_path = PROJECT_ROOT / "reference_videos" / ref_video
 
 
 
 
 
 
 
 
 
 
 
132
 
133
- # Process videos
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", "", ""