dylanplummer commited on
Commit
dbab62b
·
1 Parent(s): f142dbc

ijru2025 updates

Browse files
Files changed (2) hide show
  1. app.py +141 -17
  2. hls_download.py +2 -1
app.py CHANGED
@@ -73,6 +73,7 @@ def preprocess_image(img, img_size):
73
 
74
 
75
  def run_inference(batch_X):
 
76
  batch_X = torch.cat(batch_X)
77
  return ort_sess.run(None, {'video': batch_X.numpy()})
78
 
@@ -114,6 +115,7 @@ def detect_beeps(video_path, target_event_length=30, beep_height=0.8):
114
 
115
  # Extract audio from video
116
  audio_convert_command = f'ffmpeg -i {video_path} -vn -acodec pcm_s16le -ar {fs} -ac 2 temp.wav'
 
117
  subprocess.call(audio_convert_command, shell=True)
118
 
119
  # Read the extracted audio
@@ -307,17 +309,45 @@ def upload_video(out_text, in_video):
307
  )
308
 
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choice,
311
  beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay,
312
- count_only_api, api_key, seq_len=64, stride_length=32, stride_pad=3, batch_size=4,
313
- miss_threshold=0.8, marks_threshold=0.5, median_pred_filter=True, both_feet=True,
314
  api_call=False,
315
  progress=gr.Progress()):
316
- global current_model
 
317
  if model_choice != current_model:
318
  current_model = model_choice
319
  onnx_file = hf_hub_download(repo_id="lumos-motion/nextjump", filename=f"{current_model}.onnx", repo_type="model", token=os.environ['DATASET_SECRET'])
320
-
321
 
322
  if torch.cuda.is_available():
323
  print("Using CUDA")
@@ -333,8 +363,10 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
333
  # warmup inference
334
  ort_sess.run(None, {'video': np.zeros((4, 64, 3, IMG_SIZE, IMG_SIZE), dtype=np.float32)})
335
  if in_video is None:
 
336
  in_video = download_clips(stream_url, os.path.join(os.getcwd(), 'clips'), start_time, end_time, use_60fps=use_60fps)
337
  else: # local uploaded video (still resize with ffmpeg)
 
338
  in_video = download_clips(in_video, os.path.join(os.getcwd(), 'clips'), start_time, end_time, use_60fps=use_60fps)
339
  progress(0, desc="Running inference...")
340
  has_access = False
@@ -401,7 +433,7 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
401
  batch_list = []
402
  idx_list = []
403
  inference_futures = []
404
- with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
405
  for i in progress.tqdm(range(0, length + stride_length - stride_pad, stride_length)):
406
  batch = all_frames[i:i + seq_len]
407
  Xlist = []
@@ -499,17 +531,20 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
499
  full_marks_mask = np.zeros(len(full_marks))
500
  full_marks_mask[pred_marks_peaks] = 1
501
  periodicity_mask = np.int32(periodicity > miss_threshold)
 
502
  numofReps = 0
503
  count = []
504
  miss_detected = True
505
- num_misses = 0
 
506
  for i in range(len(periodLength)):
507
  if periodLength[i] < 2 or periodicity_mask[i] == 0:
508
  numofReps += 0
509
  if not miss_detected:
510
  miss_detected = True
511
  num_misses += 1
512
- numofReps -= 2
 
513
  elif full_marks_mask[i]: # high confidence mark detected
514
  if math.modf(numofReps)[0] < 0.2: # probably false positive/late detection
515
  numofReps = float(int(numofReps))
@@ -526,6 +561,7 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
526
  # if a jump was counted, and periodicity is high, and the next frame was not counted (to avoid double counting)
527
  if full_marks_mask[i] > 0 and periodicity_mask[i] > 0 and full_marks_mask[i + 1] == 0:
528
  marks_count_pred += 1
 
529
  if not both_feet:
530
  count_pred = count_pred / 2
531
  marks_count_pred = marks_count_pred / 2
@@ -545,11 +581,84 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
545
  self_pct_err = 0
546
  total_confidence = confidence * (1 - self_pct_err)
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  if LOCAL:
549
  if both_feet:
550
- count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Marks Count (both feet): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
551
  else:
552
- count_msg = f"## Reps Count (one foot): {count_pred:.1f}, Marks Count (one foot): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
553
  else:
554
  if both_feet:
555
  count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Confidence: {total_confidence:.2f}"
@@ -575,7 +684,21 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
575
  "cum_count": np.array2string(np.array(count), formatter={'float_kind':lambda x: "%.2f" % x}, threshold=np.inf).replace('\n', ''),
576
  "count": f"{count_pred:.2f}",
577
  "marks": f"{marks_count_pred:.1f}",
 
578
  "confidence": f"{total_confidence:.2f}",
 
 
 
 
 
 
 
 
 
 
 
 
 
579
  "single_rope_speed": f"{event_type_probs[0]:.3f}",
580
  "double_dutch": f"{event_type_probs[1]:.3f}",
581
  "double_unders": f"{event_type_probs[2]:.3f}",
@@ -710,8 +833,10 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
710
  # phase_cos = np.cos(np.arctan2(phase_sin, phase_cos) - np.pi / 2)
711
 
712
  # plot phase spiral using plotly
 
 
713
  fig_phase_spiral = px.scatter(x=phase_cos, y=phase_sin,
714
- color=jumps_per_second,
715
  color_continuous_scale='plasma',
716
  title="Phase Spiral (speed)",
717
  template="plotly_dark")
@@ -725,7 +850,7 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
725
  )
726
  # label colorbar as time
727
  fig_phase_spiral.update_coloraxes(colorbar=dict(
728
- title="Jumps per second"))
729
  # make axes equal
730
  fig_phase_spiral.update_layout(
731
  xaxis=dict(scaleanchor="y"),
@@ -792,7 +917,7 @@ def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choic
792
  except FileNotFoundError:
793
  pass
794
 
795
- return in_video, count_msg, fig, fig_phase_spiral, fig_phase_spiral_marks, hist, bar
796
 
797
  #css = '#phase-spiral {transform: rotate(0.25turn);}\n#phase-spiral-marks {transform: rotate(0.25turn);}'
798
  with gr.Blocks() as demo:
@@ -823,6 +948,7 @@ with gr.Blocks() as demo:
823
  use_60fps = gr.Checkbox(label="Use 60 FPS", elem_id='use-60fps', visible=True)
824
  model_choice = gr.Dropdown(
825
  ["nextjump_speed", "nextjump_all", "nextjump_both_feet"], label="Model Choice", info="For now just speed-only or general model",
 
826
  )
827
  with gr.Column():
828
  gr.Markdown(
@@ -837,8 +963,6 @@ with gr.Blocks() as demo:
837
  relay_detection_on = gr.Checkbox(label="Relay Event", elem_id='relay-beeps', visible=True)
838
  relay_length = gr.Textbox(label="Relay Length (s)", elem_id='relay-length', visible=True, value='30')
839
  switch_delay = gr.Textbox(label="Expected Switch Delay (s)", elem_id='event-length', visible=True, value='0.2')
840
- with gr.Column(min_width=480):
841
- out_video = gr.PlayableVideo(label="Video Clip", elem_id='output-video', format='mp4', width=400, height=400)
842
 
843
  with gr.Row():
844
  run_button = gr.Button(value="Run", elem_id='run-button', scale=1)
@@ -869,7 +993,7 @@ with gr.Blocks() as demo:
869
  demo_inference = partial(inference, count_only_api=False, api_key=None)
870
 
871
  run_button.click(demo_inference, [in_video, in_stream_url, in_stream_start, in_stream_end, use_60fps, model_choice, beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay],
872
- outputs=[out_video, out_text, out_plot, out_phase_spiral, out_phase, out_hist, out_event_type_dist])
873
  api_inference = partial(inference, api_call=True)
874
  api_dummy_button.click(api_inference, [in_video, in_stream_url, in_stream_start, in_stream_end, use_60fps, model_choice, beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay, count_only, api_token],
875
  outputs=[period_length], api_name='inference')
@@ -881,7 +1005,7 @@ with gr.Blocks() as demo:
881
  ]
882
  gr.Examples(examples,
883
  inputs=[in_video, in_stream_url, in_stream_start, in_stream_end, use_60fps, model_choice, beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay],
884
- outputs=[out_video, out_text, out_plot, out_phase_spiral, out_phase, out_hist, out_event_type_dist],
885
  fn=demo_inference, cache_examples=False)
886
 
887
 
@@ -891,6 +1015,6 @@ if __name__ == "__main__":
891
  server_port=7860,
892
  debug=False,
893
  ssl_verify=False,
894
- share=False)
895
  else:
896
  demo.queue(api_open=True, max_size=15).launch(share=False)
 
73
 
74
 
75
  def run_inference(batch_X):
76
+ global ort_sess
77
  batch_X = torch.cat(batch_X)
78
  return ort_sess.run(None, {'video': batch_X.numpy()})
79
 
 
115
 
116
  # Extract audio from video
117
  audio_convert_command = f'ffmpeg -i {video_path} -vn -acodec pcm_s16le -ar {fs} -ac 2 temp.wav'
118
+ print(audio_convert_command)
119
  subprocess.call(audio_convert_command, shell=True)
120
 
121
  # Read the extracted audio
 
309
  )
310
 
311
 
312
+ def count_phases(phase_sin, phase_cos, threshold=0.5):
313
+ """
314
+ Count the number of phase transitions in the sine and cosine phases.
315
+
316
+ Args:
317
+ phase_sin: Numpy array of sine phase values
318
+ phase_cos: Numpy array of cosine phase values
319
+ threshold: Threshold to consider a transition
320
+ Returns:
321
+ count: Number of phase transitions
322
+ phase_indices: Indices where transitions occur
323
+ """
324
+ phase_indices = []
325
+ count = 0
326
+ for i in range(1, len(phase_sin)):
327
+ # Check if the sine and cosine phases cross each other
328
+ if (phase_sin[i-1] < threshold and phase_sin[i] >= threshold) or \
329
+ (phase_sin[i-1] >= threshold and phase_sin[i] < threshold):
330
+ # Check if the cosine phase crosses the threshold
331
+ if (phase_cos[i-1] < threshold and phase_cos[i] >= threshold) or \
332
+ (phase_cos[i-1] >= threshold and phase_cos[i] < threshold):
333
+ phase_indices.append(i)
334
+ count += 1
335
+ return count, phase_indices
336
+
337
+
338
+
339
  def inference(in_video, stream_url, start_time, end_time, use_60fps, model_choice,
340
  beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay,
341
+ count_only_api, api_key, seq_len=64, stride_length=32, stride_pad=3, batch_size=2,
342
+ miss_threshold=0.5, marks_threshold=0.5, median_pred_filter=True, both_feet=True,
343
  api_call=False,
344
  progress=gr.Progress()):
345
+ global current_model, ort_sess
346
+ print(in_video)
347
  if model_choice != current_model:
348
  current_model = model_choice
349
  onnx_file = hf_hub_download(repo_id="lumos-motion/nextjump", filename=f"{current_model}.onnx", repo_type="model", token=os.environ['DATASET_SECRET'])
350
+ #onnx_file = f'{current_model}.onnx'
351
 
352
  if torch.cuda.is_available():
353
  print("Using CUDA")
 
363
  # warmup inference
364
  ort_sess.run(None, {'video': np.zeros((4, 64, 3, IMG_SIZE, IMG_SIZE), dtype=np.float32)})
365
  if in_video is None:
366
+ print("No video input provided.")
367
  in_video = download_clips(stream_url, os.path.join(os.getcwd(), 'clips'), start_time, end_time, use_60fps=use_60fps)
368
  else: # local uploaded video (still resize with ffmpeg)
369
+ print("Using uploaded video input.")
370
  in_video = download_clips(in_video, os.path.join(os.getcwd(), 'clips'), start_time, end_time, use_60fps=use_60fps)
371
  progress(0, desc="Running inference...")
372
  has_access = False
 
433
  batch_list = []
434
  idx_list = []
435
  inference_futures = []
436
+ with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
437
  for i in progress.tqdm(range(0, length + stride_length - stride_pad, stride_length)):
438
  batch = all_frames[i:i + seq_len]
