@@ -52,10 +52,33 @@ def resize_video_frames(images, size):
52
52
return resized_images
53
53
54
54
55
+ def create_border (video , color = "blue" , border_percent = 2 ):
56
+ """Creates a border around each frame to differentiate input and target.
57
+
58
+ Args:
59
+ video: 5-D NumPy array.
60
+ color: string, "blue", "red" or "green".
61
+ border_percent: Percentarge of the frame covered by the border.
62
+ Returns:
63
+ video: 5-D NumPy array.
64
+ """
65
+ color_to_axis = {"blue" : 2 , "red" : 0 , "green" : 1 }
66
+ axis = color_to_axis [color ]
67
+ _ , _ , height , width , _ = video .shape
68
+ border_height = np .ceil (border_percent * height / 100.0 ).astype (np .int )
69
+ border_width = np .ceil (border_percent * width / 100.0 ).astype (np .int )
70
+ video [:, :, :border_height , :, axis ] = 255
71
+ video [:, :, - border_height :, :, axis ] = 255
72
+ video [:, :, :, :border_width , axis ] = 255
73
+ video [:, :, :, - border_width :, axis ] = 255
74
+ return video
75
+
76
+
55
77
def display_video_hooks (hook_args ):
56
78
"""Hooks to display videos at decode time."""
57
79
predictions = hook_args .predictions
58
80
fps = hook_args .decode_hparams .frames_per_second
81
+ border_percent = hook_args .decode_hparams .border_percent
59
82
60
83
all_summaries = []
61
84
for decode_ind , decode in enumerate (predictions ):
@@ -67,9 +90,17 @@ def display_video_hooks(hook_args):
67
90
output_videos = np .asarray (output_videos , dtype = np .uint8 )
68
91
input_videos = np .asarray (input_videos , dtype = np .uint8 )
69
92
93
+ input_videos = create_border (
94
+ input_videos , color = "blue" , border_percent = border_percent )
95
+ target_videos = create_border (
96
+ target_videos , color = "red" , border_percent = border_percent )
97
+ output_videos = create_border (
98
+ output_videos , color = "red" , border_percent = border_percent )
99
+
70
100
# Video gif.
71
101
all_input = np .concatenate ((input_videos , target_videos ), axis = 1 )
72
102
all_output = np .concatenate ((input_videos , output_videos ), axis = 1 )
103
+
73
104
input_summ_vals , _ = common_video .py_gif_summary (
74
105
"decode_%d/input" % decode_ind ,
75
106
all_input , max_outputs = 10 ,
0 commit comments