forked from mindspore-Ecosystem/mindspore
Add Random operation with MultiField
This commit is contained in:
parent
4cab7ffbd3
commit
a8d02ab782
|
@ -45,17 +45,21 @@ Status BoundingBoxAugmentOp::Compute(const TensorRow &input, TensorRow *output)
|
|||
RETURN_IF_NOT_OK(Crop(input_restore, &crop_out, static_cast<int>(bbox->x()), static_cast<int>(bbox->y()),
|
||||
static_cast<int>(bbox->width()), static_cast<int>(bbox->height())));
|
||||
// transform the cropped bbox region
|
||||
RETURN_IF_NOT_OK(transform_->Compute(crop_out, &res_out));
|
||||
TensorRow crop_out_row;
|
||||
TensorRow res_out_row;
|
||||
crop_out_row.push_back(crop_out);
|
||||
res_out_row.push_back(res_out);
|
||||
RETURN_IF_NOT_OK(transform_->Compute(crop_out_row, &res_out_row));
|
||||
// place the transformed region back in the restored input
|
||||
std::shared_ptr<CVTensor> res_img = CVTensor::AsCVTensor(res_out);
|
||||
std::shared_ptr<CVTensor> res_img = CVTensor::AsCVTensor(res_out_row[0]);
|
||||
// check if transformed crop is out of bounds of the box
|
||||
if (res_img->mat().cols > bbox->width() || res_img->mat().rows > bbox->height() ||
|
||||
res_img->mat().cols < bbox->width() || res_img->mat().rows < bbox->height()) {
|
||||
// if so, resize to fit in the box
|
||||
std::shared_ptr<TensorOp> resize_op =
|
||||
std::make_shared<ResizeOp>(static_cast<int32_t>(bbox->height()), static_cast<int32_t>(bbox->width()));
|
||||
RETURN_IF_NOT_OK(resize_op->Compute(std::static_pointer_cast<Tensor>(res_img), &res_out));
|
||||
res_img = CVTensor::AsCVTensor(res_out);
|
||||
RETURN_IF_NOT_OK(resize_op->Compute(std::static_pointer_cast<Tensor>(res_img), &res_out_row[0]));
|
||||
res_img = CVTensor::AsCVTensor(res_out_row[0]);
|
||||
}
|
||||
res_img->mat().copyTo(
|
||||
input_restore->mat()(cv::Rect(bbox->x(), bbox->y(), res_img->mat().cols, res_img->mat().rows)));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -14,6 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "minddata/dataset/kernels/image/random_crop_and_resize_op.h"
|
||||
#include <limits>
|
||||
#include <random>
|
||||
|
||||
#include "minddata/dataset/kernels/image/image_utils.h"
|
||||
|
@ -44,19 +45,28 @@ RandomCropAndResizeOp::RandomCropAndResizeOp(int32_t target_height, int32_t targ
|
|||
is_deterministic_ = false;
|
||||
}
|
||||
|
||||
Status RandomCropAndResizeOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
|
||||
IO_CHECK(input, output);
|
||||
CHECK_FAIL_RETURN_UNEXPECTED(input->shape().Size() >= 2, "RandomCropAndResize: the image is not <H,W,C> or <H,W>");
|
||||
|
||||
int h_in = input->shape()[0];
|
||||
int w_in = input->shape()[1];
|
||||
Status RandomCropAndResizeOp::Compute(const TensorRow &input, TensorRow *output) {
|
||||
IO_CHECK_VECTOR(input, output);
|
||||
const int output_count = input.size();
|
||||
output->resize(output_count);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int crop_height = 0;
|
||||
int crop_width = 0;
|
||||
(void)GetCropBox(h_in, w_in, &x, &y, &crop_height, &crop_width);
|
||||
return CropAndResize(input, output, x, y, crop_height, crop_width, target_height_, target_width_, interpolation_);
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
CHECK_FAIL_RETURN_UNEXPECTED(input[i]->shape().Size() >= 2,
|
||||
"RandomCropAndResize: the image is not <H,W,C> or <H,W>");
|
||||
int h_in = input[i]->shape()[0];
|
||||
int w_in = input[i]->shape()[1];
|
||||
if (i == 0) {
|
||||
(void)GetCropBox(h_in, w_in, &x, &y, &crop_height, &crop_width);
|
||||
}
|
||||
RETURN_IF_NOT_OK(CropAndResize(input[i], &(*output)[i], x, y, crop_height, crop_width, target_height_,
|
||||
target_width_, interpolation_));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status RandomCropAndResizeOp::OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) {
|
||||
RETURN_IF_NOT_OK(TensorOp::OutputShape(inputs, outputs));
|
||||
outputs.clear();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -54,13 +54,18 @@ class RandomCropAndResizeOp : public TensorOp {
|
|||
out << "RandomCropAndResize: " << target_height_ << " " << target_width_;
|
||||
}
|
||||
|
||||
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
|
||||
Status Compute(const TensorRow &input, TensorRow *output) override;
|
||||
|
||||
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
|
||||
|
||||
Status GetCropBox(int h_in, int w_in, int *x, int *y, int *crop_height, int *crop_width);
|
||||
|
||||
std::string Name() const override { return kRandomCropAndResizeOp; }
|
||||
|
||||
uint32_t NumInput() override { return -1; }
|
||||
|
||||
uint32_t NumOutput() override { return -1; }
|
||||
|
||||
protected:
|
||||
int32_t target_height_;
|
||||
int32_t target_width_;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -27,30 +27,37 @@ RandomCropDecodeResizeOp::RandomCropDecodeResizeOp(int32_t target_height, int32_
|
|||
: RandomCropAndResizeOp(target_height, target_width, scale_lb, scale_ub, aspect_lb, aspect_ub, interpolation,
|
||||
max_attempts) {}
|
||||
|
||||
Status RandomCropDecodeResizeOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
|
||||
if (input == nullptr) {
|
||||
RETURN_STATUS_UNEXPECTED("RandomCropDecodeResize: input image is empty.");
|
||||
}
|
||||
if (!IsNonEmptyJPEG(input)) {
|
||||
DecodeOp op(true);
|
||||
std::shared_ptr<Tensor> decoded;
|
||||
RETURN_IF_NOT_OK(op.Compute(input, &decoded));
|
||||
return RandomCropAndResizeOp::Compute(decoded, output);
|
||||
} else {
|
||||
int h_in = 0;
|
||||
int w_in = 0;
|
||||
RETURN_IF_NOT_OK(GetJpegImageInfo(input, &w_in, &h_in));
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int crop_height = 0;
|
||||
int crop_width = 0;
|
||||
(void)GetCropBox(h_in, w_in, &x, &y, &crop_height, &crop_width);
|
||||
|
||||
std::shared_ptr<Tensor> decoded;
|
||||
RETURN_IF_NOT_OK(JpegCropAndDecode(input, &decoded, x, y, crop_width, crop_height));
|
||||
return Resize(decoded, output, target_height_, target_width_, 0.0, 0.0, interpolation_);
|
||||
Status RandomCropDecodeResizeOp::Compute(const TensorRow &input, TensorRow *output) {
|
||||
IO_CHECK_VECTOR(input, output);
|
||||
const int output_count = input.size();
|
||||
output->resize(output_count);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int crop_height = 0;
|
||||
int crop_width = 0;
|
||||
TensorRow decoded;
|
||||
decoded.resize(output_count);
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
if (input[i] == nullptr) {
|
||||
RETURN_STATUS_UNEXPECTED("RandomCropDecodeResize: input image is empty.");
|
||||
}
|
||||
if (!IsNonEmptyJPEG(input[i])) {
|
||||
DecodeOp op(true);
|
||||
RETURN_IF_NOT_OK(op.Compute(input[i], &decoded[i]));
|
||||
RETURN_IF_NOT_OK(RandomCropAndResizeOp::Compute(decoded, output));
|
||||
} else {
|
||||
int h_in = 0;
|
||||
int w_in = 0;
|
||||
RETURN_IF_NOT_OK(GetJpegImageInfo(input[i], &w_in, &h_in));
|
||||
if (i == 0) {
|
||||
(void)GetCropBox(h_in, w_in, &x, &y, &crop_height, &crop_width);
|
||||
}
|
||||
std::shared_ptr<Tensor> decoded_tensor = nullptr;
|
||||
RETURN_IF_NOT_OK(JpegCropAndDecode(input[i], &decoded_tensor, x, y, crop_width, crop_height));
|
||||
RETURN_IF_NOT_OK(Resize(decoded_tensor, &(*output)[i], target_height_, target_width_, 0.0, 0.0, interpolation_));
|
||||
}
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
} // namespace dataset
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -43,7 +43,7 @@ class RandomCropDecodeResizeOp : public RandomCropAndResizeOp {
|
|||
out << Name() << ": " << RandomCropAndResizeOp::target_height_ << " " << RandomCropAndResizeOp::target_width_;
|
||||
}
|
||||
|
||||
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
|
||||
Status Compute(const TensorRow &input, TensorRow *output) override;
|
||||
|
||||
std::string Name() const override { return kRandomCropDecodeResizeOp; }
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -112,35 +112,38 @@ void RandomCropOp::GenRandomXY(int *x, int *y, const int32_t &padded_image_w, co
|
|||
*y = std::uniform_int_distribution<int>(0, padded_image_h - crop_height_)(rnd_);
|
||||
}
|
||||
|
||||
Status RandomCropOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
|
||||
IO_CHECK(input, output);
|
||||
|
||||
if (input->Rank() != 3 && input->Rank() != 2) {
|
||||
RETURN_STATUS_UNEXPECTED("RandomCrop: image shape is not <H,W,C> or <H,W>.");
|
||||
}
|
||||
|
||||
// Apply padding first then crop
|
||||
std::shared_ptr<Tensor> pad_image;
|
||||
int32_t t_pad_top = 0;
|
||||
int32_t t_pad_bottom = 0;
|
||||
int32_t t_pad_left = 0;
|
||||
int32_t t_pad_right = 0;
|
||||
int32_t padded_image_w = 0;
|
||||
int32_t padded_image_h = 0;
|
||||
bool crop_further = true; // whether image needs further cropping based on new size & requirements
|
||||
|
||||
RETURN_IF_NOT_OK( // error code sent back directly
|
||||
ImagePadding(input, &pad_image, &t_pad_top, &t_pad_bottom, &t_pad_left, &t_pad_right, &padded_image_w,
|
||||
&padded_image_h, &crop_further));
|
||||
if (!crop_further) {
|
||||
*output = pad_image;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status RandomCropOp::Compute(const TensorRow &input, TensorRow *output) {
|
||||
IO_CHECK_VECTOR(input, output);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GenRandomXY(&x, &y, padded_image_w, padded_image_h);
|
||||
return Crop(pad_image, output, x, y, crop_width_, crop_height_);
|
||||
const int output_count = input.size();
|
||||
output->resize(output_count);
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
if (input[i]->Rank() != 3 && input[i]->Rank() != 2) {
|
||||
RETURN_STATUS_UNEXPECTED("RandomCrop: image shape is not <H,W,C> or <H,W>.");
|
||||
}
|
||||
std::shared_ptr<Tensor> pad_image = nullptr;
|
||||
int32_t t_pad_top = 0;
|
||||
int32_t t_pad_bottom = 0;
|
||||
int32_t t_pad_left = 0;
|
||||
int32_t t_pad_right = 0;
|
||||
int32_t padded_image_w = 0;
|
||||
int32_t padded_image_h = 0;
|
||||
bool crop_further = true; // whether image needs further cropping based on new size & requirements
|
||||
|
||||
RETURN_IF_NOT_OK( // error code sent back directly
|
||||
ImagePadding(input[i], &pad_image, &t_pad_top, &t_pad_bottom, &t_pad_left, &t_pad_right, &padded_image_w,
|
||||
&padded_image_h, &crop_further));
|
||||
if (!crop_further) {
|
||||
(*output)[i] = pad_image;
|
||||
return Status::OK();
|
||||
}
|
||||
if (i == 0) {
|
||||
GenRandomXY(&x, &y, padded_image_w, padded_image_h);
|
||||
}
|
||||
RETURN_IF_NOT_OK(Crop(pad_image, &(*output)[i], x, y, crop_width_, crop_height_));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status RandomCropOp::OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -54,7 +54,7 @@ class RandomCropOp : public TensorOp {
|
|||
|
||||
void Print(std::ostream &out) const override { out << Name() << ": " << crop_height_ << " " << crop_width_; }
|
||||
|
||||
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
|
||||
Status Compute(const TensorRow &input, TensorRow *output) override;
|
||||
|
||||
// Function breaks out the compute function's image padding functionality and makes available to other Ops
|
||||
// Using this class as a base - re-structured to allow for RandomCropWithBBox Augmentation Op
|
||||
|
@ -79,6 +79,10 @@ class RandomCropOp : public TensorOp {
|
|||
|
||||
std::string Name() const override { return kRandomCropOp; }
|
||||
|
||||
uint32_t NumInput() override { return -1; }
|
||||
|
||||
uint32_t NumOutput() override { return -1; }
|
||||
|
||||
protected:
|
||||
int32_t crop_height_ = 0;
|
||||
int32_t crop_width_ = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -22,10 +22,15 @@ namespace mindspore {
|
|||
namespace dataset {
|
||||
const float RandomHorizontalFlipOp::kDefProbability = 0.5;
|
||||
|
||||
Status RandomHorizontalFlipOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
|
||||
IO_CHECK(input, output);
|
||||
Status RandomHorizontalFlipOp::Compute(const TensorRow &input, TensorRow *output) {
|
||||
IO_CHECK_VECTOR(input, output);
|
||||
const int output_count = input.size();
|
||||
output->resize(output_count);
|
||||
if (distribution_(rnd_)) {
|
||||
return HorizontalFlip(input, output);
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
RETURN_IF_NOT_OK(HorizontalFlip(input[i], &(*output)[i]));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
*output = input;
|
||||
return Status::OK();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -45,10 +45,14 @@ class RandomHorizontalFlipOp : public TensorOp {
|
|||
return out;
|
||||
}
|
||||
|
||||
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
|
||||
Status Compute(const TensorRow &input, TensorRow *output) override;
|
||||
|
||||
std::string Name() const override { return kRandomHorizontalFlipOp; }
|
||||
|
||||
uint32_t NumInput() override { return -1; }
|
||||
|
||||
uint32_t NumOutput() override { return -1; }
|
||||
|
||||
private:
|
||||
std::mt19937 rnd_;
|
||||
std::bernoulli_distribution distribution_;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -25,11 +25,16 @@ namespace mindspore {
|
|||
namespace dataset {
|
||||
const int32_t RandomResizeOp::kDefTargetWidth = 0;
|
||||
|
||||
Status RandomResizeOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
|
||||
// Randomly selects from the following four interpolation methods
|
||||
// 0-bilinear, 1-nearest_neighbor, 2-bicubic, 3-area
|
||||
interpolation_ = static_cast<InterpolationMode>(distribution_(random_generator_));
|
||||
return ResizeOp::Compute(input, output);
|
||||
Status RandomResizeOp::Compute(const TensorRow &input, TensorRow *output) {
|
||||
IO_CHECK_VECTOR(input, output);
|
||||
const int output_count = input.size();
|
||||
output->resize(output_count);
|
||||
InterpolationMode interpolation_random_resize = static_cast<InterpolationMode>(distribution_(random_generator_));
|
||||
std::shared_ptr<TensorOp> resize_op = std::make_shared<ResizeOp>(size1_, size2_, interpolation_random_resize);
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
RETURN_IF_NOT_OK(resize_op->Compute(input[i], &(*output)[i]));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
} // namespace dataset
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -43,10 +43,14 @@ class RandomResizeOp : public ResizeOp {
|
|||
// Description: A function that prints info about the node
|
||||
void Print(std::ostream &out) const override { out << Name() << ": " << ResizeOp::size1_ << " " << ResizeOp::size2_; }
|
||||
|
||||
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
|
||||
Status Compute(const TensorRow &input, TensorRow *output) override;
|
||||
|
||||
std::string Name() const override { return kRandomResizeOp; }
|
||||
|
||||
uint32_t NumInput() override { return -1; }
|
||||
|
||||
uint32_t NumOutput() override { return -1; }
|
||||
|
||||
private:
|
||||
std::mt19937 random_generator_;
|
||||
std::uniform_int_distribution<int> distribution_{0, 3};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -23,10 +23,15 @@ namespace mindspore {
|
|||
namespace dataset {
|
||||
const float RandomVerticalFlipOp::kDefProbability = 0.5;
|
||||
|
||||
Status RandomVerticalFlipOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
|
||||
IO_CHECK(input, output);
|
||||
Status RandomVerticalFlipOp::Compute(const TensorRow &input, TensorRow *output) {
|
||||
IO_CHECK_VECTOR(input, output);
|
||||
const int output_count = input.size();
|
||||
output->resize(output_count);
|
||||
if (distribution_(rnd_)) {
|
||||
return VerticalFlip(input, output);
|
||||
for (size_t i = 0; i < input.size(); i++) {
|
||||
RETURN_IF_NOT_OK(VerticalFlip(input[i], &(*output)[i]));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
*output = input;
|
||||
return Status::OK();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -39,10 +39,14 @@ class RandomVerticalFlipOp : public TensorOp {
|
|||
|
||||
~RandomVerticalFlipOp() override = default;
|
||||
|
||||
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
|
||||
Status Compute(const TensorRow &input, TensorRow *output) override;
|
||||
|
||||
std::string Name() const override { return kRandomVerticalFlipOp; }
|
||||
|
||||
uint32_t NumInput() override { return -1; }
|
||||
|
||||
uint32_t NumOutput() override { return -1; }
|
||||
|
||||
private:
|
||||
std::mt19937 rnd_;
|
||||
std::bernoulli_distribution distribution_;
|
||||
|
|
|
@ -13,13 +13,14 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "minddata/dataset/kernels/image/soft_dvpp/soft_dvpp_decode_random_crop_resize_jpeg_op.h"
|
||||
#include <string>
|
||||
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
#include "minddata/dataset/core/cv_tensor.h"
|
||||
#include "minddata/dataset/kernels/image/image_utils.h"
|
||||
#include "minddata/dataset/kernels/image/random_crop_and_resize_op.h"
|
||||
#include "minddata/dataset/kernels/image/soft_dvpp/soft_dvpp_decode_random_crop_resize_jpeg_op.h"
|
||||
#include "minddata/dataset/util/random.h"
|
||||
|
||||
namespace mindspore {
|
||||
|
@ -28,8 +29,13 @@ SoftDvppDecodeRandomCropResizeJpegOp::SoftDvppDecodeRandomCropResizeJpegOp(int32
|
|||
float scale_lb, float scale_ub,
|
||||
float aspect_lb, float aspect_ub,
|
||||
int32_t max_attempts)
|
||||
: RandomCropAndResizeOp(target_height, target_width, scale_lb, scale_ub, aspect_lb, aspect_ub,
|
||||
InterpolationMode::kLinear, max_attempts) {}
|
||||
: target_height_(target_height),
|
||||
target_width_(target_width),
|
||||
scale_lb_(scale_lb),
|
||||
scale_ub_(scale_ub),
|
||||
aspect_lb_(aspect_lb),
|
||||
aspect_ub_(aspect_ub),
|
||||
max_attempts_(max_attempts) {}
|
||||
|
||||
Status SoftDvppDecodeRandomCropResizeJpegOp::GetCropInfo(const std::shared_ptr<Tensor> &input,
|
||||
SoftDpCropInfo *crop_info) {
|
||||
|
@ -40,7 +46,10 @@ Status SoftDvppDecodeRandomCropResizeJpegOp::GetCropInfo(const std::shared_ptr<T
|
|||
int y = 0;
|
||||
int crop_heigh = 0;
|
||||
int crop_widht = 0;
|
||||
RETURN_IF_NOT_OK(GetCropBox(img_height, img_width, &x, &y, &crop_heigh, &crop_widht));
|
||||
std::unique_ptr<RandomCropAndResizeOp> random_crop_resize(
|
||||
new RandomCropAndResizeOp(target_height_, target_width_, scale_lb_, scale_ub_, aspect_lb_, aspect_ub_,
|
||||
InterpolationMode::kLinear, max_attempts_));
|
||||
RETURN_IF_NOT_OK(random_crop_resize->GetCropBox(img_height, img_width, &x, &y, &crop_heigh, &crop_widht));
|
||||
crop_info->left = x;
|
||||
crop_info->up = y;
|
||||
crop_info->right = crop_info->left + crop_widht - 1;
|
||||
|
|
|
@ -28,8 +28,15 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace dataset {
|
||||
class SoftDvppDecodeRandomCropResizeJpegOp : public RandomCropAndResizeOp {
|
||||
class SoftDvppDecodeRandomCropResizeJpegOp : public TensorOp {
|
||||
public:
|
||||
static const float kDefScaleLb;
|
||||
static const float kDefScaleUb;
|
||||
static const float kDefAspectLb;
|
||||
static const float kDefAspectUb;
|
||||
static const InterpolationMode kDefInterpolation;
|
||||
static const int32_t kDefMaxIter;
|
||||
|
||||
SoftDvppDecodeRandomCropResizeJpegOp(int32_t target_height, int32_t target_width, float scale_lb = kDefScaleLb,
|
||||
float scale_ub = kDefScaleUb, float aspect_lb = kDefAspectLb,
|
||||
float aspect_ub = kDefAspectUb, int32_t max_attempts = kDefMaxIter);
|
||||
|
@ -43,6 +50,14 @@ class SoftDvppDecodeRandomCropResizeJpegOp : public RandomCropAndResizeOp {
|
|||
|
||||
protected:
|
||||
Status GetCropInfo(const std::shared_ptr<Tensor> &input, SoftDpCropInfo *crop_info);
|
||||
|
||||
int32_t target_height_;
|
||||
int32_t target_width_;
|
||||
float scale_lb_;
|
||||
float scale_ub_;
|
||||
float aspect_lb_;
|
||||
float aspect_ub_;
|
||||
int32_t max_attempts_;
|
||||
};
|
||||
} // namespace dataset
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -34,5 +34,5 @@ if platform.system().lower() != 'windows':
|
|||
from .transforms import UnicodeScriptTokenizer, WhitespaceTokenizer, CaseFold, NormalizeUTF8, \
|
||||
RegexReplace, RegexTokenizer, BasicTokenizer, BertTokenizer
|
||||
|
||||
__all__.append(["UnicodeScriptTokenizer", "WhitespaceTokenizer", "CaseFold", "NormalizeUTF8",
|
||||
__all__.extend(["UnicodeScriptTokenizer", "WhitespaceTokenizer", "CaseFold", "NormalizeUTF8",
|
||||
"RegexReplace", "RegexTokenizer", "BasicTokenizer", "BertTokenizer"])
|
||||
|
|
|
@ -260,6 +260,46 @@ class ConvertColor(ImageTensorOperation):
|
|||
Args:
|
||||
convert_mode (ConvertMode): The mode of image channel conversion.
|
||||
|
||||
- ConvertMode.COLOR_BGR2BGRA, Add alpha channel to BGR image.
|
||||
|
||||
- ConvertMode.COLOR_RGB2RGBA, Add alpha channel to RGB image.
|
||||
|
||||
- ConvertMode.COLOR_BGRA2BGR, Remove alpha channel to BGR image.
|
||||
|
||||
- ConvertMode.COLOR_RGBA2RGB, Remove alpha channel to RGB image.
|
||||
|
||||
- ConvertMode.COLOR_BGR2RGBA, Convert BGR image to RGBA image.
|
||||
|
||||
- ConvertMode.COLOR_RGB2BGRA, Convert RGB image to BGRA image.
|
||||
|
||||
- ConvertMode.COLOR_RGBA2BGR, Convert RGBA image to BGR image.
|
||||
|
||||
- ConvertMode.COLOR_BGRA2RGB, Convert BGRA image to RGB image.
|
||||
|
||||
- ConvertMode.COLOR_BGR2RGB, Convert BGR image to RGB image.
|
||||
|
||||
- ConvertMode.COLOR_RGB2BGR, Convert RGB image to BGR image.
|
||||
|
||||
- ConvertMode.COLOR_BGRA2RGBA, Convert BGRA image to RGBA image.
|
||||
|
||||
- ConvertMode.COLOR_RGBA2BGRA, Convert RGBA image to BGRA image.
|
||||
|
||||
- ConvertMode.COLOR_BGR2GRAY, Convert BGR image to GRAY image.
|
||||
|
||||
- ConvertMode.COLOR_RGB2GRAY, Convert RGB image to GRAY image.
|
||||
|
||||
- ConvertMode.COLOR_GRAY2BGR, Convert GRAY image to BGR image.
|
||||
|
||||
- ConvertMode.COLOR_GRAY2RGB, Convert GRAY image to RGB image.
|
||||
|
||||
- ConvertMode.COLOR_GRAY2BGRA, Convert GRAY image to BGRA image.
|
||||
|
||||
- ConvertMode.COLOR_GRAY2RGBA, Convert GRAY image to RGBA image.
|
||||
|
||||
- ConvertMode.COLOR_BGRA2GRAY, Convert BGRA image to GRAY image.
|
||||
|
||||
- ConvertMode.COLOR_RGBA2GRAY, Convert RGBA image to GRAY image.
|
||||
|
||||
Examples:
|
||||
>>> # Convert RGB images to GRAY images
|
||||
>>> convert_op = c_vision.ConvertColor(ConvertMode.COLOR_RGB2GRAY)
|
||||
|
|
|
@ -336,6 +336,49 @@ TEST_F(MindDataTestPipeline, TestRandomCropSuccess) {
|
|||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomCropWithMultiField) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomCropWithMultiField.";
|
||||
// Create an VOC Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
|
||||
std::shared_ptr<Dataset> ds =
|
||||
VOC(folder_path, "Segmentation", "train", {}, true, std::make_shared<SequentialSampler>(0, 1));
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create objects for the tensor ops
|
||||
transforms::Duplicate duplicate = transforms::Duplicate();
|
||||
std::shared_ptr<TensorTransform> random_crop(new mindspore::dataset::vision::RandomCrop({500, 500}));
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({duplicate}, {"image"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
ds = ds->Map({random_crop}, {"image", "image_copy"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create an iterator over the result of the above dataset
|
||||
// This will trigger the creation of the Execution Tree and launch it.
|
||||
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
||||
EXPECT_NE(iter, nullptr);
|
||||
|
||||
// Iterate the dataset and get each row
|
||||
std::unordered_map<std::string, mindspore::MSTensor> row;
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
|
||||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
auto image = row["image"];
|
||||
auto image_copy = row["image_copy"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Tensor image_copy shape: " << image_copy.Shape();
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
}
|
||||
|
||||
EXPECT_EQ(i, 1);
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomCropFail) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomCropFail with invalid parameters.";
|
||||
// Create an VOC Dataset
|
||||
|
@ -661,6 +704,50 @@ TEST_F(MindDataTestPipeline, TestRandomHorizontalAndVerticalFlip) {
|
|||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomResizeWithMultiField) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomResizeWithMultiField with single integer input.";
|
||||
|
||||
// Create an ImageFolder Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
||||
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, std::make_shared<RandomSampler>(false, 1));
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create objects for the tensor ops
|
||||
transforms::Duplicate duplicate = transforms::Duplicate();
|
||||
std::shared_ptr<TensorTransform> random_resize(new vision::RandomResize({100}));
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({duplicate}, {"image"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
ds = ds->Map({random_resize}, {"image", "image_copy"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create an iterator over the result of the above dataset
|
||||
// This will trigger the creation of the Execution Tree and launch it.
|
||||
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
||||
EXPECT_NE(iter, nullptr);
|
||||
|
||||
// Iterate the dataset and get each row
|
||||
std::unordered_map<std::string, mindspore::MSTensor> row;
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
|
||||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
auto image = row["image"];
|
||||
auto image_copy = row["image_copy"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Tensor image_copy shape: " << image_copy.Shape();
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
}
|
||||
|
||||
EXPECT_EQ(i, 1);
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomPosterizeSuccess1) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomPosterizeSuccess1 with non-default parameters.";
|
||||
|
||||
|
@ -878,7 +965,7 @@ TEST_F(MindDataTestPipeline, TestRandomResizeWithBBoxSuccess1) {
|
|||
}
|
||||
|
||||
EXPECT_EQ(i, 3);
|
||||
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
config::set_seed(current_seed);
|
||||
|
@ -1555,3 +1642,138 @@ TEST_F(MindDataTestPipeline, TestRandomVerticalFlipWithBBoxSuccess) {
|
|||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomHorizontalAndVerticalFlipWithMultiField) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomHorizontalAndVerticalFlipWithMultiField for horizontal and "
|
||||
"vertical flips.";
|
||||
|
||||
// Create an ImageFolder Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
||||
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, std::make_shared<RandomSampler>(false, 1));
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create objects for the tensor ops
|
||||
transforms::Duplicate duplicate = transforms::Duplicate();
|
||||
std::shared_ptr<TensorTransform> random_vertical_flip_op = std::make_shared<vision::RandomVerticalFlip>(1);
|
||||
std::shared_ptr<TensorTransform> random_horizontal_flip_op = std::make_shared<vision::RandomHorizontalFlip>(1);
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({duplicate}, {"image"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
ds = ds->Map({random_vertical_flip_op}, {"image", "image_copy"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create an iterator over the result of the above dataset
|
||||
// This will trigger the creation of the Execution Tree and launch it.
|
||||
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
||||
EXPECT_NE(iter, nullptr);
|
||||
|
||||
// Iterate the dataset and get each row
|
||||
std::unordered_map<std::string, mindspore::MSTensor> row;
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
|
||||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
auto image = row["image"];
|
||||
auto image_copy = row["image_copy"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Tensor image_copy shape: " << image_copy.Shape();
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
}
|
||||
|
||||
EXPECT_EQ(i, 1);
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomCropDecodeResizeWithMultiField) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomCropDecodeResizeWithMultiField.";
|
||||
|
||||
// Create an ImageFolder Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
||||
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, false, std::make_shared<RandomSampler>(false, 1));
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create objects for the tensor ops
|
||||
transforms::Duplicate duplicate = transforms::Duplicate();
|
||||
std::shared_ptr<TensorTransform> random_crop_decode_resize(new vision::RandomCropDecodeResize({500, 500}));
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({duplicate}, {"image"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
ds = ds->Map({random_crop_decode_resize}, {"image", "image_copy"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create an iterator over the result of the above dataset
|
||||
// This will trigger the creation of the Execution Tree and launch it.
|
||||
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
||||
EXPECT_NE(iter, nullptr);
|
||||
|
||||
// Iterate the dataset and get each row
|
||||
std::unordered_map<std::string, mindspore::MSTensor> row;
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
|
||||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
auto image = row["image"];
|
||||
auto image_copy = row["image_copy"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Tensor image_copy shape: " << image_copy.Shape();
|
||||
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
}
|
||||
|
||||
EXPECT_EQ(i, 1);
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestPipeline, TestRandomCropResizeWithMultiField) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRandomCropResizeWithMultiField.";
|
||||
|
||||
// Create an ImageFolder Dataset
|
||||
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
||||
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, std::make_shared<RandomSampler>(false, 1));
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create objects for the tensor ops
|
||||
transforms::Duplicate duplicate = transforms::Duplicate();
|
||||
std::shared_ptr<TensorTransform> random_crop_decode_resize(new vision::RandomResizedCrop({500, 500}));
|
||||
|
||||
// Create a Map operation on ds
|
||||
ds = ds->Map({duplicate}, {"image"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
ds = ds->Map({random_crop_decode_resize}, {"image", "image_copy"}, {"image", "image_copy"});
|
||||
EXPECT_NE(ds, nullptr);
|
||||
|
||||
// Create an iterator over the result of the above dataset
|
||||
// This will trigger the creation of the Execution Tree and launch it.
|
||||
std::shared_ptr<Iterator> iter = ds->CreateIterator();
|
||||
EXPECT_NE(iter, nullptr);
|
||||
|
||||
// Iterate the dataset and get each row
|
||||
std::unordered_map<std::string, mindspore::MSTensor> row;
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
|
||||
uint64_t i = 0;
|
||||
while (row.size() != 0) {
|
||||
i++;
|
||||
auto image = row["image"];
|
||||
auto image_copy = row["image_copy"];
|
||||
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
|
||||
MS_LOG(INFO) << "Tensor image_copy shape: " << image_copy.Shape();
|
||||
ASSERT_OK(iter->GetNextRow(&row));
|
||||
}
|
||||
|
||||
EXPECT_EQ(i, 1);
|
||||
|
||||
// Manually terminate the pipeline
|
||||
iter->Stop();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -31,6 +31,10 @@ class MindDataTestRandomCropAndResizeOp : public UT::CVOP::CVOpCommon {
|
|||
TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest1) {
|
||||
MS_LOG(INFO) << " starting RandomCropAndResizeOp simple test";
|
||||
TensorShape s_in = input_tensor_->shape();
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
TensorRow output_tensor_row;
|
||||
std::shared_ptr<Tensor> output_tensor;
|
||||
int h_out = 1024;
|
||||
int w_out = 2048;
|
||||
|
@ -44,7 +48,7 @@ TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest1) {
|
|||
auto op = std::make_unique<RandomCropAndResizeOp>(h_out, w_out, scale_lb, scale_ub, aspect_lb, aspect_ub);
|
||||
Status s;
|
||||
for (auto i = 0; i < 100; i++) {
|
||||
s = op->Compute(input_tensor_, &output_tensor);
|
||||
s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_TRUE(s.IsOk());
|
||||
}
|
||||
|
||||
|
@ -53,6 +57,10 @@ TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest1) {
|
|||
TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest2) {
|
||||
MS_LOG(INFO) << " starting RandomCropAndResizeOp simple test";
|
||||
TensorShape s_in = input_tensor_->shape();
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
TensorRow output_tensor_row;
|
||||
std::shared_ptr<Tensor> output_tensor;
|
||||
int h_out = 1024;
|
||||
int w_out = 2048;
|
||||
|
@ -66,7 +74,7 @@ TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest2) {
|
|||
auto op = std::make_unique<RandomCropAndResizeOp>(h_out, w_out, scale_lb, scale_ub, aspect_lb, aspect_ub);
|
||||
Status s;
|
||||
for (auto i = 0; i < 100; i++) {
|
||||
s = op->Compute(input_tensor_, &output_tensor);
|
||||
s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_TRUE(s.IsOk());
|
||||
}
|
||||
|
||||
|
@ -75,6 +83,10 @@ TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest2) {
|
|||
TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest3) {
|
||||
MS_LOG(INFO) << " starting RandomCropAndResizeOp simple test";
|
||||
TensorShape s_in = input_tensor_->shape();
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
TensorRow output_tensor_row;
|
||||
std::shared_ptr<Tensor> output_tensor;
|
||||
int h_out = 1024;
|
||||
int w_out = 2048;
|
||||
|
@ -88,7 +100,7 @@ TEST_F(MindDataTestRandomCropAndResizeOp, TestOpSimpleTest3) {
|
|||
auto op = std::make_unique<RandomCropAndResizeOp>(h_out, w_out, scale_lb, scale_ub, aspect_lb, aspect_ub);
|
||||
Status s;
|
||||
for (auto i = 0; i < 100; i++) {
|
||||
s = op->Compute(input_tensor_, &output_tensor);
|
||||
s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_TRUE(s.IsOk());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -36,7 +36,6 @@ class MindDataTestRandomCropDecodeResizeOp : public UT::CVOP::CVOpCommon {
|
|||
TEST_F(MindDataTestRandomCropDecodeResizeOp, TestOp2) {
|
||||
MS_LOG(INFO) << "starting RandomCropDecodeResizeOp test 1";
|
||||
|
||||
std::shared_ptr<Tensor> decode_and_crop_output;
|
||||
std::shared_ptr<Tensor> crop_and_decode_output;
|
||||
|
||||
constexpr int target_height = 884;
|
||||
|
@ -52,13 +51,18 @@ TEST_F(MindDataTestRandomCropDecodeResizeOp, TestOp2) {
|
|||
interpolation, max_iter);
|
||||
auto crop_and_decode_copy = crop_and_decode;
|
||||
auto decode_and_crop = static_cast<RandomCropAndResizeOp>(crop_and_decode_copy);
|
||||
EXPECT_TRUE(crop_and_decode.OneToOne());
|
||||
GlobalContext::config_manager()->set_seed(42);
|
||||
TensorRow input_tensor_row_decode;
|
||||
TensorRow output_tensor_row_decode;
|
||||
input_tensor_row_decode.push_back(raw_input_tensor_);
|
||||
TensorRow input_tensor_row;
|
||||
TensorRow output_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
for (int k = 0; k < 10; k++) {
|
||||
(void)crop_and_decode.Compute(raw_input_tensor_, &crop_and_decode_output);
|
||||
(void)decode_and_crop.Compute(input_tensor_, &decode_and_crop_output);
|
||||
cv::Mat output1 = CVTensor::AsCVTensor(crop_and_decode_output)->mat().clone();
|
||||
cv::Mat output2 = CVTensor::AsCVTensor(decode_and_crop_output)->mat().clone();
|
||||
(void)crop_and_decode.Compute(input_tensor_row_decode, &output_tensor_row_decode);
|
||||
(void)decode_and_crop.Compute(input_tensor_row, &output_tensor_row);
|
||||
cv::Mat output1 = CVTensor::AsCVTensor(output_tensor_row_decode[0])->mat().clone();
|
||||
cv::Mat output2 = CVTensor::AsCVTensor(output_tensor_row[0])->mat().clone();
|
||||
|
||||
long int mse_sum = 0;
|
||||
long int count = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -27,7 +27,7 @@ class MindDataTestRandomCropOp : public UT::CVOP::CVOpCommon {
|
|||
protected:
|
||||
MindDataTestRandomCropOp() : CVOpCommon() {}
|
||||
|
||||
std::shared_ptr<Tensor> output_tensor_;
|
||||
TensorRow output_tensor_row;
|
||||
};
|
||||
|
||||
TEST_F(MindDataTestRandomCropOp, TestOp1) {
|
||||
|
@ -36,14 +36,18 @@ TEST_F(MindDataTestRandomCropOp, TestOp1) {
|
|||
unsigned int crop_height = 128;
|
||||
unsigned int crop_width = 128;
|
||||
std::unique_ptr<RandomCropOp> op(new RandomCropOp(crop_height, crop_width, 0, 0, 0, 0, false, BorderType::kConstant));
|
||||
EXPECT_TRUE(op->OneToOne());
|
||||
Status s = op->Compute(input_tensor_, &output_tensor_);
|
||||
size_t actual = 0;
|
||||
if (s == Status::OK()) {
|
||||
actual = output_tensor_->shape()[0] * output_tensor_->shape()[1] * output_tensor_->shape()[2];
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
Status s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
for (size_t i = 0; i < input_tensor_row.size(); i++) {
|
||||
size_t actual = 0;
|
||||
if (s == Status::OK()) {
|
||||
actual = output_tensor_row[i]->shape()[0] * output_tensor_row[i]->shape()[1] * output_tensor_row[i]->shape()[2];
|
||||
}
|
||||
EXPECT_EQ(actual, crop_height * crop_width * 3);
|
||||
EXPECT_EQ(s, Status::OK());
|
||||
}
|
||||
EXPECT_EQ(actual, crop_height * crop_width * 3);
|
||||
EXPECT_EQ(s, Status::OK());
|
||||
}
|
||||
|
||||
TEST_F(MindDataTestRandomCropOp, TestOp2) {
|
||||
|
@ -51,10 +55,12 @@ TEST_F(MindDataTestRandomCropOp, TestOp2) {
|
|||
// Crop params
|
||||
unsigned int crop_height = 1280;
|
||||
unsigned int crop_width = 1280;
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
std::unique_ptr<RandomCropOp> op(
|
||||
new RandomCropOp(crop_height, crop_width, 513, 513, 513, 513, false, BorderType::kConstant));
|
||||
EXPECT_TRUE(op->OneToOne());
|
||||
Status s = op->Compute(input_tensor_, &output_tensor_);
|
||||
Status s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_EQ(true, s.IsOk());
|
||||
MS_LOG(INFO) << "testRandomCrop end.";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -19,9 +19,9 @@
|
|||
#include "utils/log_adapter.h"
|
||||
|
||||
using namespace mindspore::dataset;
|
||||
using mindspore::MsLogLevel::INFO;
|
||||
using mindspore::ExceptionType::NoExceptionType;
|
||||
using mindspore::LogStream;
|
||||
using mindspore::ExceptionType::NoExceptionType;
|
||||
using mindspore::MsLogLevel::INFO;
|
||||
|
||||
class MindDataTestRandomHorizontalFlipOp : public UT::CVOP::CVOpCommon {
|
||||
protected:
|
||||
|
@ -31,9 +31,12 @@ class MindDataTestRandomHorizontalFlipOp : public UT::CVOP::CVOpCommon {
|
|||
TEST_F(MindDataTestRandomHorizontalFlipOp, TestOp) {
|
||||
MS_LOG(INFO) << "Doing testHorizontalFlip.";
|
||||
// flip
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
TensorRow output_tensor_row;
|
||||
std::unique_ptr<RandomHorizontalFlipOp> op(new RandomHorizontalFlipOp(0.5));
|
||||
EXPECT_TRUE(op->OneToOne());
|
||||
Status s = op->Compute(input_tensor_, &input_tensor_);
|
||||
Status s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_TRUE(s.IsOk());
|
||||
CheckImageShapeAndData(input_tensor_, kFlipHorizontal);
|
||||
MS_LOG(INFO) << "testHorizontalFlip end.";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -19,9 +19,9 @@
|
|||
#include "utils/log_adapter.h"
|
||||
|
||||
using namespace mindspore::dataset;
|
||||
using mindspore::MsLogLevel::INFO;
|
||||
using mindspore::ExceptionType::NoExceptionType;
|
||||
using mindspore::LogStream;
|
||||
using mindspore::ExceptionType::NoExceptionType;
|
||||
using mindspore::MsLogLevel::INFO;
|
||||
|
||||
class MindDataTestRandomResize : public UT::CVOP::CVOpCommon {
|
||||
public:
|
||||
|
@ -34,11 +34,13 @@ TEST_F(MindDataTestRandomResize, TestOp) {
|
|||
TensorShape s = input_tensor_->shape();
|
||||
int output_h = 0.5 * s[0];
|
||||
int output_w = 0.5 * s[1];
|
||||
std::shared_ptr<Tensor> output_tensor;
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
TensorRow output_tensor_row;
|
||||
// Resizing
|
||||
std::unique_ptr<RandomResizeOp> op(new RandomResizeOp(output_h, output_w));
|
||||
EXPECT_TRUE(op->OneToOne());
|
||||
Status st = op->Compute(input_tensor_, &output_tensor);
|
||||
Status st = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_TRUE(st.IsOk());
|
||||
MS_LOG(INFO) << "testResize end.";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
||||
* Copyright 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.
|
||||
|
@ -31,9 +31,12 @@ class MindDataTestRandomVerticalFlipOp : public UT::CVOP::CVOpCommon {
|
|||
TEST_F(MindDataTestRandomVerticalFlipOp, TestOp) {
|
||||
MS_LOG(INFO) << "Doing testVerticalFlip.";
|
||||
// flip
|
||||
TensorRow input_tensor_row;
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
input_tensor_row.push_back(input_tensor_);
|
||||
TensorRow output_tensor_row;
|
||||
std::unique_ptr<RandomVerticalFlipOp> op(new RandomVerticalFlipOp(0.5));
|
||||
Status s = op->Compute(input_tensor_, &input_tensor_);
|
||||
EXPECT_TRUE(op->OneToOne());
|
||||
Status s = op->Compute(input_tensor_row, &output_tensor_row);
|
||||
EXPECT_TRUE(s.IsOk());
|
||||
CheckImageShapeAndData(input_tensor_, kFlipVertical);
|
||||
MS_LOG(INFO) << "testVerticalFlip end.";
|
||||
|
|
|
@ -18,13 +18,14 @@ Testing RandomCrop op in DE
|
|||
import numpy as np
|
||||
|
||||
import mindspore.dataset.transforms.py_transforms
|
||||
import mindspore.dataset.transforms.c_transforms as ops
|
||||
import mindspore.dataset.vision.c_transforms as c_vision
|
||||
import mindspore.dataset.vision.py_transforms as py_vision
|
||||
import mindspore.dataset.vision.utils as mode
|
||||
import mindspore.dataset as ds
|
||||
from mindspore import log as logger
|
||||
from util import save_and_check_md5, visualize_list, config_get_set_seed, \
|
||||
config_get_set_num_parallel_workers
|
||||
config_get_set_num_parallel_workers, diff_mse
|
||||
|
||||
|
||||
GENERATE_GOLDEN = False
|
||||
|
@ -541,6 +542,30 @@ def test_random_crop_comp(plot=False):
|
|||
if plot:
|
||||
visualize_list(image_c_cropped, image_py_cropped, visualize_mode=2)
|
||||
|
||||
def test_random_crop_09_c():
|
||||
"""
|
||||
Test RandomCrop with different fields.
|
||||
"""
|
||||
logger.info("Test RandomCrop with different fields.")
|
||||
|
||||
data = ds.TFRecordDataset(DATA_DIR, SCHEMA_DIR, columns_list=["image"], shuffle=False)
|
||||
data = data.map(operations=ops.Duplicate(), input_columns=["image"],
|
||||
output_columns=["image", "image_copy"], column_order=["image", "image_copy"])
|
||||
random_crop_op = c_vision.RandomCrop([512, 512], [200, 200, 200, 200])
|
||||
decode_op = c_vision.Decode()
|
||||
|
||||
data = data.map(operations=decode_op, input_columns=["image"])
|
||||
data = data.map(operations=decode_op, input_columns=["image_copy"])
|
||||
data = data.map(operations=random_crop_op, input_columns=["image", "image_copy"])
|
||||
|
||||
num_iter = 0
|
||||
for data1 in data.create_dict_iterator(num_epochs=1, output_numpy=True):
|
||||
image = data1["image"]
|
||||
image_copy = data1["image_copy"]
|
||||
mse = diff_mse(image, image_copy)
|
||||
assert mse == 0
|
||||
num_iter += 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_random_crop_01_c()
|
||||
|
@ -563,3 +588,4 @@ if __name__ == "__main__":
|
|||
test_random_crop_op_c(True)
|
||||
test_random_crop_op_py(True)
|
||||
test_random_crop_comp(True)
|
||||
test_random_crop_09_c()
|
||||
|
|
|
@ -19,6 +19,7 @@ import numpy as np
|
|||
import cv2
|
||||
|
||||
import mindspore.dataset.transforms.py_transforms
|
||||
import mindspore.dataset.transforms.c_transforms as ops
|
||||
import mindspore.dataset.vision.c_transforms as c_vision
|
||||
import mindspore.dataset.vision.py_transforms as py_vision
|
||||
import mindspore.dataset.vision.utils as mode
|
||||
|
@ -405,6 +406,31 @@ def test_random_crop_and_resize_06():
|
|||
logger.info("Got an exception in DE: {}".format(str(e)))
|
||||
assert "Argument scale[1] with value 2 is not of type [<class 'float'>, <class 'int'>]" in str(e)
|
||||
|
||||
def test_random_crop_and_resize_07():
|
||||
"""
|
||||
Test RandomCropAndResize with different fields.
|
||||
"""
|
||||
logger.info("Test RandomCropAndResize with different fields.")
|
||||
|
||||
data = ds.TFRecordDataset(DATA_DIR, SCHEMA_DIR, columns_list=["image"], shuffle=False)
|
||||
data = data.map(operations=ops.Duplicate(), input_columns=["image"],
|
||||
output_columns=["image", "image_copy"], column_order=["image", "image_copy"])
|
||||
random_crop_and_resize_op = c_vision.RandomResizedCrop((256, 512), (2, 2), (1, 3))
|
||||
decode_op = c_vision.Decode()
|
||||
|
||||
data = data.map(operations=decode_op, input_columns=["image"])
|
||||
data = data.map(operations=decode_op, input_columns=["image_copy"])
|
||||
data = data.map(operations=random_crop_and_resize_op, input_columns=["image", "image_copy"])
|
||||
|
||||
num_iter = 0
|
||||
for data1 in data.create_dict_iterator(num_epochs=1, output_numpy=True):
|
||||
image = data1["image"]
|
||||
image_copy = data1["image_copy"]
|
||||
mse = diff_mse(image, image_copy)
|
||||
logger.info("image_{}, mse: {}".format(num_iter + 1, mse))
|
||||
assert mse == 0
|
||||
num_iter += 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_random_crop_and_resize_callable()
|
||||
|
@ -420,3 +446,4 @@ if __name__ == "__main__":
|
|||
test_random_crop_and_resize_05_py()
|
||||
test_random_crop_and_resize_06()
|
||||
test_random_crop_and_resize_comp(True)
|
||||
test_random_crop_and_resize_07()
|
||||
|
|
|
@ -18,6 +18,7 @@ Testing the random horizontal flip op in DE
|
|||
import numpy as np
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.py_transforms
|
||||
import mindspore.dataset.transforms.c_transforms as ops
|
||||
import mindspore.dataset.vision.c_transforms as c_vision
|
||||
import mindspore.dataset.vision.py_transforms as py_vision
|
||||
from mindspore import log as logger
|
||||
|
@ -208,6 +209,31 @@ def test_random_horizontal_comp(plot=False):
|
|||
if plot:
|
||||
visualize_list(images_list_c, images_list_py, visualize_mode=2)
|
||||
|
||||
def test_random_horizontal_op_1():
|
||||
"""
|
||||
Test RandomHorizontalFlip with different fields.
|
||||
"""
|
||||
logger.info("Test RandomHorizontalFlip with different fields.")
|
||||
|
||||
data = ds.TFRecordDataset(DATA_DIR, SCHEMA_DIR, columns_list=["image"], shuffle=False)
|
||||
data = data.map(operations=ops.Duplicate(), input_columns=["image"],
|
||||
output_columns=["image", "image_copy"], column_order=["image", "image_copy"])
|
||||
random_horizontal_op = c_vision.RandomHorizontalFlip(1.0)
|
||||
decode_op = c_vision.Decode()
|
||||
|
||||
data = data.map(operations=decode_op, input_columns=["image"])
|
||||
data = data.map(operations=decode_op, input_columns=["image_copy"])
|
||||
data = data.map(operations=random_horizontal_op, input_columns=["image", "image_copy"])
|
||||
|
||||
num_iter = 0
|
||||
for data1 in data.create_dict_iterator(num_epochs=1, output_numpy=True):
|
||||
image = data1["image"]
|
||||
image_copy = data1["image_copy"]
|
||||
mse = diff_mse(image, image_copy)
|
||||
logger.info("image_{}, mse: {}".format(num_iter + 1, mse))
|
||||
assert mse == 0
|
||||
num_iter += 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_random_horizontal_op(plot=True)
|
||||
|
@ -216,3 +242,4 @@ if __name__ == "__main__":
|
|||
test_random_horizontal_invalid_prob_c()
|
||||
test_random_horizontal_invalid_prob_py()
|
||||
test_random_horizontal_comp(plot=True)
|
||||
test_random_horizontal_op_1()
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
Testing RandomResize op in DE
|
||||
"""
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.c_transforms as ops
|
||||
import mindspore.dataset.vision.c_transforms as vision
|
||||
from mindspore import log as logger
|
||||
from util import visualize_list, save_and_check_md5, \
|
||||
from util import visualize_list, save_and_check_md5, diff_mse, \
|
||||
config_get_set_seed, config_get_set_num_parallel_workers
|
||||
|
||||
DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"]
|
||||
|
@ -77,7 +78,33 @@ def test_random_resize_md5():
|
|||
ds.config.set_seed(original_seed)
|
||||
ds.config.set_num_parallel_workers(original_num_parallel_workers)
|
||||
|
||||
def test_random_resize_op_1():
|
||||
"""
|
||||
Test RandomResize with different fields.
|
||||
"""
|
||||
logger.info("Test RandomResize with different fields.")
|
||||
|
||||
data = ds.TFRecordDataset(DATA_DIR, SCHEMA_DIR, columns_list=["image"], shuffle=False)
|
||||
data = data.map(operations=ops.Duplicate(), input_columns=["image"],
|
||||
output_columns=["image", "image_copy"], column_order=["image", "image_copy"])
|
||||
resize_op = vision.RandomResize(10)
|
||||
decode_op = vision.Decode()
|
||||
|
||||
data = data.map(operations=decode_op, input_columns=["image"])
|
||||
data = data.map(operations=decode_op, input_columns=["image_copy"])
|
||||
data = data.map(operations=resize_op, input_columns=["image", "image_copy"])
|
||||
|
||||
num_iter = 0
|
||||
for data1 in data.create_dict_iterator(num_epochs=1, output_numpy=True):
|
||||
image = data1["image"]
|
||||
image_copy = data1["image_copy"]
|
||||
mse = diff_mse(image, image_copy)
|
||||
logger.info("image_{}, mse: {}".format(num_iter + 1, mse))
|
||||
assert mse == 0
|
||||
num_iter += 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_random_resize_op(plot=True)
|
||||
test_random_resize_md5()
|
||||
test_random_resize_op_1()
|
||||
|
|
|
@ -18,6 +18,7 @@ Testing the random vertical flip op in DE
|
|||
import numpy as np
|
||||
import mindspore.dataset as ds
|
||||
import mindspore.dataset.transforms.py_transforms
|
||||
import mindspore.dataset.transforms.c_transforms as ops
|
||||
import mindspore.dataset.vision.c_transforms as c_vision
|
||||
import mindspore.dataset.vision.py_transforms as py_vision
|
||||
from mindspore import log as logger
|
||||
|
@ -208,6 +209,31 @@ def test_random_vertical_comp(plot=False):
|
|||
if plot:
|
||||
visualize_list(images_list_c, images_list_py, visualize_mode=2)
|
||||
|
||||
def test_random_vertical_op_1():
|
||||
"""
|
||||
Test RandomVerticalFlip with different fields.
|
||||
"""
|
||||
logger.info("Test RandomVerticalFlip with different fields.")
|
||||
|
||||
data = ds.TFRecordDataset(DATA_DIR, SCHEMA_DIR, columns_list=["image"], shuffle=False)
|
||||
data = data.map(operations=ops.Duplicate(), input_columns=["image"],
|
||||
output_columns=["image", "image_copy"], column_order=["image", "image_copy"])
|
||||
random_vertical_op = c_vision.RandomVerticalFlip(1.0)
|
||||
decode_op = c_vision.Decode()
|
||||
|
||||
data = data.map(operations=decode_op, input_columns=["image"])
|
||||
data = data.map(operations=decode_op, input_columns=["image_copy"])
|
||||
data = data.map(operations=random_vertical_op, input_columns=["image", "image_copy"])
|
||||
|
||||
num_iter = 0
|
||||
for data1 in data.create_dict_iterator(num_epochs=1, output_numpy=True):
|
||||
image = data1["image"]
|
||||
image_copy = data1["image_copy"]
|
||||
mse = diff_mse(image, image_copy)
|
||||
logger.info("image_{}, mse: {}".format(num_iter + 1, mse))
|
||||
assert mse == 0
|
||||
num_iter += 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_random_vertical_op(plot=True)
|
||||
|
@ -216,3 +242,4 @@ if __name__ == "__main__":
|
|||
test_random_vertical_invalid_prob_c()
|
||||
test_random_vertical_invalid_prob_py()
|
||||
test_random_vertical_comp(plot=True)
|
||||
test_random_vertical_op_1()
|
||||
|
|
Loading…
Reference in New Issue