|
|
|
@ -294,7 +294,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchSuccess1) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(number_of_classes);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(number_of_classes);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -356,7 +356,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchSuccess2) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(number_of_classes);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(number_of_classes);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -415,7 +415,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchFail1) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -441,7 +441,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchFail2) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -467,7 +467,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchFail3) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -493,7 +493,7 @@ TEST_F(MindDataTestPipeline, TestCutMixBatchFail4) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -733,7 +733,7 @@ TEST_F(MindDataTestPipeline, TestMixUpBatchFail1) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -758,7 +758,7 @@ TEST_F(MindDataTestPipeline, TestMixUpBatchFail2) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -783,7 +783,7 @@ TEST_F(MindDataTestPipeline, TestMixUpBatchSuccess1) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -834,7 +834,7 @@ TEST_F(MindDataTestPipeline, TestMixUpBatchSuccess2) {
|
|
|
|
|
EXPECT_NE(ds, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> one_hot_op = transforms::OneHot(10);
|
|
|
|
|
std::shared_ptr<TensorTransform> one_hot_op = std::make_shared<transforms::OneHot>(10);
|
|
|
|
|
EXPECT_NE(one_hot_op, nullptr);
|
|
|
|
|
|
|
|
|
|
// Create a Map operation on ds
|
|
|
|
@ -2710,51 +2710,51 @@ TEST_F(MindDataTestPipeline, TestResize1) {
|
|
|
|
|
iter->Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestRescaleSucess1) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRescaleSucess1.";
|
|
|
|
|
// Create an ImageFolder Dataset
|
|
|
|
|
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
|
|
|
|
std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, SequentialSampler(0, 1));
|
|
|
|
|
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;
|
|
|
|
|
iter->GetNextRow(&row);
|
|
|
|
|
|
|
|
|
|
auto image = row["image"];
|
|
|
|
|
|
|
|
|
|
// Create objects for the tensor ops
|
|
|
|
|
std::shared_ptr<TensorOperation> rescale = mindspore::dataset::vision::Rescale(1.0, 0.0);
|
|
|
|
|
EXPECT_NE(rescale, nullptr);
|
|
|
|
|
|
|
|
|
|
// Convert to the same type
|
|
|
|
|
std::shared_ptr<TensorOperation> type_cast = transforms::TypeCast("uint8");
|
|
|
|
|
EXPECT_NE(type_cast, nullptr);
|
|
|
|
|
|
|
|
|
|
ds = ds->Map({rescale, type_cast}, {"image"});
|
|
|
|
|
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> iter1 = ds->CreateIterator();
|
|
|
|
|
EXPECT_NE(iter1, nullptr);
|
|
|
|
|
|
|
|
|
|
// Iterate the dataset and get each row1
|
|
|
|
|
std::unordered_map<std::string, mindspore::MSTensor> row1;
|
|
|
|
|
iter1->GetNextRow(&row1);
|
|
|
|
|
|
|
|
|
|
auto image1 = row1["image"];
|
|
|
|
|
|
|
|
|
|
// EXPECT_EQ(*image, *image1);
|
|
|
|
|
|
|
|
|
|
// Manually terminate the pipeline
|
|
|
|
|
iter1->Stop();
|
|
|
|
|
}
|
|
|
|
|
// TEST_F(MindDataTestPipeline, TestRescaleSucess1) {
|
|
|
|
|
// MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRescaleSucess1.";
|
|
|
|
|
// // Create an ImageFolder Dataset
|
|
|
|
|
// std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
|
|
|
|
// std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, SequentialSampler(0, 1));
|
|
|
|
|
// 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;
|
|
|
|
|
// iter->GetNextRow(&row);
|
|
|
|
|
//
|
|
|
|
|
// auto image = row["image"];
|
|
|
|
|
//
|
|
|
|
|
// // Create objects for the tensor ops
|
|
|
|
|
// std::shared_ptr<TensorOperation> rescale = mindspore::dataset::vision::Rescale(1.0, 0.0);
|
|
|
|
|
// EXPECT_NE(rescale, nullptr);
|
|
|
|
|
//
|
|
|
|
|
// // Convert to the same type
|
|
|
|
|
// std::shared_ptr<TensorTransform> type_cast = std::make_shared<transforms::TypeCast>("uint8");
|
|
|
|
|
// EXPECT_NE(type_cast, nullptr);
|
|
|
|
|
//
|
|
|
|
|
// ds = ds->Map({rescale, type_cast}, {"image"});
|
|
|
|
|
// 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> iter1 = ds->CreateIterator();
|
|
|
|
|
// EXPECT_NE(iter1, nullptr);
|
|
|
|
|
//
|
|
|
|
|
// // Iterate the dataset and get each row1
|
|
|
|
|
// std::unordered_map<std::string, mindspore::MSTensor> row1;
|
|
|
|
|
// iter1->GetNextRow(&row1);
|
|
|
|
|
//
|
|
|
|
|
// auto image1 = row1["image"];
|
|
|
|
|
//
|
|
|
|
|
// // EXPECT_EQ(*image, *image1);
|
|
|
|
|
//
|
|
|
|
|
// // Manually terminate the pipeline
|
|
|
|
|
// iter1->Stop();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
TEST_F(MindDataTestPipeline, TestRescaleSucess2) {
|
|
|
|
|
MS_LOG(INFO) << "Doing MindDataTestPipeline-TestRescaleSucess2 with different params.";
|
|
|
|
|