439
  Xlist = []
 
531
  full_marks_mask = np.zeros(len(full_marks))
532
  full_marks_mask[pred_marks_peaks] = 1
533
  periodicity_mask = np.int32(periodicity > miss_threshold)
534
+ phase_count, phase_indices = count_phases(phase_sin, phase_cos, threshold=-0.5)
535
  numofReps = 0
536
  count = []
537
  miss_detected = True
538
+ num_misses = -1 # end of event is not counted as a miss
539
+ miss_frames = []
540
  for i in range(len(periodLength)):
541
  if periodLength[i] < 2 or periodicity_mask[i] == 0:
542
  numofReps += 0
543
  if not miss_detected:
544
  miss_detected = True
545
  num_misses += 1
546
+ miss_frames.append(i)
547
+ #numofReps -= 2
548
  elif full_marks_mask[i]: # high confidence mark detected
549
  if math.modf(numofReps)[0] < 0.2: # probably false positive/late detection
550
  numofReps = float(int(numofReps))
 
561
  # if a jump was counted, and periodicity is high, and the next frame was not counted (to avoid double counting)
562
  if full_marks_mask[i] > 0 and periodicity_mask[i] > 0 and full_marks_mask[i + 1] == 0:
563
  marks_count_pred += 1
564
+
565
  if not both_feet:
566
  count_pred = count_pred / 2
567
  marks_count_pred = marks_count_pred / 2
 
581
  self_pct_err = 0
582
  total_confidence = confidence * (1 - self_pct_err)
583
 
584
+ # find the fastest second (30 frames if 30fp and 60 frames if 60fps) based on the period_length
585
+ scan_window = 60 if use_60fps else 30
586
+ fastest_frames_start = 0
587
+ fastest_period = float('inf')
588
+ for i in range(0, len(periodLength) - scan_window, scan_window // 2):
589
+ #if np.sum(periodicity_mask[i:i + scan_window]) > 0:
590
+ avg_period = np.mean(periodLength[i:i + scan_window])
591
+ if avg_period < fastest_period:
592
+ fastest_period = avg_period
593
+ fastest_frames_start = i
594
+ fastest_frames_end = fastest_frames_start + scan_window
595
+ fastest_jumps_per_second = np.clip(1 / ((fastest_period / fps) + 0.0001), 0, 10)
596
+ print(f"Fastest jumps per second: {fastest_jumps_per_second:.2f} (from frames {fastest_frames_start} to {fastest_frames_end})")
597
+
598
+ # measure the reaction time to the beep (if beep detection is on) as the time to reach average speed
599
+ time_to_speed = 0
600
+ if beep_detection_on:
601
+ avg_speed = np.mean(periodLength[periodicity_mask])
602
+ reaction_frame = np.argmax((periodLength < avg_speed) & (periodicity_mask))
603
+ print(f"Reaction frame: {reaction_frame}, Avg Speed: {avg_speed}")
604
+ time_to_speed = (reaction_frame - event_start) / fps
605
+
606
+ # get peak speed and lowest speed
607
+ peak_speed = np.quantile(periodLength[periodicity_mask], 0.01) if np.any(periodicity_mask) else 0
608
+ lowest_speed = np.quantile(periodLength[periodicity_mask], 0.99) if np.any(periodicity_mask) else 0
609
+ peak_jps = np.clip(1 / ((peak_speed / fps) + 0.0001), 0, 10)
610
+ lowest_jps = np.clip(1 / ((lowest_speed / fps) + 0.0001), 0, 10)
611
+ slowdown = (lowest_jps - peak_jps)
612
+ slowdown_percent = (slowdown / peak_jps) * 100 if peak_jps > 0 else 0
613
+
614
+ print('slowdown', slowdown)
615
+ print('percent', slowdown_percent)
616
+
617
+ # estimate the score assuming no misses and fill in the gaps
618
+ estimated_score = 0
619
+ filled_periodLength = np.zeros(len(periodLength))
620
+ started = False
621
+ for i in range(len(periodLength)):
622
+ if beep_detection_on and i < event_start:
623
+ filled_periodLength[i] = 0
624
+ elif beep_detection_on and i >= event_end:
625
+ filled_periodLength[i] = 0
626
+ elif periodicity_mask[i] > 0:
627
+ started = True
628
+ filled_periodLength[i] = periodLength[i]
629
+ elif not started:
630
+ filled_periodLength[i] = 0
631
+ else:
632
+ # fill in the gaps with the previous value
633
+ filled_periodLength[i] = filled_periodLength[i - 1]
634
+ estimated_score = 0
635
+ for i in range(len(filled_periodLength)):
636
+ if filled_periodLength[i] < 2:
637
+ estimated_score += 0
638
+ else:
639
+ estimated_score += max(0, periodicity_mask[i] / (filled_periodLength[i]))
640
+ print(f"Estimated score: {estimated_score:.2f}")
641
+
642
+ # find the recovery times after each miss
643
+ recovery_times = []
644
+ if len(miss_frames) > 0:
645
+ avg_speed = np.mean(periodLength[periodicity_mask])
646
+ for miss_frame in miss_frames:
647
+ # find the next frame where the speed is above avg_speed
648
+ recovery_frame = np.argmax((periodLength[miss_frame:] > avg_speed) & (periodicity_mask[miss_frame:])) + miss_frame
649
+ if recovery_frame > miss_frame:
650
+ recovery_time = (recovery_frame - miss_frame) / fps
651
+ recovery_times.append(recovery_time)
652
+ else: # end of event
653
+ pass
654
+ print(f"Recovery times: {recovery_times}")
655
+
656
+
657
  if LOCAL:
658
  if both_feet:
659
+ 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"
660
  else:
661
+ 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"
662
  else:
663
  if both_feet:
664
  count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Confidence: {total_confidence:.2f}"
 
684
  "cum_count": np.array2string(np.array(count), formatter={'float_kind':lambda x: "%.2f" % x}, threshold=np.inf).replace('\n', ''),
685
  "count": f"{count_pred:.2f}",
686
  "marks": f"{marks_count_pred:.1f}",
687
+ "phase_count": f"{phase_count:.1f}",
688
  "confidence": f"{total_confidence:.2f}",
689
+ "fastest_frames_start": fastest_frames_start,
690
+ "fastest_frames_end": fastest_frames_end,
691
+ "fastest_jumps_per_second": f"{fastest_jumps_per_second:.2f}",
692
+ "lowest_jumps_per_second": f"{lowest_jps:.2f}",
693
+ "fastest_period_length": f"{fastest_period:.2f}",
694
+ "lowest_period_length": f"{lowest_speed:.2f}",
695
+ "time_to_speed": f"{time_to_speed:.2f}" if beep_detection_on else 0,
696
+ "slowdown": f"{slowdown:.2f}",
697
+ "slowdown_percent": f"{slowdown_percent:.2f}",
698
+ "num_misses": num_misses,
699
+ "miss_frames": np.array2string(np.array(miss_frames[:num_misses]), formatter={'int':lambda x: str(x)}, threshold=np.inf).replace('\n', ''),
700
+ "recovery_times": np.array2string(np.array(recovery_times), formatter={'float_kind':lambda x: "%.2f" % x}, threshold=np.inf).replace('\n', ''),
701
+ "no_miss_score": f"{estimated_score:.2f}" if num_misses > 0 else f"{count_pred:.2f}",
702
  "single_rope_speed": f"{event_type_probs[0]:.3f}",
703
  "double_dutch": f"{event_type_probs[1]:.3f}",
704
  "double_unders": f"{event_type_probs[2]:.3f}",
 
833
  # phase_cos = np.cos(np.arctan2(phase_sin, phase_cos) - np.pi / 2)
834
 
835
  # plot phase spiral using plotly
836
+ phase_jumps = np.zeros(len(phase_sin))
837
+ phase_jumps[phase_indices] = 1
838
  fig_phase_spiral = px.scatter(x=phase_cos, y=phase_sin,
839
+ color=phase_jumps,
840
  color_continuous_scale='plasma',
841
  title="Phase Spiral (speed)",
842
  template="plotly_dark")
 
850
  )
851
  # label colorbar as time
852
  fig_phase_spiral.update_coloraxes(colorbar=dict(
853
+ title="Phase Jumps",))
854
  # make axes equal
855
  fig_phase_spiral.update_layout(
856
  xaxis=dict(scaleanchor="y"),
 
917
  except FileNotFoundError:
918
  pass
919
 
920
+ return count_msg, fig, fig_phase_spiral, fig_phase_spiral_marks, hist, bar
921
 
922
  #css = '#phase-spiral {transform: rotate(0.25turn);}\n#phase-spiral-marks {transform: rotate(0.25turn);}'
923
  with gr.Blocks() as demo:
 
948
  use_60fps = gr.Checkbox(label="Use 60 FPS", elem_id='use-60fps', visible=True)
949
  model_choice = gr.Dropdown(
950
  ["nextjump_speed", "nextjump_all", "nextjump_both_feet"], label="Model Choice", info="For now just speed-only or general model",
951
+ value="nextjump_speed", elem_id='model-choice'
952
  )
953
  with gr.Column():
954
  gr.Markdown(
 
963
  relay_detection_on = gr.Checkbox(label="Relay Event", elem_id='relay-beeps', visible=True)
964
  relay_length = gr.Textbox(label="Relay Length (s)", elem_id='relay-length', visible=True, value='30')
965
  switch_delay = gr.Textbox(label="Expected Switch Delay (s)", elem_id='event-length', visible=True, value='0.2')
 
 
966
 
967
  with gr.Row():
968
  run_button = gr.Button(value="Run", elem_id='run-button', scale=1)
 
993
  demo_inference = partial(inference, count_only_api=False, api_key=None)
994
 
995
  run_button.click(demo_inference, [in_video, in_stream_url, in_stream_start, in_stream_end, use_60fps, model_choice, beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay],
996
+ outputs=[out_text, out_plot, out_phase_spiral, out_phase, out_hist, out_event_type_dist])
997
  api_inference = partial(inference, api_call=True)
998
  api_dummy_button.click(api_inference, [in_video, in_stream_url, in_stream_start, in_stream_end, use_60fps, model_choice, beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay, count_only, api_token],
999
  outputs=[period_length], api_name='inference')
 
1005
  ]
1006
  gr.Examples(examples,
1007
  inputs=[in_video, in_stream_url, in_stream_start, in_stream_end, use_60fps, model_choice, beep_detection_on, event_length, relay_detection_on, relay_length, switch_delay],
1008
+ outputs=[out_text, out_plot, out_phase_spiral, out_phase, out_hist, out_event_type_dist],
1009
  fn=demo_inference, cache_examples=False)
1010
 
1011
 
 
1015
  server_port=7860,
1016
  debug=False,
1017
  ssl_verify=False,
1018
+ share=True)
1019
  else:
1020
  demo.queue(api_open=True, max_size=15).launch(share=False)
hls_download.py CHANGED
@@ -11,6 +11,7 @@ def download_clips(stream_url, out_dir, start_time, end_time, resize=True, use_6
11
  if resize: # resize and convert to 30 fps
12
  ffmpeg_cmd = [
13
  'ffmpeg',
 
14
  '-i', stream_url,
15
  '-c:v', 'libx264',
16
  '-crf', '23',
@@ -30,7 +31,7 @@ def download_clips(stream_url, out_dir, start_time, end_time, resize=True, use_6
30
  except subprocess.CalledProcessError as e:
31
  print(f"Error occurred: {e}")
32
  print(f"ffmpeg output: {e.output}")
33
- return None
34
  # else:
35
  # os.rename(tmp_file, output_file)
36
  print(f"Converted {output_file}")
 
11
  if resize: # resize and convert to 30 fps
12
  ffmpeg_cmd = [
13
  'ffmpeg',
14
+ #'-hwaccel', 'cuda',
15
  '-i', stream_url,
16
  '-c:v', 'libx264',
17
  '-crf', '23',
 
31
  except subprocess.CalledProcessError as e:
32
  print(f"Error occurred: {e}")
33
  print(f"ffmpeg output: {e.output}")
34
+ return output_file
35
  # else:
36
  # os.rename(tmp_file, output_file)
37
  print(f"Converted {output_file}")