Spaces:
Sleeping
Sleeping
fix
Browse files- app.py +8 -2
- core/inference.py +1 -5
app.py
CHANGED
@@ -21,8 +21,14 @@ def fn(video: gr.Video):
|
|
21 |
print('Process video.')
|
22 |
output = f'Marked-{str(video)}'
|
23 |
clip = VideoFileClip(video)
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
process_frame = FrameProcessor(detector, classifier, id_to_name)
|
27 |
clip = clip.fl_image(process_frame)
|
28 |
clip.write_videofile(output, fps=clip.fps, audio_codec='aac', logger=None)
|
|
|
21 |
print('Process video.')
|
22 |
output = f'Marked-{str(video)}'
|
23 |
clip = VideoFileClip(video)
|
24 |
+
id_to_name = {
|
25 |
+
0: 'Flying',
|
26 |
+
1: 'Landing',
|
27 |
+
2: 'Other',
|
28 |
+
3: 'Straight Taxiing',
|
29 |
+
4: 'Takeoff',
|
30 |
+
5: 'Turning Maneuver',
|
31 |
+
}
|
32 |
process_frame = FrameProcessor(detector, classifier, id_to_name)
|
33 |
clip = clip.fl_image(process_frame)
|
34 |
clip.write_videofile(output, fps=clip.fps, audio_codec='aac', logger=None)
|
core/inference.py
CHANGED
@@ -15,10 +15,6 @@ def detect_object(detector, frame):
|
|
15 |
result = detector(frame, classes=4, verbose=False)[0]
|
16 |
classes = result.boxes.cls.numpy()
|
17 |
boxes = result.boxes.xyxy.numpy()
|
18 |
-
predictions = [
|
19 |
-
(result.names[classes[i]].capitalize(), boxes[i])
|
20 |
-
for i in range(len(classes))
|
21 |
-
]
|
22 |
detections = (
|
23 |
[result.names[i].capitalize() for i in classes],
|
24 |
boxes,
|
@@ -35,7 +31,7 @@ def classify_action(classifier, frames, id_to_name):
|
|
35 |
for (class_id, confidence) in enumerate(confidences):
|
36 |
other_class_id = 2
|
37 |
if confidence > 0.3 and class_id != other_class_id:
|
38 |
-
actions.append(f'{id_to_name[class_id]}: {
|
39 |
return actions
|
40 |
|
41 |
def draw_boxes(frame, detections, actions):
|
|
|
15 |
result = detector(frame, classes=4, verbose=False)[0]
|
16 |
classes = result.boxes.cls.numpy()
|
17 |
boxes = result.boxes.xyxy.numpy()
|
|
|
|
|
|
|
|
|
18 |
detections = (
|
19 |
[result.names[i].capitalize() for i in classes],
|
20 |
boxes,
|
|
|
31 |
for (class_id, confidence) in enumerate(confidences):
|
32 |
other_class_id = 2
|
33 |
if confidence > 0.3 and class_id != other_class_id:
|
34 |
+
actions.append(f'{id_to_name[class_id]}: {confidence:.2f}')
|
35 |
return actions
|
36 |
|
37 |
def draw_boxes(frame, detections, actions):
|