!12810 dataset: Add IR vision error input tests, plus other UT updates

From: @cathwong
Reviewed-by: 
Signed-off-by:
pull/12810/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 7f71525b0a

@ -76,8 +76,8 @@ TEST_F(MindDataTestPipeline, TestImageFolderWithSamplers) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -239,7 +239,8 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess2) {
// num_shards=4, shard_id=0, shuffle=false, num_samplers=0, seed=0, offset=-1, even_dist=true
Sampler *sampler = new DistributedSampler(4, 0, false, 0, 0, -1, true);
EXPECT_NE(sampler, nullptr);
// Note that with new, we have to explicitly delete the allocated object as shown below.
// Note: No need to check for output after calling API class constructor
// Create an ImageFolder Dataset
std::string folder_path = datasets_root_path_ + "/testPK/data/";
@ -261,6 +262,9 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess2) {
EXPECT_EQ(i, 11);
iter->Stop();
// Delete allocated objects with raw pointers
delete sampler;
}
TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess3) {
@ -318,7 +322,8 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerFail2) {
// num_shards=4, shard_id=0, shuffle=false, num_samplers=0, seed=0, offset=5, even_dist=true
// offset=5 which is greater than num_shards=4 --> will fail later
Sampler *sampler = new DistributedSampler(4, 0, false, 0, 0, 5, false);
EXPECT_NE(sampler, nullptr);
// Note that with new, we have to explicitly delete the allocated object as shown below.
// Note: No need to check for output after calling API class constructor
// Create an ImageFolder Dataset
std::string folder_path = datasets_root_path_ + "/testPK/data/";
@ -328,6 +333,9 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerFail2) {
// Iterate will fail because sampler is not initiated successfully.
std::shared_ptr<Iterator> iter = ds->CreateIterator();
EXPECT_EQ(iter, nullptr);
// Delete allocated objects with raw pointers
delete sampler;
}
TEST_F(MindDataTestPipeline, TestDistributedSamplerFail3) {

File diff suppressed because it is too large Load Diff

@ -30,7 +30,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess1Shr) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestBoundingBoxAugmentSuccess1Shr.";
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
@ -54,8 +55,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess1Shr) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -68,11 +69,13 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess2Auto) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestBoundingBoxAugmentSuccess2Auto.";
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
// Use auto for raw pointers
// Note that with auto and new, we have to explicitly delete the allocated object as shown below.
auto random_rotation_op(new vision::RandomRotation({90.0}));
auto bound_box_augment_op(new vision::BoundingBoxAugment({random_rotation_op}, 1.0));
@ -92,21 +95,26 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess2Auto) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
EXPECT_EQ(i, 3);
// Manually terminate the pipeline
iter->Stop();
// Delete allocated objects with raw pointers
delete random_rotation_op;
delete bound_box_augment_op;
}
TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess3Obj) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestBoundingBoxAugmentSuccess3Obj.";
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
@ -130,8 +138,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentSuccess3Obj) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -145,7 +153,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentFail1) {
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
@ -169,7 +178,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentFail2) {
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
@ -193,7 +203,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentFail3) {
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create BoundingBoxAugment op with invalid nullptr transform
@ -214,7 +225,8 @@ TEST_F(MindDataTestPipeline, TestBoundingBoxAugmentFail4) {
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops

@ -46,11 +46,11 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess1) {
// Create objects for the tensor ops
std::shared_ptr<TensorTransform> rescale(new mindspore::dataset::vision::Rescale(1.0, 0.0));
EXPECT_NE(rescale, nullptr);
// Note: No need to check for output after calling API class constructor
// Convert to the same type
std::shared_ptr<TensorTransform> type_cast(new transforms::TypeCast("uint8"));
EXPECT_NE(type_cast, nullptr);
// Note: No need to check for output after calling API class constructor
ds = ds->Map({rescale, type_cast}, {"image"});
EXPECT_NE(ds, nullptr);
@ -81,7 +81,7 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess2) {
// Create objects for the tensor ops
std::shared_ptr<TensorTransform> rescale(new mindspore::dataset::vision::Rescale(1.0 / 255, 1.0));
EXPECT_NE(rescale, nullptr);
// Note: No need to check for output after calling API class constructor
ds = ds->Map({rescale}, {"image"});
EXPECT_NE(ds, nullptr);
@ -98,8 +98,8 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess2) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -109,14 +109,6 @@ TEST_F(MindDataTestPipeline, TestRescaleSucess2) {
iter->Stop();
}
TEST_F(MindDataTestPipeline, TestRescaleFail) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRescaleFail with invalid params.";
// FIXME: For error tests, need to check for failure from CreateIterator execution
// incorrect negative rescale parameter
std::shared_ptr<TensorTransform> rescale(new mindspore::dataset::vision::Rescale(-1.0, 0.0));
EXPECT_NE(rescale, nullptr);
}
TEST_F(MindDataTestPipeline, TestResize1) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestResize1 with single integer input.";
// Create an ImageFolder Dataset
@ -131,7 +123,7 @@ TEST_F(MindDataTestPipeline, TestResize1) {
// Create resize object with single integer input
std::shared_ptr<TensorTransform> resize_op(new vision::Resize({30}));
EXPECT_NE(resize_op, nullptr);
// Note: No need to check for output after calling API class constructor
// Create a Map operation on ds
ds = ds->Map({resize_op});
@ -154,8 +146,8 @@ TEST_F(MindDataTestPipeline, TestResize1) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -165,33 +157,18 @@ TEST_F(MindDataTestPipeline, TestResize1) {
iter->Stop();
}
TEST_F(MindDataTestPipeline, TestResizeFail) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestResize with invalid parameters.";
// FIXME: For error tests, need to check for failure from CreateIterator execution
// negative resize value
std::shared_ptr<TensorTransform> resize_op1(new mindspore::dataset::vision::Resize({30, -30}));
EXPECT_NE(resize_op1, nullptr);
// zero resize value
std::shared_ptr<TensorTransform> resize_op2(new mindspore::dataset::vision::Resize({0, 30}));
EXPECT_NE(resize_op2, nullptr);
// resize with 3 values
std::shared_ptr<TensorTransform> resize_op3(new mindspore::dataset::vision::Resize({30, 20, 10}));
EXPECT_NE(resize_op3, nullptr);
}
TEST_F(MindDataTestPipeline, TestResizeWithBBoxSuccess) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestResizeWithBBoxSuccess.";
// Create an VOC Dataset
std::string folder_path = datasets_root_path_ + "/testVOC2012_2";
std::shared_ptr<Dataset> ds = VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
std::shared_ptr<Dataset> ds =
VOC(folder_path, "Detection", "train", {}, true, std::make_shared<SequentialSampler>(0, 3));
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
std::shared_ptr<TensorTransform> resize_with_bbox_op(new vision::ResizeWithBBox({30}));
EXPECT_NE(resize_with_bbox_op, nullptr);
std::shared_ptr<TensorTransform> resize_with_bbox_op1(new vision::ResizeWithBBox({30, 30}));
EXPECT_NE(resize_with_bbox_op1, nullptr);
// Note: No need to check for output after calling API class constructor
// Create a Map operation on ds
ds = ds->Map({resize_with_bbox_op, resize_with_bbox_op1}, {"image", "bbox"}, {"image", "bbox"}, {"image", "bbox"});
@ -209,8 +186,8 @@ TEST_F(MindDataTestPipeline, TestResizeWithBBoxSuccess) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -218,38 +195,3 @@ TEST_F(MindDataTestPipeline, TestResizeWithBBoxSuccess) {
// Manually terminate the pipeline
iter->Stop();
}
TEST_F(MindDataTestPipeline, TestResizeWithBBoxFail) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestResizeWithBBoxFail with invalid parameters.";
// FIXME: For error tests, need to check for failure from CreateIterator execution
// Testing negative resize value
std::shared_ptr<TensorTransform> resize_with_bbox_op(new vision::ResizeWithBBox({10, -10}));
EXPECT_NE(resize_with_bbox_op, nullptr);
// Testing negative resize value
std::shared_ptr<TensorTransform> resize_with_bbox_op1(new vision::ResizeWithBBox({-10}));
EXPECT_NE(resize_with_bbox_op1, nullptr);
// Testinig zero resize value
std::shared_ptr<TensorTransform> resize_with_bbox_op2(new vision::ResizeWithBBox({0, 10}));
EXPECT_NE(resize_with_bbox_op2, nullptr);
// Testing resize with 3 values
std::shared_ptr<TensorTransform> resize_with_bbox_op3(new vision::ResizeWithBBox({10, 10, 10}));
EXPECT_NE(resize_with_bbox_op3, nullptr);
}
TEST_F(MindDataTestPipeline, TestVisionOperationName) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestVisionOperationName.";
std::string correct_name;
// Create object for the tensor op, and check the name
/* FIXME - Update and move test to IR level
std::shared_ptr<TensorOperation> random_vertical_flip_op = vision::RandomVerticalFlip(0.5);
correct_name = "RandomVerticalFlip";
EXPECT_EQ(correct_name, random_vertical_flip_op->Name());
// Create object for the tensor op, and check the name
std::shared_ptr<TensorOperation> softDvpp_decode_resize_jpeg_op = vision::SoftDvppDecodeResizeJpeg({1, 1});
correct_name = "SoftDvppDecodeResizeJpeg";
EXPECT_EQ(correct_name, softDvpp_decode_resize_jpeg_op->Name());
*/
}

@ -66,8 +66,8 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess1Shr) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -87,6 +87,7 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess2Auto) {
// Create objects for the tensor ops
// Use auto for raw pointers
// Note that with auto and new, we have to explicitly delete the allocated object as shown below.
// Valid case: TensorTransform is not null and probability is between (0,1)
auto invert_op(new vision::Invert());
auto equalize_op(new vision::Equalize());
@ -118,8 +119,8 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess2Auto) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -127,6 +128,12 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess2Auto) {
// Manually terminate the pipeline
iter->Stop();
// Delete allocated objects with raw pointers
delete invert_op;
delete equalize_op;
delete resize_op;
delete random_select_subpolicy_op;
}
TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess3Obj) {
@ -169,8 +176,8 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess3Obj) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -221,8 +228,8 @@ TEST_F(MindDataTestPipeline, TestRandomSelectSubpolicySuccess4MultiPolicy) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}

@ -36,9 +36,9 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess1) {
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
std::shared_ptr<TensorTransform> soft_dvpp_decode_random_crop_resize_jpeg(new
vision::SoftDvppDecodeRandomCropResizeJpeg({500}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg, nullptr);
std::shared_ptr<TensorTransform> soft_dvpp_decode_random_crop_resize_jpeg(
new vision::SoftDvppDecodeRandomCropResizeJpeg({500}));
// Note: No need to check for output after calling API class constructor
// Create a Map operation on ds
ds = ds->Map({soft_dvpp_decode_random_crop_resize_jpeg}, {"image"});
@ -78,9 +78,9 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess2) {
EXPECT_NE(ds, nullptr);
// Create objects for the tensor ops
std::shared_ptr<TensorTransform> soft_dvpp_decode_random_crop_resize_jpeg(new
vision::SoftDvppDecodeRandomCropResizeJpeg({500, 600}, {0.25, 0.75}, {0.5, 1.25}, 20));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg, nullptr);
std::shared_ptr<TensorTransform> soft_dvpp_decode_random_crop_resize_jpeg(
new vision::SoftDvppDecodeRandomCropResizeJpeg({500, 600}, {0.25, 0.75}, {0.5, 1.25}, 20));
// Note: No need to check for output after calling API class constructor
// Create a Map operation on ds
ds = ds->Map({soft_dvpp_decode_random_crop_resize_jpeg}, {"image"});
@ -110,50 +110,6 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegSuccess2) {
iter->Stop();
}
TEST_F(MindDataTestPipeline, TestSoftDvppDecodeRandomCropResizeJpegFail) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestSoftDvppDecodeRandomCropResizeJpegFail with incorrect parameters.";
// FIXME: For error tests, need to check for failure from CreateIterator execution
// SoftDvppDecodeRandomCropResizeJpeg: size must only contain positive integers
auto soft_dvpp_decode_random_crop_resize_jpeg1(new vision::SoftDvppDecodeRandomCropResizeJpeg({-500, 600}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg1, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: size must only contain positive integers
auto soft_dvpp_decode_random_crop_resize_jpeg2(new vision::SoftDvppDecodeRandomCropResizeJpeg({-500}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg2, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: size must be a vector of one or two values
auto soft_dvpp_decode_random_crop_resize_jpeg3(new vision::SoftDvppDecodeRandomCropResizeJpeg({500, 600, 700}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg3, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: scale must be greater than or equal to 0
auto soft_dvpp_decode_random_crop_resize_jpeg4(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {-0.1, 0.9}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg4, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: scale must be in the format of (min, max)
auto soft_dvpp_decode_random_crop_resize_jpeg5(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {0.6, 0.2}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg5, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: scale must be a vector of two values
auto soft_dvpp_decode_random_crop_resize_jpeg6(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {0.5, 0.6, 0.7}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg6, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: ratio must be greater than or equal to 0
auto soft_dvpp_decode_random_crop_resize_jpeg7(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {0.5, 0.9}, {-0.2, 0.4}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg7, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: ratio must be in the format of (min, max)
auto soft_dvpp_decode_random_crop_resize_jpeg8(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {0.5, 0.9}, {0.4, 0.2}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg8, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: ratio must be a vector of two values
auto soft_dvpp_decode_random_crop_resize_jpeg9(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {0.5, 0.9}, {0.1, 0.2, 0.3}));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg9, nullptr);
// SoftDvppDecodeRandomCropResizeJpeg: max_attempts must be greater than or equal to 1
auto soft_dvpp_decode_random_crop_resize_jpeg10(new vision::SoftDvppDecodeRandomCropResizeJpeg({500}, {0.5, 0.9}, {0.1, 0.2}, 0));
EXPECT_NE(soft_dvpp_decode_random_crop_resize_jpeg10, nullptr);
}
TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegSuccess1) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestSoftDvppDecodeResizeJpegSuccess1 with single integer input.";
// Create an ImageFolder Dataset
@ -168,7 +124,7 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegSuccess1) {
// Create SoftDvppDecodeResizeJpeg object with single integer input
std::shared_ptr<TensorTransform> soft_dvpp_decode_resize_jpeg_op(new vision::SoftDvppDecodeResizeJpeg({1134}));
EXPECT_NE(soft_dvpp_decode_resize_jpeg_op, nullptr);
// Note: No need to check for output after calling API class constructor
// Create a Map operation on ds
ds = ds->Map({soft_dvpp_decode_resize_jpeg_op});
@ -206,7 +162,7 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegSuccess2) {
// Create SoftDvppDecodeResizeJpeg object with single integer input
std::shared_ptr<TensorTransform> soft_dvpp_decode_resize_jpeg_op(new vision::SoftDvppDecodeResizeJpeg({100, 200}));
EXPECT_NE(soft_dvpp_decode_resize_jpeg_op, nullptr);
// Note: No need to check for output after calling API class constructor
// Create a Map operation on ds
ds = ds->Map({soft_dvpp_decode_resize_jpeg_op});
@ -234,23 +190,3 @@ TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegSuccess2) {
// Manually terminate the pipeline
iter->Stop();
}
TEST_F(MindDataTestPipeline, TestSoftDvppDecodeResizeJpegFail) {
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestSoftDvppDecodeResizeJpegFail with incorrect size.";
// FIXME: For error tests, need to check for failure from CreateIterator execution
// CSoftDvppDecodeResizeJpeg: size must be a vector of one or two values
std::shared_ptr<TensorTransform> soft_dvpp_decode_resize_jpeg_op1(new vision::SoftDvppDecodeResizeJpeg({}));
EXPECT_NE(soft_dvpp_decode_resize_jpeg_op1, nullptr);
// SoftDvppDecodeResizeJpeg: size must be a vector of one or two values
std::shared_ptr<TensorTransform> soft_dvpp_decode_resize_jpeg_op2(new vision::SoftDvppDecodeResizeJpeg({1, 2, 3}));
EXPECT_NE(soft_dvpp_decode_resize_jpeg_op2, nullptr);
// SoftDvppDecodeResizeJpeg: size must only contain positive integers
std::shared_ptr<TensorTransform> soft_dvpp_decode_resize_jpeg_op3(new vision::SoftDvppDecodeResizeJpeg({20, -20}));
EXPECT_NE(soft_dvpp_decode_resize_jpeg_op3, nullptr);
// SoftDvppDecodeResizeJpeg: size must only contain positive integers
std::shared_ptr<TensorTransform> soft_dvpp_decode_resize_jpeg_op4(new vision::SoftDvppDecodeResizeJpeg({0}));
EXPECT_NE(soft_dvpp_decode_resize_jpeg_op4, nullptr);
}

@ -63,8 +63,8 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps1Shr) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -89,6 +89,7 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps2Auto) {
// Create objects for the tensor ops
// Use auto for raw pointers
// Note that with auto and new, we have to explicitly delete the allocated object as shown below.
auto resize_op(new vision::Resize({30, 30}));
auto random_crop_op(new vision::RandomCrop({28, 28}));
auto center_crop_op(new vision::CenterCrop({16, 16}));
@ -110,8 +111,8 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps2Auto) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}
@ -119,6 +120,12 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps2Auto) {
// Manually terminate the pipeline
iter->Stop();
// Delete allocated objects with raw pointers
delete resize_op;
delete random_crop_op;
delete center_crop_op;
delete uniform_aug_op;
}
TEST_F(MindDataTestPipeline, TestUniformAugWithOps3Obj) {
@ -157,8 +164,8 @@ TEST_F(MindDataTestPipeline, TestUniformAugWithOps3Obj) {
uint64_t i = 0;
while (row.size() != 0) {
i++;
// auto image = row["image"];
// MS_LOG(INFO) << "Tensor image shape: " << image->shape();
auto image = row["image"];
MS_LOG(INFO) << "Tensor image shape: " << image.Shape();
iter->GetNextRow(&row);
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save