(self, image)
| 313 | self.image_prompt_token_id = special_tokens[tokenizer.IMAGE_PROMPT] |
| 314 | |
| 315 | def _normalize(self, image): |
| 316 | if self.normalize == "openai": |
| 317 | image -= np.array(OPENAI_CLIP_MEAN, dtype=np.float32)[None, None, :] |
| 318 | image /= np.array(OPENAI_CLIP_STD, dtype=np.float32)[None, None, :] |
| 319 | elif self.normalize == "siglip": |
| 320 | image = np.asarray(-1.0, dtype=np.float32) + image * np.asarray(2.0, dtype=np.float32) |
| 321 | elif self.normalize == "dino": |
| 322 | image -= np.array([0.485, 0.456, 0.406], dtype=np.float32)[None, None, :] |
| 323 | image /= np.array([0.229, 0.224, 0.225], dtype=np.float32)[None, None, :] |
| 324 | else: |
| 325 | raise NotImplementedError(self.normalize) |
| 326 | return image |
| 327 | |
| 328 | def resize_image(self, image, output_size, is_training, rng): |
| 329 | if self.resize == "siglip": |
no outgoing calls
no test coverage detected