Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update task-id and add description in docstring
  • Loading branch information
fmigneault committed Jan 18, 2021
commit b734b783681ba42ed9cbd62f0addadb18af225cb
8 changes: 4 additions & 4 deletions slowfast/visualization/async_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,15 @@ def draw_predictions(task, video_vis):
boxes,
keyframe_idx=keyframe_idx,
draw_range=draw_range,
task=task,
task_id=task.id,
)
else:
frames = video_vis.draw_clip_range(
frames,
preds,
keyframe_idx=keyframe_idx,
draw_range=draw_range,
task=task,
task_id=task.id,
)
del task

Expand Down Expand Up @@ -366,15 +366,15 @@ def log_predictions(task, video_vis):
boxes,
keyframe_idx=keyframe_idx,
draw_range=draw_range,
task=task,
task_id=task.id,
)
else:
frames = video_vis.draw_clip_range(
frames,
preds,
keyframe_idx=keyframe_idx,
draw_range=draw_range,
task=task,
task_id=task.id,
)
del task

Expand Down
1 change: 0 additions & 1 deletion slowfast/visualization/ava_demo_precomputed_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ def draw_video(self):
ground_truth=ground_truth,
draw_range=current_draw_range,
repeat_frame=repeat,
task=task,
)
# Store the current clip as buffer.
prev_buffer = clip
Expand Down
11 changes: 7 additions & 4 deletions slowfast/visualization/video_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def draw_clip_range(
keyframe_idx=None,
draw_range=None,
repeat_frame=1,
task=None,
task_id=None,
):
"""
Draw predicted labels or ground truth classes to clip. Draw bouding boxes to clip
Expand All @@ -539,6 +539,7 @@ def draw_clip_range(
draw_range (Optional[list[ints]): only draw frames in range [start_idx, end_idx] inclusively in the clip.
If None, draw on the entire clip.
repeat_frame (int): repeat each frame in draw_range for `repeat_frame` time for slow-motion effect.
task_id (int): reference index of the task where frames and predictions originated from.
"""
if draw_range is None:
draw_range = [0, len(frames) - 1]
Expand Down Expand Up @@ -681,7 +682,9 @@ def _get_thres_array(self, common_class_names=None):

class VideoLogger(VideoVisualizer):
"""
Core is identical to visualizer. Override draw method to only log.
Log predictions to file instead of drawing onto output video frames.

Core is identical to `VideoVisualizer`. Override draw method to log.
"""
def __init__(self, *_, **__):
super(VideoLogger, self).__init__(*_, **__)
Expand All @@ -697,9 +700,9 @@ def draw_clip_range(
keyframe_idx=None,
draw_range=None,
repeat_frame=1,
task=None,
task_id=None,
):
self.clip_index = task.id if task else self.clip_index + 1
self.clip_index = task_id or self.clip_index + 1
num_frames = len(frames)
start_frame = self.clip_index * num_frames
frame_range = [start_frame, start_frame + num_frames - 1]
Expand Down