mindformers.models.clip.CLIPImageProcessor

class mindformers.models.clip.CLIPImageProcessor(image_resolution: Optional[int] = 224)[源代码]

CLIPImageProcessor.

参数

image_resolution (int) – The target size.

实际案例

>>> from mindformers import CLIPImageProcessor
>>> from mindformers.tools.image_tools import load_image
>>> processor = CLIPImageProcessor(image_resolution=256)
>>> image = load_image("https://ascend-repo-modelzoo.obs.cn-east-2."
...                    "myhuaweicloud.com/XFormer_for_mindspore/clip/sunflower.png")
>>> processor(image)
    Tensor(shape=[1, 3, 256, 256], dtype=Float32, value=
    [[[[-1.52949083e+000, -1.52949083e+000, ... -1.48569560e+000, -1.50029397e+000],
    [-1.52949083e+000, -1.52949083e+000, ... -1.50029397e+000, -1.50029397e+000],
    [-1.51489246e+000, -1.51489246e+000, ... -1.48569560e+000, -1.48569560e+000],
    ...
    ...
    [8.66091192e-001, 8.80311251e-001, ... -1.36645925e+000, -1.45177972e+000],
    [8.09210956e-001, 8.23431015e-001, ... -1.29535890e+000, -1.43755960e+000],
    [7.09670484e-001, 7.94990897e-001, ... -1.26691878e+000, -1.42333949e+000]]]])
preprocess(images: Union[mindspore.common.tensor.Tensor, PIL.Image.Image, numpy.ndarray, List[PIL.Image.Image]], **kwargs)[源代码]

Preprocess Required By Base Processor.

参数

images (ms.Tensor, PIL.Image, numpy.array, List[PIL.Image]) – A batch of images.

返回

A 4-rank tensor for a batch of images.