MCPcopy Create free account
hub / github.com/allenai/molmo2 / normalize_image

Method normalize_image

olmo/preprocessing/image_preprocessor.py:361–374  ·  view source on GitHub ↗
(self, image: np.ndarray)

Source from the content-addressed store, hash-verified

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":

Callers 2

build_single_cropMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected