Spaces:
Runtime error
Runtime error
Ivan Felipe Rodriguez
commited on
Commit
•
d081c3f
1
Parent(s):
3161a87
skipping frames
Browse files- app.py +27 -24
- inference.py +1 -1
app.py
CHANGED
@@ -215,35 +215,38 @@ def process_video(input_video, out_fps = 'auto', skip_frames = 5):
|
|
215 |
|
216 |
frame = cv2.resize(frame, (int(width), int(height)))
|
217 |
print('starting Frame: ', cnt)
|
218 |
-
# flip frame vertically
|
219 |
-
display_frame, result = inference_frame_serial(frame)
|
220 |
-
|
221 |
-
#print(result)
|
222 |
-
top_pred = process_results_for_plot(predictions = result.numpy(),
|
223 |
-
classes = classes,
|
224 |
-
class_sizes = class_sizes_lower)
|
225 |
-
|
226 |
-
# add to last 5
|
227 |
-
last_5_shark_detected[drawn_count % 5] = int(top_pred['shark_n'] > 0)
|
228 |
-
last_5_human_detected[drawn_count % 5] = int(top_pred['human_n'] > 0)
|
229 |
-
last_5_dangerous_dist[drawn_count % 5] = int(top_pred['dangerous_dist'] > 0)
|
230 |
-
|
231 |
-
top_pred['shark_sighted'] = int(np.sum(last_5_shark_detected) > 3)
|
232 |
-
top_pred['human_sighted'] = int(np.sum(last_5_human_detected) > 3)
|
233 |
-
top_pred['dangerous_dist_confirmed'] = int(np.sum(last_5_dangerous_dist) > 3)
|
234 |
-
|
235 |
-
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
236 |
-
prediction_frame = cv2.cvtColor(display_frame, cv2.COLOR_BGR2RGB)
|
237 |
-
|
238 |
-
#
|
239 |
-
#video.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))
|
240 |
-
|
241 |
if cnt*skip_frames %2==0:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
prediction_frame = cv2.resize(prediction_frame, (int(width), int(height)))
|
243 |
frame = prediction_frame
|
|
|
244 |
|
245 |
#if top_pred['shark_sighted'] or top_pred['shark_suspected']:
|
246 |
-
|
247 |
|
248 |
|
249 |
frame = cv2.resize(frame, (int(width), int(height)))
|
|
|
215 |
|
216 |
frame = cv2.resize(frame, (int(width), int(height)))
|
217 |
print('starting Frame: ', cnt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
if cnt*skip_frames %2==0:
|
219 |
+
|
220 |
+
# flip frame vertically
|
221 |
+
display_frame, result = inference_frame_serial(frame)
|
222 |
+
|
223 |
+
#print(result)
|
224 |
+
top_pred = process_results_for_plot(predictions = result.numpy(),
|
225 |
+
classes = classes,
|
226 |
+
class_sizes = class_sizes_lower)
|
227 |
+
|
228 |
+
# add to last 5
|
229 |
+
last_5_shark_detected[drawn_count % 5] = int(top_pred['shark_n'] > 0)
|
230 |
+
last_5_human_detected[drawn_count % 5] = int(top_pred['human_n'] > 0)
|
231 |
+
last_5_dangerous_dist[drawn_count % 5] = int(top_pred['dangerous_dist'] > 0)
|
232 |
+
|
233 |
+
top_pred['shark_sighted'] = int(np.sum(last_5_shark_detected) > 3)
|
234 |
+
top_pred['human_sighted'] = int(np.sum(last_5_human_detected) > 3)
|
235 |
+
top_pred['dangerous_dist_confirmed'] = int(np.sum(last_5_dangerous_dist) > 3)
|
236 |
+
|
237 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
238 |
+
prediction_frame = cv2.cvtColor(display_frame, cv2.COLOR_BGR2RGB)
|
239 |
+
|
240 |
+
#
|
241 |
+
#video.write(cv2.cvtColor(frame, cv2.COLOR_RGB2BGR))
|
242 |
+
|
243 |
+
|
244 |
prediction_frame = cv2.resize(prediction_frame, (int(width), int(height)))
|
245 |
frame = prediction_frame
|
246 |
+
frame = draw_cockpit(frame, top_pred,cnt*skip_frames)
|
247 |
|
248 |
#if top_pred['shark_sighted'] or top_pred['shark_suspected']:
|
249 |
+
|
250 |
|
251 |
|
252 |
frame = cv2.resize(frame, (int(width), int(height)))
|
inference.py
CHANGED
@@ -44,7 +44,7 @@ classes = ['Beach',
|
|
44 |
'Sea cow',
|
45 |
'Stingray',
|
46 |
'Person',
|
47 |
-
'
|
48 |
'Surfer',
|
49 |
'Surfer',
|
50 |
'Fish',
|
|
|
44 |
'Sea cow',
|
45 |
'Stingray',
|
46 |
'Person',
|
47 |
+
'ocean',
|
48 |
'Surfer',
|
49 |
'Surfer',
|
50 |
'Fish',
|