Shortcuts

Resize

class mmpretrain.datasets.transforms.Resize(scale=None, scale_factor=None, keep_ratio=False, clip_object_border=True, backend='cv2', interpolation='bilinear')[source]

Resize images & bbox & seg & keypoints.

This transform resizes the input image according to scale or scale_factor. Bboxes, seg map and keypoints are then resized with the same scale factor. if scale and scale_factor are both set, it will use scale to resize.

Required Keys:

  • img

  • gt_bboxes (optional)

  • gt_seg_map (optional)

  • gt_keypoints (optional)

Modified Keys:

  • img

  • gt_bboxes

  • gt_seg_map

  • gt_keypoints

  • img_shape

Added Keys:

  • scale

  • scale_factor

  • keep_ratio

Parameters:
  • scale (int or tuple) – Images scales for resizing. Defaults to None

  • scale_factor (float or tuple[float]) – Scale factors for resizing. Defaults to None.

  • keep_ratio (bool) – Whether to keep the aspect ratio when resizing the image. Defaults to False.

  • clip_object_border (bool) – Whether to clip the objects outside the border of the image. In some dataset like MOT17, the gt bboxes are allowed to cross the border of images. Therefore, we don’t need to clip the gt bboxes in these cases. Defaults to True.

  • backend (str) – Image resize backend, choices are ‘cv2’ and ‘pillow’. These two backends generates slightly different results. Defaults to ‘cv2’.

  • interpolation (str) – Interpolation method, accepted values are “nearest”, “bilinear”, “bicubic”, “area”, “lanczos” for ‘cv2’ backend, “nearest”, “bilinear” for ‘pillow’ backend. Defaults to ‘bilinear’.

transform(results)[source]

Transform function to resize images, bounding boxes, semantic segmentation map and keypoints.

Parameters:

results (dict) – Result dict from loading pipeline.

Returns:

Resized results, ‘img’, ‘gt_bboxes’, ‘gt_seg_map’, ‘gt_keypoints’, ‘scale’, ‘scale_factor’, ‘img_shape’, and ‘keep_ratio’ keys are updated in result dict.

Return type:

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.