|
- /**
- * Copyright 2020 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 "common/common.h"
- #include "common/cvop_common.h"
- #include "minddata/dataset/core/de_tensor.h"
- #include "minddata/dataset/include/execute.h"
- #include "minddata/dataset/include/transforms.h"
- #include "minddata/dataset/include/vision.h"
- #include "utils/log_adapter.h"
-
- using namespace mindspore::dataset;
- using mindspore::MsLogLevel::INFO;
- using mindspore::ExceptionType::NoExceptionType;
- using mindspore::LogStream;
-
- class MindDataTestExecute : public UT::CVOP::CVOpCommon {
- protected:
- MindDataTestExecute() : CVOpCommon() {}
-
- std::shared_ptr<Tensor> output_tensor_;
- };
-
- TEST_F(MindDataTestExecute, TestComposeTransforms) {
- MS_LOG(INFO) << "Doing TestComposeTransforms.";
-
- std::shared_ptr<mindspore::dataset::Tensor> de_tensor;
- mindspore::dataset::Tensor::CreateFromFile("data/dataset/apple.jpg", &de_tensor);
- auto image = mindspore::MSTensor(std::make_shared<DETensor>(de_tensor));
-
- // Transform params
- std::shared_ptr<TensorOperation> decode = vision::Decode();
- std::shared_ptr<TensorOperation> center_crop = vision::CenterCrop({30});
- std::shared_ptr<TensorOperation> rescale = vision::Rescale(1./3, 0.5);
-
- auto transform = Execute({decode, center_crop, rescale});
- Status rc = transform(image, &image);
-
- EXPECT_EQ(rc, Status::OK());
- EXPECT_EQ(30, image.Shape()[0]);
- EXPECT_EQ(30, image.Shape()[1]);
- }
|