sima_utils.transformer.vision_preprocessor ========================================== .. py:module:: sima_utils.transformer.vision_preprocessor Attributes ---------- .. autoapisummary:: sima_utils.transformer.vision_preprocessor.PILImageResampling sima_utils.transformer.vision_preprocessor.IMAGE_RGB_STATS sima_utils.transformer.vision_preprocessor.vm_type Classes ------- .. autoapisummary:: sima_utils.transformer.vision_preprocessor.ImageProcessor Module Contents --------------- .. py:data:: PILImageResampling .. py:data:: IMAGE_RGB_STATS .. py:class:: ImageProcessor(model_type: str, target_size: int) Image processor for CLIP and SigLIP vision model. .. attribute:: model_type The type of vision model, "clip" or "siglip". .. attribute:: image_size The target image size for the vision model. .. attribute:: keep_aspect If true, keep aspect ratio by squaring before resize. .. attribute:: image_mean The mean of RGB images used in model training. .. attribute:: image_std The std-dev of RGB images used in model training. .. attribute:: resample The method of resampling used to resize an image. .. py:attribute:: model_type :type: str .. py:attribute:: image_size :type: tuple[int, int] .. py:attribute:: keep_aspect :type: bool .. py:attribute:: image_mean :type: list[float] .. py:attribute:: image_std :type: list[float] .. py:attribute:: resample :type: PILImageResampling .. py:method:: load_image_from_file(image_files: list[str]) .. py:method:: expand2square(pil_img: PIL.Image.Image) .. py:method:: preprocess(images: list[PIL.Image.Image], channel_first: bool = True) -> list[numpy.ndarray] Preprocess a list of images as input to a vision model. :param images: A list of RGB images. :param channel_first: A flag to output CHW if true, or HWC if false. :returns: A list of processed images as numpy arrays. .. py:data:: vm_type