SourceImagePad¶
- class mmocr.datasets.transforms.SourceImagePad(target_scale, crop_ratio=0.1111111111111111)[源代码]¶
Pad Image to target size. It will randomly crop an area from the original image and resize it to the target size, then paste the original image to its top left corner.
Required Keys:
img
Modified Keys:
img
img_shape
Added Keys: - pad_shape - pad_fixed_size
- 参数
target_scale (int or tuple[int, int]]) – The target size of padded image. If it’s an integer, then the padding size would be (target_size, target_size). If it’s tuple, then
target_scale[0]
should be the width andtarget_scale[1]
should be the height. The size of the padded image will be (target_scale[1], target_scale[0])crop_ratio (float or Tuple[float, float]) – Relative size for the crop region. If
crop_ratio
is a float, then the initial crop size would be(crop_ratio * img.shape[0], crop_ratio * img.shape[1])
. Ifcrop_ratio
is a tuple, thencrop_ratio[0]
is for the width andcrop_ratio[1]
is for the height. The initial crop size would be(crop_ratio[1] * img.shape[0], crop_ratio[0] * img.shape[1])
. Defaults to 1./9.
- 返回类型
- transform(results)[源代码]¶
Pad Image to target size. It will randomly select a small area from the original image and resize it to the target size, then paste the original image to its top left corner.
- 参数
results (Dict) – Result dict containing the data to transform.
- 返回
The transformed data.
- 返回类型
(Dict)