plice13 commited on
Commit
ab9cf38
·
verified ·
1 Parent(s): 14da3dd

Upload 2 files

Browse files
Files changed (2) hide show
  1. backend.py +2 -17
  2. visualize_pose.py +1 -0
backend.py CHANGED
@@ -141,23 +141,8 @@ def process_input(input_video_path):
141
 
142
  print(f"1. Extracting keypoints from video... [{time.time() - start_time:.2f} s since start]")
143
  video_frames, fps = load_video_cv(input_video_path)
144
-
145
- # Normalize high frame rate (e.g. 60 or 120 FPS from webcams/phones) to 30 FPS
146
- if fps and fps > 32:
147
- step = fps / 30.0
148
- num_target_frames = int(len(video_frames) / step)
149
- if num_target_frames > 0:
150
- video_frames = [video_frames[int(i * step)] for i in range(num_target_frames)]
151
- fps = 30.0
152
- print(f"Downsampled high-FPS video to 30 FPS ({len(video_frames)} frames).")
153
-
154
- # Subsample frames if excessively long (e.g. long webcam recordings) to prevent CPU freeze/timeout
155
- max_process_frames = 120
156
- if len(video_frames) > max_process_frames:
157
- step = len(video_frames) / float(max_process_frames)
158
- indices = [int(i * step) for i in range(max_process_frames)]
159
- video_frames = [video_frames[i] for i in indices]
160
- print(f"Subsampled long video ({len(video_frames)} frames) for fast inference.")
161
 
162
  pose_results = predict_pose(video_frames, pose_models)
163
 
 
141
 
142
  print(f"1. Extracting keypoints from video... [{time.time() - start_time:.2f} s since start]")
143
  video_frames, fps = load_video_cv(input_video_path)
144
+ if fps is None or fps <= 0 or np.isnan(fps):
145
+ fps = 25.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  pose_results = predict_pose(video_frames, pose_models)
148
 
visualize_pose.py CHANGED
@@ -361,6 +361,7 @@ def render_keypoints_video(
361
  "-pix_fmt", "rgb24",
362
  "-r", str(fps),
363
  "-i", "-",
 
364
  "-c:v", "libx264",
365
  "-preset", "fast",
366
  "-crf", "18", # Near lossless visual quality
 
361
  "-pix_fmt", "rgb24",
362
  "-r", str(fps),
363
  "-i", "-",
364
+ "-r", str(fps),
365
  "-c:v", "libx264",
366
  "-preset", "fast",
367
  "-crf", "18", # Near lossless visual quality