Shortcuts

SourceImagePad

class mmocr.datasets.transforms.SourceImagePad(target_scale, crop_ratio=0.1111111111111111)[source]

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

Parameters
  • 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 and target_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]) . If crop_ratio is a tuple, then crop_ratio[0] is for the width and crop_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.

Return type

None

transform(results)[source]

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.

Parameters

results (Dict) – Result dict containing the data to transform.

Returns

The transformed data.

Return type

(Dict)

Read the Docs v: dev-1.x
Versions
latest
stable
v1.0.1
v1.0.0
0.x
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.