(self, im)
| 807 | self.min_bound, self.max_bound = min_max[0], min_max[1] |
| 808 | |
| 809 | def __call__(self, im): |
| 810 | if isinstance(im, np.ndarray): |
| 811 | return np.clip(im, a_min=self.min_bound, a_max=self.max_bound) |
| 812 | elif isinstance(im, torch.Tensor): |
| 813 | return torch.clamp(im, min=self.min_bound, max=self.max_bound) |
| 814 | else: |
| 815 | raise TypeError(f'ndarray or Tensor expected, got {type(im)}') |
| 816 | |
| 817 | if __name__ == '__main__': |
| 818 | im = np.random.randn(64, 64, 3).astype(np.float32) |
nothing calls this directly
no outgoing calls
no test coverage detected