Spaces:
Sleeping
Sleeping
Commit ·
c1d54ca
1
Parent(s): e10dca0
fix zero div error
Browse files
app.py
CHANGED
|
@@ -224,8 +224,10 @@ def inference(stream_url, start_time, end_time, count_only_api, api_key,
|
|
| 224 |
count_pred = count_pred / 2
|
| 225 |
marks_count_pred = marks_count_pred / 2
|
| 226 |
count = np.array(count) / 2
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
| 229 |
self_err = abs(count_pred - marks_count_pred)
|
| 230 |
self_pct_err = self_err / count_pred
|
| 231 |
total_confidence = confidence * (1 - self_pct_err)
|
|
@@ -393,7 +395,7 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
|
|
| 393 |
# ]
|
| 394 |
|
| 395 |
gr.Examples(examples=[
|
| 396 |
-
['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_DA6NyTCw/vod', '
|
| 397 |
#[os.path.join(os.path.dirname(__file__), "files", "train14.mp4")],
|
| 398 |
#[os.path.join(os.path.dirname(__file__), "files", "train_17.mp4")],
|
| 399 |
#[os.path.join(os.path.dirname(__file__), "files", "train13.mp4")],
|
|
|
|
| 224 |
count_pred = count_pred / 2
|
| 225 |
marks_count_pred = marks_count_pred / 2
|
| 226 |
count = np.array(count) / 2
|
| 227 |
+
try:
|
| 228 |
+
confidence = (np.mean(periodicity[periodicity > miss_threshold]) - miss_threshold) / (1 - miss_threshold)
|
| 229 |
+
except ZeroDivisionError:
|
| 230 |
+
confidence = 0
|
| 231 |
self_err = abs(count_pred - marks_count_pred)
|
| 232 |
self_pct_err = self_err / count_pred
|
| 233 |
total_confidence = confidence * (1 - self_pct_err)
|
|
|
|
| 395 |
# ]
|
| 396 |
|
| 397 |
gr.Examples(examples=[
|
| 398 |
+
['https://hiemdall-dev2.azurewebsites.net/api/playlist/rec_DA6NyTCw/vod', '336', '366'],
|
| 399 |
#[os.path.join(os.path.dirname(__file__), "files", "train14.mp4")],
|
| 400 |
#[os.path.join(os.path.dirname(__file__), "files", "train_17.mp4")],
|
| 401 |
#[os.path.join(os.path.dirname(__file__), "files", "train13.mp4")],
|