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

Class TemporalRandomCrop

datasets/video_utils.py:453–467  ·  view source on GitHub ↗

Temporally crop the given frame indices at a random location. Args: size (int): Desired length of frames will be seen in the model.

Source from the content-addressed store, hash-verified

451# --------------------- Sampling ---------------------------
452# ------------------------------------------------------------
453class TemporalRandomCrop(object):
454 """Temporally crop the given frame indices at a random location.
455
456 Args:
457 size (int): Desired length of frames will be seen in the model.
458 """
459
460 def __init__(self, size):
461 self.size = size
462
463 def __call__(self, total_frames):
464 rand_end = max(0, total_frames - self.size - 1)
465 begin_index = random.randint(0, rand_end)
466 end_index = min(begin_index + self.size, total_frames)
467 return begin_index, end_index
468
469
470class DatasetFromCSV(torch.utils.data.Dataset):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected