Class RandomResizedCropWithBBox

Inheritance Relationships

Base Type

Class Documentation

class RandomResizedCropWithBBox : public mindspore::dataset::TensorTransform

Crop the input image to a random size and aspect ratio. If cropped area is out of bbox, the return bbox will be empty.

Public Functions

explicit RandomResizedCropWithBBox(const std::vector<int32_t> &size, const std::vector<float> &scale = {0.08, 1.0}, const std::vector<float> &ratio = {3. / 4., 4. / 3.}, InterpolationMode interpolation = InterpolationMode::kLinear, int32_t max_attempts = 10)

Constructor.

Parameters
  • size[in] A vector representing the output size of the cropped image. If the size is a single value, a squared crop of size (size, size) is returned. If the size has 2 values, it should be (height, width).

  • scale[in] Range [min, max) of respective size of the original size to be cropped (default=(0.08, 1.0)).

  • ratio[in] Range [min, max) of aspect ratio to be cropped (default=(3. / 4., 4. / 3.)).

  • interpolation[in] Image interpolation mode (default=InterpolationMode::kLinear).

    • InterpolationMode::kLinear, Interpolation method is blinear interpolation.

    • InterpolationMode::kNearestNeighbour, Interpolation method is nearest-neighbor interpolation.

    • InterpolationMode::kCubic, Interpolation method is bicubic interpolation.

    • InterpolationMode::kArea, Interpolation method is pixel area interpolation.

    • InterpolationMode::kCubicPil, Interpolation method is bicubic interpolation like implemented in pillow.

  • max_attempts[in] The maximum number of attempts to propose a valid crop_area (default=10). If exceeded, fall back to use center_crop instead.

样例
/* Define operations */
auto random_op = vision::RandomResizedCropWithBBox({50, 50}, {0.05, 0.5}, {0.2, 0.4},
                                                   InterpolationMode::kCubic);

/* dataset is an instance of Dataset object */
dataset = dataset->Map({random_op},             // operations
                       {"image", "bbox"});      // input columns
~RandomResizedCropWithBBox() = default

Destructor.