yonigozlan HF Staff commited on
Commit
7a2c317
·
1 Parent(s): c34b80e

fix error when no person detected in video

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -155,7 +155,6 @@ def process_video(
155
  # ------------------------------------------------------------------------
156
  # Stage 1. Detect humans on the image
157
  # ------------------------------------------------------------------------
158
-
159
  inputs = person_image_processor(images=frame, return_tensors="pt").to(
160
  device
161
  )
@@ -182,6 +181,9 @@ def process_video(
182
  # Stage 2. Detect keypoints for each person found
183
  # ------------------------------------------------------------------------
184
 
 
 
 
185
  inputs = image_processor(
186
  frame, boxes=[person_boxes], return_tensors="pt"
187
  ).to(device)
@@ -231,7 +233,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
231
  gr.Markdown(
232
  """
233
  SynthPose is a new approach that enables finetuning of pre-trained 2D human pose models to predict an arbitrarily denser set of keypoints for accurate kinematic analysis through the use of synthetic data.
234
- More details are available in [OpenCapBench: A Benchmark to Bridge Pose Estimation and Biomechanics](https://arxiv.org/abs/2406.09788).
235
  This particular variant was finetuned on a set of keypoints usually found on motion capture setups, and include coco keypoints as well.<br />
236
  The keypoints part of the skeleton are the COCO keypoints, and the pink ones the anatomical markers.
237
  """
 
155
  # ------------------------------------------------------------------------
156
  # Stage 1. Detect humans on the image
157
  # ------------------------------------------------------------------------
 
158
  inputs = person_image_processor(images=frame, return_tensors="pt").to(
159
  device
160
  )
 
181
  # Stage 2. Detect keypoints for each person found
182
  # ------------------------------------------------------------------------
183
 
184
+ if len(person_boxes) == 0:
185
+ sink.write_frame(frame)
186
+ continue
187
  inputs = image_processor(
188
  frame, boxes=[person_boxes], return_tensors="pt"
189
  ).to(device)
 
233
  gr.Markdown(
234
  """
235
  SynthPose is a new approach that enables finetuning of pre-trained 2D human pose models to predict an arbitrarily denser set of keypoints for accurate kinematic analysis through the use of synthetic data.
236
+ More details are available in [OpenCapBench: A Benchmark to Bridge Pose Estimation and Biomechanics](https://arxiv.org/abs/2406.09788).<br />
237
  This particular variant was finetuned on a set of keypoints usually found on motion capture setups, and include coco keypoints as well.<br />
238
  The keypoints part of the skeleton are the COCO keypoints, and the pink ones the anatomical markers.
239
  """