CenterCrop

class paddle.vision.transforms. CenterCrop ( size, keys=None ) [source]

Crops the given the input data at the center.

Parameters
  • size (int|list|tuple) – Target size of output image, with (height, width) shape.

  • keys (list[str]|tuple[str], optional) – Same as BaseTransform. Default: None.

Examples

import numpy as np
from PIL import Image
from paddle.vision.transforms import CenterCrop

transform = CenterCrop(224)

fake_img = Image.fromarray((np.random.rand(300, 320, 3) * 255.).astype(np.uint8))

fake_img = transform(fake_img)
print(fake_img.size)