mindspore.dataset.vision.c_transforms.SoftDvppDecodeRandomCropResizeJpeg
- class mindspore.dataset.vision.c_transforms.SoftDvppDecodeRandomCropResizeJpeg(size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), max_attempts=10)[source]
A combination of Crop, Decode and Resize using the simulation algorithm of Ascend series chip DVPP module.
The usage scenario is consistent with SoftDvppDecodeResizeJpeg. The input image size should be in range [32*32, 8192*8192]. The zoom-out and zoom-in multiples of the image length and width should in the range [1/32, 16]. Only images with an even resolution can be output. The output of odd resolution is not supported.
- Parameters
size (Union[int, sequence]) – The size of the output image. The size value(s) must be positive. If size is an integer, a square crop of size (size, size) is returned. If size is a sequence of length 2, it should be (height, width).
scale (list, tuple, optional) – Range [min, max) of respective size of the original size to be cropped, which must be non-negative (default=(0.08, 1.0)).
ratio (list, tuple, optional) – Range [min, max) of aspect ratio to be cropped, which must be non-negative (default=(3. / 4., 4. / 3.)).
max_attempts (int, optional) – The maximum number of attempts to propose a valid crop_area (default=10). If exceeded, fall back to use center_crop instead. The max_attempts value must be positive.
- Raises
TypeError – If size is not of type integer or sequence of integer.
TypeError – If scale is not of type tuple.
TypeError – If ratio is not of type tuple.
TypeError – If max_attempts is not of type integer.
ValueError – If size is not positive.
ValueError – If scale is negative.
ValueError – If ratio is negative.
ValueError – If max_attempts is not positive.
RuntimeError – If given tensor is not a 1D sequence.
- Supported Platforms:
CPU
Examples
>>> # decode, randomly crop and resize image, keeping aspect ratio >>> transforms_list1 = [c_vision.SoftDvppDecodeRandomCropResizeJpeg(90)] >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list1, ... input_columns=["image"]) >>> # decode, randomly crop and resize to landscape style >>> transforms_list2 = [c_vision.SoftDvppDecodeRandomCropResizeJpeg((80, 100))] >>> image_folder_dataset_1 = image_folder_dataset_1.map(operations=transforms_list2, ... input_columns=["image"])