/** * Copyright 2020-2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "minddata/dataset/include/vision.h" #include "minddata/dataset/include/transforms.h" #include "minddata/dataset/kernels/ir/vision/vision_ir.h" #ifndef ENABLE_ANDROID #include "minddata/dataset/kernels/image/image_utils.h" #endif #include "minddata/dataset/kernels/ir/validators.h" // Kernel image headers (in alphabetical order) #ifndef ENABLE_ANDROID #include "minddata/dataset/kernels/image/auto_contrast_op.h" #include "minddata/dataset/kernels/image/bounding_box_augment_op.h" #endif #include "minddata/dataset/kernels/image/center_crop_op.h" #include "minddata/dataset/kernels/image/crop_op.h" #ifndef ENABLE_ANDROID #include "minddata/dataset/kernels/image/cutmix_batch_op.h" #include "minddata/dataset/kernels/image/cut_out_op.h" #endif #include "minddata/dataset/kernels/image/decode_op.h" #ifdef ENABLE_ACL #include "minddata/dataset/include/vision_ascend.h" #include "minddata/dataset/kernels/image/dvpp/dvpp_crop_jpeg_op.h" #include "minddata/dataset/kernels/image/dvpp/dvpp_decode_resize_jpeg_op.h" #include "minddata/dataset/kernels/image/dvpp/dvpp_decode_resize_crop_jpeg_op.h" #include "minddata/dataset/kernels/image/dvpp/dvpp_decode_jpeg_op.h" #include "minddata/dataset/kernels/image/dvpp/dvpp_decode_png_op.h" #include "minddata/dataset/kernels/image/dvpp/dvpp_resize_jpeg_op.h" #endif #ifndef ENABLE_ANDROID #include "minddata/dataset/kernels/image/equalize_op.h" #include "minddata/dataset/kernels/image/hwc_to_chw_op.h" #include "minddata/dataset/kernels/image/invert_op.h" #include "minddata/dataset/kernels/image/mixup_batch_op.h" #endif #include "minddata/dataset/kernels/image/normalize_op.h" #include "minddata/dataset/kernels/image/normalize_pad_op.h" #ifndef ENABLE_ANDROID #include "minddata/dataset/kernels/image/pad_op.h" #include "minddata/dataset/kernels/image/random_affine_op.h" #include "minddata/dataset/kernels/image/random_color_op.h" #include "minddata/dataset/kernels/image/random_color_adjust_op.h" #include "minddata/dataset/kernels/image/random_crop_and_resize_op.h" #include "minddata/dataset/kernels/image/random_crop_op.h" #include "minddata/dataset/kernels/image/random_crop_decode_resize_op.h" #include "minddata/dataset/kernels/image/random_crop_with_bbox_op.h" #include "minddata/dataset/kernels/image/random_crop_and_resize_with_bbox_op.h" #include "minddata/dataset/kernels/image/random_horizontal_flip_op.h" #include "minddata/dataset/kernels/image/random_horizontal_flip_with_bbox_op.h" #include "minddata/dataset/kernels/image/random_posterize_op.h" #include "minddata/dataset/kernels/image/random_resize_op.h" #include "minddata/dataset/kernels/image/random_resize_with_bbox_op.h" #include "minddata/dataset/kernels/image/random_rotation_op.h" #include "minddata/dataset/kernels/image/random_select_subpolicy_op.h" #include "minddata/dataset/kernels/image/random_sharpness_op.h" #include "minddata/dataset/kernels/image/random_solarize_op.h" #include "minddata/dataset/kernels/image/random_vertical_flip_op.h" #include "minddata/dataset/kernels/image/random_vertical_flip_with_bbox_op.h" #include "minddata/dataset/kernels/image/rescale_op.h" #endif #include "minddata/dataset/kernels/image/resize_op.h" #ifndef ENABLE_ANDROID #include "minddata/dataset/kernels/image/resize_with_bbox_op.h" #include "minddata/dataset/kernels/image/rgba_to_bgr_op.h" #include "minddata/dataset/kernels/image/rgba_to_rgb_op.h" #include "minddata/dataset/kernels/image/soft_dvpp/soft_dvpp_decode_random_crop_resize_jpeg_op.h" #include "minddata/dataset/kernels/image/soft_dvpp/soft_dvpp_decode_resize_jpeg_op.h" #include "minddata/dataset/kernels/image/swap_red_blue_op.h" #include "minddata/dataset/kernels/image/uniform_aug_op.h" #endif #include "minddata/dataset/kernels/image/rotate_op.h" namespace mindspore { namespace dataset { // Transform operations for computer vision. namespace vision { #ifndef ENABLE_ANDROID // FUNCTIONS TO CREATE VISION TRANSFORM OPERATIONS // (In alphabetical order) // Function to create AutoContrastOperation. std::shared_ptr AutoContrast(float cutoff, std::vector ignore) { auto op = std::make_shared(cutoff, ignore); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create BoundingBoxAugmentOperation. std::shared_ptr BoundingBoxAugment(std::shared_ptr transform, float ratio) { auto op = std::make_shared(transform, ratio); // Input validation return op->ValidateParams() ? op : nullptr; } #endif // Function to create CenterCropOperation. std::shared_ptr CenterCrop(std::vector size) { auto op = std::make_shared(size); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create CropOperation. std::shared_ptr Crop(std::vector coordinates, std::vector size) { auto op = std::make_shared(coordinates, size); // Input validation return op->ValidateParams() ? op : nullptr; } #ifndef ENABLE_ANDROID // Function to create CutMixBatchOperation. std::shared_ptr CutMixBatch(ImageBatchFormat image_batch_format, float alpha, float prob) { auto op = std::make_shared(image_batch_format, alpha, prob); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create CutOutOp. std::shared_ptr CutOut(int32_t length, int32_t num_patches) { auto op = std::make_shared(length, num_patches); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create DecodeOperation. std::shared_ptr Decode(bool rgb) { auto op = std::make_shared(rgb); // Input validation return op->ValidateParams() ? op : nullptr; } #ifdef ENABLE_ACL // Function to create DvppResizeOperation. std::shared_ptr DvppCropJpeg(std::vector crop) { auto op = std::make_shared(crop); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create DvppDecodeResizeOperation. std::shared_ptr DvppDecodeResizeJpeg(std::vector resize) { auto op = std::make_shared(resize); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create DvppDecodeResizeCropOperation. std::shared_ptr DvppDecodeResizeCropJpeg(std::vector crop, std::vector resize) { auto op = std::make_shared(crop, resize); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create DvppDecodeJpegOperation. std::shared_ptr DvppDecodeJpeg() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create DvppDecodePngOperation. std::shared_ptr DvppDecodePng() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create DvppResizeOperation. std::shared_ptr DvppResizeJpeg(std::vector resize) { auto op = std::make_shared(resize); // Input validation return op->ValidateParams() ? op : nullptr; } #endif // Function to create EqualizeOperation. std::shared_ptr Equalize() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create HwcToChwOperation. std::shared_ptr HWC2CHW() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create InvertOperation. std::shared_ptr Invert() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create MixUpBatchOperation. std::shared_ptr MixUpBatch(float alpha) { auto op = std::make_shared(alpha); // Input validation return op->ValidateParams() ? op : nullptr; } #endif // Function to create NormalizeOperation. std::shared_ptr Normalize(std::vector mean, std::vector std) { auto op = std::make_shared(mean, std); // Input validation return op->ValidateParams() ? op : nullptr; } #ifndef ENABLE_ANDROID // Function to create NormalizePadOperation. std::shared_ptr NormalizePad(const std::vector &mean, const std::vector &std, const std::string &dtype) { auto op = std::make_shared(mean, std, dtype); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create PadOperation. std::shared_ptr Pad(std::vector padding, std::vector fill_value, BorderType padding_mode) { auto op = std::make_shared(padding, fill_value, padding_mode); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomAffineOperation. std::shared_ptr RandomAffine(const std::vector °rees, const std::vector &translate_range, const std::vector &scale_range, const std::vector &shear_ranges, InterpolationMode interpolation, const std::vector &fill_value) { auto op = std::make_shared(degrees, translate_range, scale_range, shear_ranges, interpolation, fill_value); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomColorOperation. std::shared_ptr RandomColor(float t_lb, float t_ub) { auto op = std::make_shared(t_lb, t_ub); // Input validation return op->ValidateParams() ? op : nullptr; } std::shared_ptr RandomColorOperation::Build() { std::shared_ptr tensor_op = std::make_shared(t_lb_, t_ub_); return tensor_op; } // Function to create RandomColorAdjustOperation. std::shared_ptr RandomColorAdjust(std::vector brightness, std::vector contrast, std::vector saturation, std::vector hue) { auto op = std::make_shared(brightness, contrast, saturation, hue); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomCropOperation. std::shared_ptr RandomCrop(std::vector size, std::vector padding, bool pad_if_needed, std::vector fill_value, BorderType padding_mode) { auto op = std::make_shared(size, padding, pad_if_needed, fill_value, padding_mode); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomCropDecodeResizeOperation. std::shared_ptr RandomCropDecodeResize(std::vector size, std::vector scale, std::vector ratio, InterpolationMode interpolation, int32_t max_attempts) { auto op = std::make_shared(size, scale, ratio, interpolation, max_attempts); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomCropWithBBoxOperation. std::shared_ptr RandomCropWithBBox(std::vector size, std::vector padding, bool pad_if_needed, std::vector fill_value, BorderType padding_mode) { auto op = std::make_shared(size, padding, pad_if_needed, fill_value, padding_mode); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomHorizontalFlipOperation. std::shared_ptr RandomHorizontalFlip(float prob) { auto op = std::make_shared(prob); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomHorizontalFlipOperation. std::shared_ptr RandomHorizontalFlipWithBBox(float prob) { auto op = std::make_shared(prob); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomPosterizeOperation. std::shared_ptr RandomPosterize(const std::vector &bit_range) { auto op = std::make_shared(bit_range); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomResizeOperation. std::shared_ptr RandomResize(std::vector size) { auto op = std::make_shared(size); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomResizeWithBBoxOperation. std::shared_ptr RandomResizeWithBBox(std::vector size) { auto op = std::make_shared(size); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomResizedCropOperation. std::shared_ptr RandomResizedCrop(std::vector size, std::vector scale, std::vector ratio, InterpolationMode interpolation, int32_t max_attempts) { auto op = std::make_shared(size, scale, ratio, interpolation, max_attempts); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomResizedCropOperation. std::shared_ptr RandomResizedCropWithBBox(std::vector size, std::vector scale, std::vector ratio, InterpolationMode interpolation, int32_t max_attempts) { auto op = std::make_shared(size, scale, ratio, interpolation, max_attempts); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomRotationOperation. std::shared_ptr RandomRotation(std::vector degrees, InterpolationMode resample, bool expand, std::vector center, std::vector fill_value) { auto op = std::make_shared(degrees, resample, expand, center, fill_value); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomSharpnessOperation. std::shared_ptr RandomSharpness(std::vector degrees) { auto op = std::make_shared(degrees); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomSolarizeOperation. std::shared_ptr RandomSolarize(std::vector threshold) { auto op = std::make_shared(threshold); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomSelectSubpolicyOperation. std::shared_ptr RandomSelectSubpolicy( std::vector, double>>> policy) { auto op = std::make_shared(policy); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomVerticalFlipOperation. std::shared_ptr RandomVerticalFlip(float prob) { auto op = std::make_shared(prob); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RandomVerticalFlipWithBBoxOperation. std::shared_ptr RandomVerticalFlipWithBBox(float prob) { auto op = std::make_shared(prob); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RescaleOperation. std::shared_ptr Rescale(float rescale, float shift) { auto op = std::make_shared(rescale, shift); // Input validation return op->ValidateParams() ? op : nullptr; } #endif // Function to create ResizeOperation. std::shared_ptr Resize(std::vector size, InterpolationMode interpolation) { auto op = std::make_shared(size, interpolation); // Input validation return op->ValidateParams() ? op : nullptr; } #ifdef ENABLE_ANDROID // Function to create RotateOperation. std::shared_ptr Rotate() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } #endif #ifndef ENABLE_ANDROID // Function to create ResizeWithBBoxOperation. std::shared_ptr ResizeWithBBox(std::vector size, InterpolationMode interpolation) { auto op = std::make_shared(size, interpolation); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RgbaToBgrOperation. std::shared_ptr RGBA2BGR() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create RgbaToRgbOperation. std::shared_ptr RGBA2RGB() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create SoftDvppDecodeRandomCropResizeJpegOperation. std::shared_ptr SoftDvppDecodeRandomCropResizeJpeg( std::vector size, std::vector scale, std::vector ratio, int32_t max_attempts) { auto op = std::make_shared(size, scale, ratio, max_attempts); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create SoftDvppDecodeResizeJpegOperation. std::shared_ptr SoftDvppDecodeResizeJpeg(std::vector size) { auto op = std::make_shared(size); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create SwapRedBlueOperation. std::shared_ptr SwapRedBlue() { auto op = std::make_shared(); // Input validation return op->ValidateParams() ? op : nullptr; } // Function to create UniformAugOperation. std::shared_ptr UniformAugment(std::vector> transforms, int32_t num_ops) { auto op = std::make_shared(transforms, num_ops); // Input validation return op->ValidateParams() ? op : nullptr; } #endif #ifdef ENABLE_ACL // DvppCropOperation DvppCropJpegOperation::DvppCropJpegOperation(const std::vector &crop) : crop_(crop) {} Status DvppCropJpegOperation::ValidateParams() { // size if (crop_.empty() || crop_.size() > 2) { std::string err_msg = "DvppCropJpeg: Crop resolution must be a vector of one or two elements, got: " + std::to_string(crop_.size()); MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (*min_element(crop_.begin(), crop_.end()) < 32 || *max_element(crop_.begin(), crop_.end()) > 2048) { std::string err_msg = "Dvpp module supports crop image with resolution in range [32, 2048], got crop Parameters: "; if (crop_.size() == 2) { MS_LOG(ERROR) << err_msg << "[" << crop_[0] << ", " << crop_[1] << "]"; } else { MS_LOG(ERROR) << err_msg << "[" << crop_[0] << ", " << crop_[0] << "]"; } RETURN_STATUS_SYNTAX_ERROR(err_msg); } return Status::OK(); } std::shared_ptr DvppCropJpegOperation::Build() { // If size is a single value, the smaller edge of the image will be // resized to this value with the same image aspect ratio. uint32_t cropHeight, cropWidth; // User specified the width value. if (crop_.size() == 1) { cropHeight = crop_[0]; cropWidth = crop_[0]; } else { cropHeight = crop_[0]; cropWidth = crop_[1]; } std::shared_ptr tensor_op = std::make_shared(cropHeight, cropWidth); return tensor_op; } // DvppDecodeResizeOperation DvppDecodeResizeOperation::DvppDecodeResizeOperation(const std::vector &resize) : resize_(resize) {} Status DvppDecodeResizeOperation::ValidateParams() { // size if (resize_.empty() || resize_.size() > 2) { std::string err_msg = "DvppDecodeResizeJpeg: resize resolution must be a vector of one or two elements, got: " + std::to_string(resize_.size()); MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (*min_element(resize_.begin(), resize_.end()) < 32 || *max_element(resize_.begin(), resize_.end()) > 2048) { std::string err_msg = "Dvpp module supports resize image with resolution in range [32, 2048], got resize Parameters: "; if (resize_.size() == 2) { MS_LOG(ERROR) << err_msg << "[" << resize_[0] << ", " << resize_[1] << "]"; } else { MS_LOG(ERROR) << err_msg << "[" << resize_[0] << ", " << resize_[0] << "]"; } RETURN_STATUS_SYNTAX_ERROR(err_msg); } return Status::OK(); } std::shared_ptr DvppDecodeResizeOperation::Build() { // If size is a single value, the smaller edge of the image will be // resized to this value with the same image aspect ratio. uint32_t resizeHeight, resizeWidth; // User specified the width value. if (resize_.size() == 1) { resizeHeight = resize_[0]; resizeWidth = 0; } else { resizeHeight = resize_[0]; resizeWidth = resize_[1]; } std::shared_ptr tensor_op = std::make_shared(resizeHeight, resizeWidth); return tensor_op; } // DvppDecodeResizeCropOperation DvppDecodeResizeCropOperation::DvppDecodeResizeCropOperation(const std::vector &crop, const std::vector &resize) : crop_(crop), resize_(resize) {} Status DvppDecodeResizeCropOperation::ValidateParams() { // size if (crop_.empty() || crop_.size() > 2) { std::string err_msg = "DvppDecodeResizeCropJpeg: crop resolution must be a vector of one or two elements, got: " + std::to_string(crop_.size()); MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (resize_.empty() || resize_.size() > 2) { std::string err_msg = "DvppDecodeResizeCropJpeg: resize resolution must be a vector of one or two elements, got: " + std::to_string(resize_.size()); MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (*min_element(crop_.begin(), crop_.end()) < 32 || *max_element(crop_.begin(), crop_.end()) > 2048) { std::string err_msg = "Dvpp module supports crop image with resolution in range [32, 2048], got Crop Parameters: "; if (crop_.size() == 2) { MS_LOG(ERROR) << err_msg << "[" << crop_[0] << ", " << crop_[1] << "]"; } else { MS_LOG(ERROR) << err_msg << "[" << crop_[0] << ", " << crop_[0] << "]"; } RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (*min_element(resize_.begin(), resize_.end()) < 32 || *max_element(resize_.begin(), resize_.end()) > 2048) { std::string err_msg = "Dvpp module supports resize image with resolution in range [32, 2048], got Crop Parameters: "; if (resize_.size() == 2) { MS_LOG(ERROR) << err_msg << "[" << resize_[0] << ", " << resize_[1] << "]"; } else { MS_LOG(ERROR) << err_msg << "[" << resize_[0] << "]"; } RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (crop_.size() < resize_.size()) { if (crop_[0] > MIN(resize_[0], resize_[1])) { std::string err_msg = "Each value of crop parameter must be smaller than corresponding resize parameter, for example: x[0] <= " "y[0], and x[1] <= y[1], please verify your input parameters."; MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } } if (crop_.size() > resize_.size()) { if (MAX(crop_[0], crop_[1]) > resize_[0]) { std::string err_msg = "Each value of crop parameter must be smaller than corresponding resize parameter, for example: x[0] <= " "y[0], and x[1] <= y[1], please verify your input parameters."; MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } } if (crop_.size() == resize_.size()) { for (int32_t i = 0; i < crop_.size(); ++i) { if (crop_[i] > resize_[i]) { std::string err_msg = "Each value of crop parameter must be smaller than corresponding resize parameter, for example: x[0] <= " "y[0], and x[1] <= y[1], please verify your input parameters."; MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } } } return Status::OK(); } std::shared_ptr DvppDecodeResizeCropOperation::Build() { // If size is a single value, the smaller edge of the image will be // resized to this value with the same image aspect ratio. uint32_t cropHeight, cropWidth, resizeHeight, resizeWidth; if (crop_.size() == 1) { cropHeight = crop_[0]; cropWidth = crop_[0]; } else { cropHeight = crop_[0]; cropWidth = crop_[1]; } // User specified the width value. if (resize_.size() == 1) { resizeHeight = resize_[0]; resizeWidth = 0; } else { resizeHeight = resize_[0]; resizeWidth = resize_[1]; } std::shared_ptr tensor_op = std::make_shared(cropHeight, cropWidth, resizeHeight, resizeWidth); return tensor_op; } // DvppDecodeJPEG Status DvppDecodeJpegOperation::ValidateParams() { return Status::OK(); } std::shared_ptr DvppDecodeJpegOperation::Build() { return std::make_shared(); } // DvppDecodePNG Status DvppDecodePngOperation::ValidateParams() { return Status::OK(); } std::shared_ptr DvppDecodePngOperation::Build() { return std::make_shared(); } // DvppResizeOperation DvppResizeJpegOperation::DvppResizeJpegOperation(const std::vector &resize) : resize_(resize) {} Status DvppResizeJpegOperation::ValidateParams() { // size if (resize_.empty() || resize_.size() > 2) { std::string err_msg = "DvppResizeJpeg: resize resolution must be a vector of one or two elements, got: " + std::to_string(resize_.size()); MS_LOG(ERROR) << err_msg; RETURN_STATUS_SYNTAX_ERROR(err_msg); } if (*min_element(resize_.begin(), resize_.end()) < 32 || *max_element(resize_.begin(), resize_.end()) > 2048) { std::string err_msg = "Dvpp module supports resize image with resolution in range [32, 2048], got resize Parameters: "; if (resize_.size() == 2) { MS_LOG(ERROR) << err_msg << "[" << resize_[0] << ", " << resize_[1] << "]"; } else { MS_LOG(ERROR) << err_msg << "[" << resize_[0] << ", " << resize_[0] << "]"; } RETURN_STATUS_SYNTAX_ERROR(err_msg); } return Status::OK(); } std::shared_ptr DvppResizeJpegOperation::Build() { // If size is a single value, the smaller edge of the image will be // resized to this value with the same image aspect ratio. uint32_t resizeHeight, resizeWidth; // User specified the width value. if (resize_.size() == 1) { resizeHeight = resize_[0]; resizeWidth = 0; } else { resizeHeight = resize_[0]; resizeWidth = resize_[1]; } std::shared_ptr tensor_op = std::make_shared(resizeHeight, resizeWidth); return tensor_op; } #endif } // namespace vision } // namespace dataset } // namespace mindspore