Update app.py
Browse files
app.py
CHANGED
|
@@ -363,7 +363,6 @@ def inference(in_video, stream_url, start_time, end_time, beep_detection_on, eve
|
|
| 363 |
period_length_overlaps[idx:idx+seq_len] += 1
|
| 364 |
event_type_logit_overlaps[idx:idx+seq_len] += 1
|
| 365 |
del y1_out, y2_out, y3_out, y4_out # free up memory
|
| 366 |
-
del y1_out, y2_out, y3_out, y4_out # free up memory
|
| 367 |
|
| 368 |
periodLength = np.divide(period_lengths, period_length_overlaps, where=period_length_overlaps!=0)[:length]
|
| 369 |
periodicity = np.divide(periodicities, period_length_overlaps, where=period_length_overlaps!=0)[:length]
|
|
@@ -424,11 +423,6 @@ def inference(in_video, stream_url, start_time, end_time, beep_detection_on, eve
|
|
| 424 |
confidence = 0
|
| 425 |
else:
|
| 426 |
confidence = (np.mean(periodicity[periodicity > miss_threshold]) - miss_threshold) / (1 - miss_threshold)
|
| 427 |
-
periodicity_mask = periodicity > miss_threshold
|
| 428 |
-
if np.sum(periodicity_mask) == 0:
|
| 429 |
-
confidence = 0
|
| 430 |
-
else:
|
| 431 |
-
confidence = (np.mean(periodicity[periodicity > miss_threshold]) - miss_threshold) / (1 - miss_threshold)
|
| 432 |
except ZeroDivisionError:
|
| 433 |
confidence = 0
|
| 434 |
self_err = abs(count_pred - marks_count_pred)
|
|
@@ -442,16 +436,8 @@ def inference(in_video, stream_url, start_time, end_time, beep_detection_on, eve
|
|
| 442 |
count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Marks Count (both feet): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
|
| 443 |
else:
|
| 444 |
count_msg = f"## Reps Count (one foot): {count_pred:.1f}, Marks Count (one foot): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
|
| 445 |
-
count_msg = f"## Reps Count (one foot): {count_pred:.1f}, Marks Count (one foot): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
|
| 446 |
|
| 447 |
if api_call:
|
| 448 |
-
if CACHE_API_CALLS:
|
| 449 |
-
# write outputs as row of csv
|
| 450 |
-
with open('api_calls.tsv', 'a') as f:
|
| 451 |
-
periodicity_str = np.array2string(periodicity, formatter={'float_kind':lambda x: "%.2f" % x}, threshold=np.inf).replace('\n', '')
|
| 452 |
-
periodLength_str = np.array2string(periodLength, formatter={'float_kind':lambda x: "%.2f" % x}, threshold=np.inf).replace('\n', '')
|
| 453 |
-
full_marks_str = np.array2string(full_marks, formatter={'float_kind':lambda x: "%.2f" % x}, threshold=np.inf).replace('\n', '')
|
| 454 |
-
f.write(f"{stream_url}\t{start_time}\t{end_time}\t{beep_detection_on}\t{event_length}\t{periodicity_str}\t{periodLength_str}\t{full_marks_str}\t{count_pred}\t{total_confidence}\n")
|
| 455 |
if CACHE_API_CALLS:
|
| 456 |
# write outputs as row of csv
|
| 457 |
with open('api_calls.tsv', 'a') as f:
|
|
@@ -561,11 +547,6 @@ def inference(in_video, stream_url, start_time, end_time, beep_detection_on, eve
|
|
| 561 |
except FileNotFoundError:
|
| 562 |
pass
|
| 563 |
|
| 564 |
-
try:
|
| 565 |
-
os.remove('temp.wav')
|
| 566 |
-
except FileNotFoundError:
|
| 567 |
-
pass
|
| 568 |
-
|
| 569 |
return in_video, count_msg, fig, hist, bar
|
| 570 |
|
| 571 |
|
|
@@ -622,7 +603,6 @@ with gr.Blocks() as demo:
|
|
| 622 |
examples = [
|
| 623 |
#['https://hiemdall-dev2.azurewebsites.net/api/clip/clp_vrpWTyjM/mp4', '00:00:00', '00:01:10', True, 60],
|
| 624 |
[None, 'https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_UGEhqlMh/vod', '00:00:18', '00:00:55', True, 30],
|
| 625 |
-
[None, 'https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_UGEhqlMh/vod', '00:00:18', '00:00:55', True, 30],
|
| 626 |
#['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_rd2FAyUo/vod', '01:24:22', '01:25:35', True, 60]
|
| 627 |
#['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_PY5Ukaua/vod, '00:52:53', '00:55:00', True, 120]
|
| 628 |
]
|
|
|
|
| 363 |
period_length_overlaps[idx:idx+seq_len] += 1
|
| 364 |
event_type_logit_overlaps[idx:idx+seq_len] += 1
|
| 365 |
del y1_out, y2_out, y3_out, y4_out # free up memory
|
|
|
|
| 366 |
|
| 367 |
periodLength = np.divide(period_lengths, period_length_overlaps, where=period_length_overlaps!=0)[:length]
|
| 368 |
periodicity = np.divide(periodicities, period_length_overlaps, where=period_length_overlaps!=0)[:length]
|
|
|
|
| 423 |
confidence = 0
|
| 424 |
else:
|
| 425 |
confidence = (np.mean(periodicity[periodicity > miss_threshold]) - miss_threshold) / (1 - miss_threshold)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
except ZeroDivisionError:
|
| 427 |
confidence = 0
|
| 428 |
self_err = abs(count_pred - marks_count_pred)
|
|
|
|
| 436 |
count_msg = f"## Reps Count (both feet): {count_pred:.1f}, Marks Count (both feet): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
|
| 437 |
else:
|
| 438 |
count_msg = f"## Reps Count (one foot): {count_pred:.1f}, Marks Count (one foot): {marks_count_pred:.1f}, Confidence: {total_confidence:.2f}"
|
|
|
|
| 439 |
|
| 440 |
if api_call:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
if CACHE_API_CALLS:
|
| 442 |
# write outputs as row of csv
|
| 443 |
with open('api_calls.tsv', 'a') as f:
|
|
|
|
| 547 |
except FileNotFoundError:
|
| 548 |
pass
|
| 549 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
return in_video, count_msg, fig, hist, bar
|
| 551 |
|
| 552 |
|
|
|
|
| 603 |
examples = [
|
| 604 |
#['https://hiemdall-dev2.azurewebsites.net/api/clip/clp_vrpWTyjM/mp4', '00:00:00', '00:01:10', True, 60],
|
| 605 |
[None, 'https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_UGEhqlMh/vod', '00:00:18', '00:00:55', True, 30],
|
|
|
|
| 606 |
#['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_rd2FAyUo/vod', '01:24:22', '01:25:35', True, 60]
|
| 607 |
#['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_PY5Ukaua/vod, '00:52:53', '00:55:00', True, 120]
|
| 608 |
]
|