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

Function read_mask_video_binary

videox_fun/utils/utils.py:270–279  ·  view source on GitHub ↗
(mask_path, sample_size, video_length, dilate_width=11)

Source from the content-addressed store, hash-verified

268
269
270def read_mask_video_binary(mask_path, sample_size, video_length, dilate_width=11):
271 video_mask = media.read_video(mask_path)[:video_length]
272 if len(video_mask.shape) == 4: # (t, h, w, c)
273 video_mask = video_mask[..., 0] # (t, h, w)
274 video_mask = torch.from_numpy(video_mask).unsqueeze(0) # (1, t, h, w)
275 video_mask = F.interpolate(video_mask.float(), sample_size, mode='area')
276 video_mask = torch.where(video_mask < 240, 0, 255).unsqueeze(0) # (1, 1, t, h, w)
277 if dilate_width > 0:
278 video_mask = dilate_video_mask(video_mask, width=dilate_width)
279 return video_mask
280
281
282def temporal_padding(video, min_length=85, max_length=197, dim=2):

Callers 1

get_video_mask_inputFunction · 0.85

Calls 1

dilate_video_maskFunction · 0.85

Tested by

no test coverage detected