Spaces:
Sleeping
Sleeping
Tidy
Browse files- app.py +9 -10
- configuration.py +1 -1
- inference.py +1 -1
app.py
CHANGED
@@ -35,21 +35,20 @@ def fn(video: gr.Video, actions: list[int]):
|
|
35 |
actions = []
|
36 |
detections = ([], [])
|
37 |
for i, frame in enumerate(clip.iter_frames()):
|
38 |
-
if
|
39 |
-
if
|
40 |
frames.append(format_frame(frame, config))
|
41 |
-
|
42 |
-
|
43 |
-
if do_detect:
|
44 |
-
detections = detect_object(detector, frame)
|
45 |
-
if len(frames) == config.classify_action_num_frames:
|
46 |
-
print(f'Classify action: Until frame {i}')
|
47 |
-
if do_classify:
|
48 |
actions = classify_action(classifier, frames, config.id_to_name)
|
49 |
frames = []
|
|
|
|
|
|
|
|
|
50 |
if do_detect:
|
51 |
frame = draw_boxes(frame, detections, actions, do_classify)
|
52 |
-
|
53 |
frame = draw_classes(frame, actions)
|
54 |
processed_frames.append(frame)
|
55 |
if i % config.yield_frame_steps == 0:
|
|
|
35 |
actions = []
|
36 |
detections = ([], [])
|
37 |
for i, frame in enumerate(clip.iter_frames()):
|
38 |
+
if do_classify:
|
39 |
+
if i % config.classify_action_frame_step == 0:
|
40 |
frames.append(format_frame(frame, config))
|
41 |
+
if len(frames) == config.classify_action_num_frames:
|
42 |
+
print(f'Classify action: Until frame {i}')
|
|
|
|
|
|
|
|
|
|
|
43 |
actions = classify_action(classifier, frames, config.id_to_name)
|
44 |
frames = []
|
45 |
+
if do_detect:
|
46 |
+
if i % config.detect_object_frame_step == 0:
|
47 |
+
print(f'Detect object: Frame {i}')
|
48 |
+
detections = detect_object(detector, frame)
|
49 |
if do_detect:
|
50 |
frame = draw_boxes(frame, detections, actions, do_classify)
|
51 |
+
elif len(actions) > 0:
|
52 |
frame = draw_classes(frame, actions)
|
53 |
processed_frames.append(frame)
|
54 |
if i % config.yield_frame_steps == 0:
|
configuration.py
CHANGED
@@ -29,4 +29,4 @@ class Config:
|
|
29 |
detect_object_frame_step = 5
|
30 |
classify_action_frame_step = frame_step
|
31 |
classify_action_num_frames = num_frames
|
32 |
-
yield_frame_steps =
|
|
|
29 |
detect_object_frame_step = 5
|
30 |
classify_action_frame_step = frame_step
|
31 |
classify_action_num_frames = num_frames
|
32 |
+
yield_frame_steps = 2
|
inference.py
CHANGED
@@ -67,7 +67,7 @@ def draw_boxes(frame, detections, actions, do_classify):
|
|
67 |
def draw_classes(frame, actions):
|
68 |
height, width, _ = frame.shape
|
69 |
labels = np.zeros((height, width), dtype=int)
|
70 |
-
label_names = ['
|
71 |
frame = label2rgb(
|
72 |
label=labels,
|
73 |
image=frame,
|
|
|
67 |
def draw_classes(frame, actions):
|
68 |
height, width, _ = frame.shape
|
69 |
labels = np.zeros((height, width), dtype=int)
|
70 |
+
label_names = ['\n'.join(actions)]
|
71 |
frame = label2rgb(
|
72 |
label=labels,
|
73 |
image=frame,
|