MCPcopy Create free account
hub / github.com/CompVis/zigma / UCFCenterCropVideo

Class UCFCenterCropVideo

datasets/video_utils.py:279–316  ·  view source on GitHub ↗

First scale to the specified size in equal proportion to the short edge, then center cropping

Source from the content-addressed store, hash-verified

277
278
279class UCFCenterCropVideo:
280 """
281 First scale to the specified size in equal proportion to the short edge,
282 then center cropping
283 """
284
285 def __init__(
286 self,
287 size,
288 interpolation_mode="bilinear",
289 ):
290 if isinstance(size, tuple):
291 if len(size) != 2:
292 raise ValueError(
293 f"size should be tuple (height, width), instead got {size}"
294 )
295 self.size = size
296 else:
297 self.size = (size, size)
298
299 self.interpolation_mode = interpolation_mode
300
301 def __call__(self, clip):
302 """
303 Args:
304 clip (torch.tensor): Video clip to be cropped. Size is (T, C, H, W)
305 Returns:
306 torch.tensor: scale resized / center cropped video clip.
307 size is (T, C, crop_size, crop_size)
308 """
309 clip_resize = resize_scale(
310 clip=clip, target_size=self.size, interpolation_mode=self.interpolation_mode
311 )
312 clip_center_crop = center_crop(clip_resize, self.size)
313 return clip_center_crop
314
315 def __repr__(self) -> str:
316 return f"{self.__class__.__name__}(size={self.size}, interpolation_mode={self.interpolation_mode}"
317
318
319class KineticsRandomCropResizeVideo:

Callers 1

get_transforms_videoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected