Shortcuts

Pad

class mmcv.transforms.Pad(size: Optional[Tuple[int, int]] = None, size_divisor: Optional[int] = None, pad_to_square: bool = False, pad_val: Union[int, float, dict] = {'img': 0, 'seg': 255}, padding_mode: str = 'constant')[源代码]

Pad the image & segmentation map.

There are three padding modes: (1) pad to a fixed size and (2) pad to the minimum size that is divisible by some number. and (3)pad to square. Also, pad to square and pad to the minimum size can be used as the same time.

Required Keys:

  • img

  • gt_bboxes (optional)

  • gt_seg_map (optional)

Modified Keys:

  • img

  • gt_seg_map

  • img_shape

Added Keys:

  • pad_shape

  • pad_fixed_size

  • pad_size_divisor

参数
  • size (tuple, optional) – Fixed padding size. Expected padding shape (w, h). Defaults to None.

  • size_divisor (int, optional) – The divisor of padded size. Defaults to None.

  • pad_to_square (bool) – Whether to pad the image into a square. Currently only used for YOLOX. Defaults to False.

  • pad_val (Number | dict[str, Number], optional) –

    Padding value for if the pad_mode is “constant”. If it is a single number, the value to pad the image is the number and to pad the semantic segmentation map is 255. If it is a dict, it should have the following keys:

    • img: The value to pad the image.

    • seg: The value to pad the semantic segmentation map.

    Defaults to dict(img=0, seg=255).

  • padding_mode (str) –

    Type of padding. Should be: constant, edge, reflect or symmetric. Defaults to ‘constant’.

    • constant: pads with a constant value, this value is specified with pad_val.

    • edge: pads with the last value at the edge of the image.

    • reflect: pads with reflection of image without repeating the last value on the edge. For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode will result in [3, 2, 1, 2, 3, 4, 3, 2].

    • symmetric: pads with reflection of image repeating the last value on the edge. For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode will result in [2, 1, 1, 2, 3, 4, 4, 3]

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

Call function to pad images, masks, semantic segmentation maps.

参数

results (dict) – Result dict from loading pipeline.

返回

Updated result dict.

返回类型

dict

Read the Docs v: 2.x
Versions
latest
stable
2.x
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.