Shortcuts

RandomResize

class mmcv.transforms.RandomResize(scale: Union[Tuple[int, int], Sequence[Tuple[int, int]]], ratio_range: Optional[Tuple[float, float]] = None, resize_type: str = 'Resize', **resize_kwargs)[源代码]

Random resize images & bbox & keypoints.

How to choose the target scale to resize the image will follow the rules below:

  • if scale is a sequence of tuple

\[target\_scale[0] \sim Uniform([scale[0][0], scale[1][0]])\]
\[target\_scale[1] \sim Uniform([scale[0][1], scale[1][1]])\]

Following the resize order of weight and height in cv2, scale[i][0] is for width, and scale[i][1] is for height.

  • if scale is a tuple

\[target\_scale[0] \sim Uniform([ratio\_range[0], ratio\_range[1]]) * scale[0]\]
\[target\_scale[1] \sim Uniform([ratio\_range[0], ratio\_range[1]]) * scale[1]\]

Following the resize order of weight and height in cv2, ratio_range[0] is for width, and ratio_range[1] is for height.

  • if keep_ratio is True, the minimum value of target_scale will be used to set the shorter side and the maximum value will be used to set the longer side.

  • if keep_ratio is False, the value of target_scale will be used to reisze the width and height accordingly.

Required Keys:

  • img

  • gt_bboxes

  • gt_seg_map

  • gt_keypoints

Modified Keys:

  • img

  • gt_bboxes

  • gt_seg_map

  • gt_keypoints

  • img_shape

Added Keys:

  • scale

  • scale_factor

  • keep_ratio

参数
  • scale (tuple or Sequence[tuple]) – Images scales for resizing. Defaults to None.

  • ratio_range (tuple[float], optional) – (min_ratio, max_ratio). Defaults to None.

  • resize_type (str) – The type of resize class to use. Defaults to “Resize”.

  • **resize_kwargs – Other keyword arguments for the resize_type.

注解

By defaults, the resize_type is “Resize”, if it’s not overwritten by your registry, it indicates the mmcv.Resize. And therefore, resize_kwargs accepts any keyword arguments of it, like keep_ratio, interpolation and so on.

If you want to use your custom resize class, the class should accept scale argument and have scale attribution which determines the resize shape.

transform(results: dict)dict[源代码]

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

参数

results (dict) – Result dict from loading pipeline.

返回

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

返回类型

dict

Read the Docs v: latest
Versions
latest
stable
2.x
v2.1.0
v2.0.1
v2.0.0
1.x
v1.7.1
v1.7.0
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.