(self, results)
| 20 | assert self.crop_size is not None |
| 21 | |
| 22 | def __call__(self, results): |
| 23 | motion = results['motion'] |
| 24 | length = len(motion) |
| 25 | if length >= self.crop_size: |
| 26 | idx = random.randint(0, length - self.crop_size) |
| 27 | motion = motion[idx:idx + self.crop_size] |
| 28 | results['motion_length'] = self.crop_size |
| 29 | else: |
| 30 | padding_length = self.crop_size - length |
| 31 | D = motion.shape[1:] |
| 32 | padding_zeros = np.zeros((padding_length, *D), dtype=np.float32) |
| 33 | motion = np.concatenate([motion, padding_zeros], axis=0) |
| 34 | results['motion_length'] = length |
| 35 | assert len(motion) == self.crop_size |
| 36 | results['motion'] = motion |
| 37 | results['motion_shape'] = motion.shape |
| 38 | if length >= self.crop_size: |
| 39 | results['motion_mask'] = torch.ones(self.crop_size).numpy() |
| 40 | else: |
| 41 | results['motion_mask'] = torch.cat( |
| 42 | (torch.ones(length), |
| 43 | torch.zeros(self.crop_size - length))).numpy() |
| 44 | return results |
| 45 | |
| 46 | def __repr__(self): |
| 47 | repr_str = self.__class__.__name__ + f'(crop_size={self.crop_size})' |
nothing calls this directly
no outgoing calls
no test coverage detected