dylanplummer commited on
Commit
4505013
·
1 Parent(s): 2621d57

add SRC beep detection

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -219,8 +219,9 @@ def count_phases(phase_sin, phase_cos, threshold=0.5):
219
 
220
  def inference(in_video, use_60fps,
221
  beep_detection_on, event_length,
 
222
  count_only_api, api_key, seq_len=64, stride_length=32, stride_pad=3, batch_size=2,
223
- miss_threshold=0.5, marks_threshold=0.5, median_pred_filter=True, both_feet=True,
224
  api_call=False,
225
  progress=gr.Progress()):
226
  print(in_video)
@@ -504,14 +505,14 @@ def inference(in_video, use_60fps,
504
 
505
  if LOCAL:
506
  if both_feet:
507
- count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Marks: {marks_count_pred:.1f}, Phase: {phase_count:.1f}, Confidence: {total_confidence:.2f}, Time to Speed: {time_to_speed:.2f} seconds"
508
  else:
509
- count_msg = f"## Reps Count (one foot): {count_pred:.1f}, Marks: {marks_count_pred:.1f}, Phase: {phase_count:.1f}, Confidence: {total_confidence:.2f}, Time to Speed: {time_to_speed:.2f} seconds"
510
  else:
511
  if both_feet:
512
- count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Confidence: {total_confidence:.2f}"
513
  else:
514
- count_msg = f"## Reps Count (one foot): {count_pred:.1f}, Confidence: {total_confidence:.2f}"
515
 
516
  if api_call:
517
  if CACHE_API_CALLS:
@@ -761,21 +762,23 @@ with gr.Blocks() as demo:
761
  gr.Markdown(
762
  """
763
  ### Inference Options
764
- Select the framerate for inference.
765
  """,
766
  elem_id='inference-options',
767
  )
768
  use_60fps = gr.Checkbox(label="Use 60 FPS", elem_id='use-60fps', visible=True)
 
 
769
  with gr.Column():
770
  gr.Markdown(
771
  """
772
  ### Beep Detection Options
773
- Must be using official IJRU timing tracks.
774
  """,
775
  elem_id='beep-detection-options',
776
  )
777
  beep_detection_on = gr.Checkbox(label="Detect Beeps", elem_id='detect-beeps', visible=True)
778
- event_length = gr.Textbox(label="Expected Event Length (s)", elem_id='event-length', visible=True)
779
 
780
  with gr.Row():
781
  run_button = gr.Button(value="Run", elem_id='run-button', scale=1)
@@ -803,16 +806,16 @@ with gr.Blocks() as demo:
803
 
804
  demo_inference = partial(inference, count_only_api=False, api_key=None)
805
 
806
- run_button.click(demo_inference, [in_video, use_60fps, beep_detection_on, event_length],
807
  outputs=[out_text, out_plot, out_phase_spiral, out_phase, out_hist])
808
  api_inference = partial(inference, api_call=True)
809
  api_dummy_button.click(api_inference, [in_video, use_60fps, beep_detection_on, event_length, count_only, api_token],
810
  outputs=[period_length], api_name='inference')
811
  examples = [
812
- ['files/wc2023.mp4', True, True, 30],
813
  ]
814
  gr.Examples(examples,
815
- inputs=[in_video, use_60fps, beep_detection_on, event_length],
816
  outputs=[out_text, out_plot, out_phase_spiral, out_phase, out_hist],
817
  fn=demo_inference, cache_examples=False)
818
 
 
219
 
220
  def inference(in_video, use_60fps,
221
  beep_detection_on, event_length,
222
+ miss_threshold, marks_threshold,
223
  count_only_api, api_key, seq_len=64, stride_length=32, stride_pad=3, batch_size=2,
224
+ median_pred_filter=True, both_feet=True,
225
  api_call=False,
226
  progress=gr.Progress()):
227
  print(in_video)
 
505
 
506
  if LOCAL:
507
  if both_feet:
508
+ count_msg = f"## Count (both feet): {count_pred:.1f}, Marks: {marks_count_pred:.1f}, Phase: {phase_count:.1f}, Confidence: {total_confidence:.2f}, Time to Speed: {time_to_speed:.2f} seconds"
509
  else:
510
+ count_msg = f"## Count (one foot): {count_pred:.1f}, Marks: {marks_count_pred:.1f}, Phase: {phase_count:.1f}, Confidence: {total_confidence:.2f}, Time to Speed: {time_to_speed:.2f} seconds"
511
  else:
512
  if both_feet:
513
+ count_msg = f"## Count (both feet): {count_pred:.1f}, Confidence: {total_confidence:.2f}"
514
  else:
515
+ count_msg = f"## Count (one foot): {count_pred:.1f}, Confidence: {total_confidence:.2f}"
516
 
517
  if api_call:
518
  if CACHE_API_CALLS:
 
762
  gr.Markdown(
763
  """
764
  ### Inference Options
765
+ Select the framerate and thresholds for inference. Default values should work well for most videos.
766
  """,
767
  elem_id='inference-options',
768
  )
769
  use_60fps = gr.Checkbox(label="Use 60 FPS", elem_id='use-60fps', visible=True)
770
+ miss_threshold = gr.Slider(label="Periodicity Threshold", minimum=0.0, maximum=1.0, step=0.05, value=0.5, elem_id='miss-threshold')
771
+ marks_threshold = gr.Slider(label="Marks Threshold", minimum=0.0, maximum=1.0, step=0.05, value=0.5, elem_id='marks-threshold')
772
  with gr.Column():
773
  gr.Markdown(
774
  """
775
  ### Beep Detection Options
776
+ Must be using official Single Rope Contest timing tracks.
777
  """,
778
  elem_id='beep-detection-options',
779
  )
780
  beep_detection_on = gr.Checkbox(label="Detect Beeps", elem_id='detect-beeps', visible=True)
781
+ event_length = gr.Textbox(label="Expected Event Length (s)", elem_id='event-length', visible=True, value="30")
782
 
783
  with gr.Row():
784
  run_button = gr.Button(value="Run", elem_id='run-button', scale=1)
 
806
 
807
  demo_inference = partial(inference, count_only_api=False, api_key=None)
808
 
809
+ run_button.click(demo_inference, [in_video, use_60fps, beep_detection_on, event_length, miss_threshold, marks_threshold],
810
  outputs=[out_text, out_plot, out_phase_spiral, out_phase, out_hist])
811
  api_inference = partial(inference, api_call=True)
812
  api_dummy_button.click(api_inference, [in_video, use_60fps, beep_detection_on, event_length, count_only, api_token],
813
  outputs=[period_length], api_name='inference')
814
  examples = [
815
+ ['files/wc2023.mp4', True, True, 30, 0.5, 0.5],
816
  ]
817
  gr.Examples(examples,
818
+ inputs=[in_video, use_60fps, beep_detection_on, event_length, miss_threshold, marks_threshold],
819
  outputs=[out_text, out_plot, out_phase_spiral, out_phase, out_hist],
820
  fn=demo_inference, cache_examples=False)
821