(self, image: np.ndarray)
| 359 | return image |
| 360 | |
| 361 | def normalize_image(self, image: np.ndarray): |
| 362 | if self.normalize_on_gpu: |
| 363 | return image |
| 364 | if self.normalize == "openai": |
| 365 | image -= np.array(OPENAI_CLIP_MEAN, dtype=np.float32)[None, None, :] |
| 366 | image /= np.array(OPENAI_CLIP_STD, dtype=np.float32)[None, None, :] |
| 367 | elif self.normalize == "siglip": |
| 368 | image = np.asarray(-1.0, dtype=np.float32) + image * np.asarray(2.0, dtype=np.float32) |
| 369 | elif self.normalize == "dino": |
| 370 | image -= np.array([0.485, 0.456, 0.406], dtype=np.float32)[None, None, :] |
| 371 | image /= np.array([0.229, 0.224, 0.225], dtype=np.float32)[None, None, :] |
| 372 | else: |
| 373 | raise NotImplementedError(self.normalize) |
| 374 | return image |
| 375 | |
| 376 | def resize_image(self, image, output_size, is_training, rng): |
| 377 | if self.resize == "siglip": |
no outgoing calls
no test coverage detected