dylanplummer commited on
Commit
964d3b7
·
1 Parent(s): 4505013

add results table

Browse files
Files changed (1) hide show
  1. app.py +24 -22
app.py CHANGED
@@ -501,18 +501,25 @@ def inference(in_video, use_60fps,
501
  else: # end of event
502
  pass
503
  print(f"Recovery times: {recovery_times}")
504
-
 
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:
@@ -599,8 +606,7 @@ def inference(in_video, use_60fps,
599
  # plt.close()
600
 
601
 
602
- jumps_per_second = np.clip(1 / ((periodLength / fps) + 0.0001), 0, 10)
603
- jumping_speed = np.copy(jumps_per_second)
604
  misses = periodicity < miss_threshold
605
  jumps_per_second[misses] = 0
606
  frame_type = np.array(['miss' if miss else 'frame' for miss in misses])
@@ -624,13 +630,11 @@ def inference(in_video, use_60fps,
624
  fig = px.scatter(data_frame=df,
625
  x='seconds',
626
  y='jumps per second',
627
- #symbol='frame_type',
628
- #symbol_map={'frame': 'circle', 'miss': 'circle-open', 'jump': 'triangle-down'},
629
- color='event_type',
630
  size='jumps_size',
631
  size_max=8,
632
- color_continuous_scale=[(t, c) for t, c in zip(event_type_tick_vals, event_type_colors)],
633
- range_color=(0,1),
634
  title="Jumping speed (jumps-per-second)",
635
  trendline='rolling',
636
  trendline_options=dict(window=16),
@@ -662,9 +666,7 @@ def inference(in_video, use_60fps,
662
  # remove white outline from marks
663
  fig.update_traces(marker_line_width = 0)
664
  fig.update_layout(coloraxis_colorbar=dict(
665
- tickvals=event_type_tick_vals,
666
- ticktext=['single<br>rope', 'double<br>dutch', 'double<br>unders', 'single<br>bounces', 'double<br>bounces', 'triple<br>unders', 'other'],
667
- title='event type'
668
  ))
669
 
670
 
@@ -812,7 +814,7 @@ with gr.Blocks() as demo:
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],
 
501
  else: # end of event
502
  pass
503
  print(f"Recovery times: {recovery_times}")
504
+ jumps_per_second = np.clip(1 / ((periodLength / fps) + 0.0001), 0, 10)
505
+ jumping_speed = np.copy(jumps_per_second)
506
 
507
+ foot_label = "both feet" if both_feet else "one foot"
508
+ count_msg = f"## 🏅 Results ({foot_label}: {count_pred:.1f})\n\n"
509
+ count_msg += f"| Metric | Value |\n|---|---|\n"
510
+ count_msg += f"| **Count** | {count_pred:.1f} |\n"
511
+ count_msg += f"| **Confidence** | {total_confidence:.2f} |\n"
512
+ count_msg += f"| **Fastest Speed** | {fastest_jumps_per_second:.2f} jumps/sec |\n"
513
+ count_msg += f"| **Average Speed** | {np.mean(jumps_per_second[periodicity_mask]):.2f} jumps/sec |\n"
514
+ count_msg += f"| **Slowest Speed** | {lowest_jps:.2f} jumps/sec |\n"
515
+ count_msg += f"| **Slowdown** | {abs(slowdown):.2f} jumps/sec ({abs(slowdown_percent):.1f}%) |\n"
516
+ if num_misses > 0:
517
+ count_msg += f"| **Misses** | {num_misses} |\n"
518
+ if recovery_times:
519
+ avg_recovery = sum(recovery_times) / len(recovery_times)
520
+ count_msg += f"| **Avg Recovery Time** | {avg_recovery:.2f}s |\n"
521
+ if beep_detection_on and time_to_speed > 0:
522
+ count_msg += f"| **Time to Speed** | {time_to_speed:.2f}s |\n"
523
 
524
  if api_call:
525
  if CACHE_API_CALLS:
 
606
  # plt.close()
607
 
608
 
609
+
 
610
  misses = periodicity < miss_threshold
611
  jumps_per_second[misses] = 0
612
  frame_type = np.array(['miss' if miss else 'frame' for miss in misses])
 
630
  fig = px.scatter(data_frame=df,
631
  x='seconds',
632
  y='jumps per second',
633
+ color='jumping speed',
 
 
634
  size='jumps_size',
635
  size_max=8,
636
+ color_continuous_scale='Turbo',
637
+ range_color=(0, 10),
638
  title="Jumping speed (jumps-per-second)",
639
  trendline='rolling',
640
  trendline_options=dict(window=16),
 
666
  # remove white outline from marks
667
  fig.update_traces(marker_line_width = 0)
668
  fig.update_layout(coloraxis_colorbar=dict(
669
+ title='jumps/sec'
 
 
670
  ))
671
 
672
 
 
814
  api_dummy_button.click(api_inference, [in_video, use_60fps, beep_detection_on, event_length, count_only, api_token],
815
  outputs=[period_length], api_name='inference')
816
  examples = [
817
+ ['files/wc2023.mp4', False, True, 30, 0.5, 0.5],
818
  ]
819
  gr.Examples(examples,
820
  inputs=[in_video, use_60fps, beep_detection_on, event_length, miss_threshold, marks_threshold],