Shortcuts

RandomResizedCrop

class mmpretrain.datasets.transforms.RandomResizedCrop(scale, crop_ratio_range=(0.08, 1.0), aspect_ratio_range=(0.75, 1.3333333333333333), max_attempts=10, interpolation='bilinear', backend='cv2')[源代码]

将给定图像按照随机尺寸和纵横比进行裁剪

A crop of random size (default: of 0.08 to 1.0) of the original size and a random aspect ratio (default: of 3/4 to 4/3) of the original aspect ratio is made. This crop is finally resized to given size.

Required Keys:

  • img

Modified Keys:

  • img

  • img_shape

参数:
  • scale (sequence | int) – Desired output scale of the crop. If size is an int instead of sequence like (h, w), a square crop (size, size) is made.

  • crop_ratio_range (tuple) – Range of the random size of the cropped image compared to the original image. Defaults to (0.08, 1.0).

  • aspect_ratio_range (tuple) – Range of the random aspect ratio of the cropped image compared to the original image. Defaults to (3. / 4., 4. / 3.).

  • max_attempts (int) – Maximum number of attempts before falling back to Central Crop. Defaults to 10.

  • interpolation (str) – Interpolation method, accepted values are ‘nearest’, ‘bilinear’, ‘bicubic’, ‘area’, ‘lanczos’. Defaults to ‘bilinear’.

  • backend (str) – The image resize backend type, accepted values are ‘cv2’ and ‘pillow’. Defaults to ‘cv2’.

transform(results)[源代码]

Transform function to randomly resized crop images.

参数:

results (dict) – Result dict from loading pipeline.

返回:

Randomly resized cropped results, ‘img_shape’

key in result dict is updated according to crop size.

返回类型:

dict

Read the Docs v: latest
Versions
latest
stable
mmcls-1.x
mmcls-0.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.