MCPcopy Create free account
hub / github.com/IceClear/StableSR / __call__

Method __call__

scripts/util_image.py:809–815  ·  view source on GitHub ↗
(self, im)

Source from the content-addressed store, hash-verified

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
817if __name__ == '__main__':
818 im = np.random.randn(64, 64, 3).astype(np.float32)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected