MCPcopy Create free account
hub / github.com/Netflix/void-model / temporal_padding

Function temporal_padding

videox_fun/utils/utils.py:282–319  ·  view source on GitHub ↗
(video, min_length=85, max_length=197, dim=2)

Source from the content-addressed store, hash-verified

280
281
282def temporal_padding(video, min_length=85, max_length=197, dim=2):
283 length = video.size(dim)
284
285 min_len = (length // 4) * 4 + 1
286 if min_len < length:
287 min_len += 4
288 if (min_len // 4) % 2 == 0:
289 min_len += 4
290 target_length = min(min_len, max_length)
291 target_length = max(min_length, target_length)
292
293 logger.debug(f'video size: {video.shape}')
294 if dim == 0:
295 video = video[:target_length]
296 elif dim == 1:
297 video = video[:, :target_length]
298 elif dim == 2:
299 video = video[:, :, :target_length]
300 elif dim == 3:
301 video = video[:, :, :, :target_length]
302 else:
303 raise NotImplementedError
304 logger.debug(f'making video length: {target_length}, padding length: {target_length - length}')
305 while video.size(dim) < target_length:
306 video_flipped = torch.flip(video, [dim])
307 video = torch.cat([video, video_flipped], dim=dim)
308 if dim == 0:
309 video = video[:target_length]
310 elif dim == 1:
311 video = video[:, :target_length]
312 elif dim == 2:
313 video = video[:, :, :target_length]
314 elif dim == 3:
315 video = video[:, :, :, :target_length]
316 else:
317 raise NotImplementedError
318 logger.debug(f'return video size: {video.shape}')
319 return video
320
321
322def get_video_mask_input(

Callers 3

get_video_mask_inputFunction · 0.85
get_videoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected