提交 b2bfb034 编写于 作者: A avakh

supporting cpp unit tests for random_resize_with_bbox_op and resize_with_bbox_op.

上级 b23fc4e4
......@@ -42,6 +42,7 @@ SET(DE_UT_SRCS
random_horizontal_flip_op_test.cc
random_horizontal_flip_with_bbox_test.cc
random_resize_op_test.cc
random_resize_with_bbox_op_test.cc
random_rotation_op_test.cc
random_vertical_flip_op_test.cc
rename_op_test.cc
......@@ -50,6 +51,7 @@ SET(DE_UT_SRCS
rescale_op_test.cc
resize_bilinear_op_test.cc
resize_op_test.cc
resize_with_bbox_op_test.cc
schema_test.cc
shuffle_op_test.cc
stand_alone_samplers_test.cc
......
/**
* 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/bboxop_common.h"
#include "dataset/kernels/image/random_resize_with_bbox_op.h"
#include "utils/log_adapter.h"
#include "dataset/core/config_manager.h"
#include "dataset/core/global_context.h"
using namespace mindspore::dataset;
using mindspore::LogStream;
using mindspore::ExceptionType::NoExceptionType;
using mindspore::MsLogLevel::INFO;
const bool kSaveExpected = false;
const char kOpName[] = "RandomResizeWithBBox_C";
class MindDataTestRandomResizeWithBBoxOp : public UT::CVOP::BBOXOP::BBoxOpCommon {
protected:
MindDataTestRandomResizeWithBBoxOp() : BBoxOpCommon() {}
};
TEST_F(MindDataTestRandomResizeWithBBoxOp, TestOp) {
MS_LOG(INFO) << "Doing testRandomResizeWithBBox.";
//setting seed here
u_int32_t curr_seed = GlobalContext::config_manager()->seed();
GlobalContext::config_manager()->set_seed(120);
TensorTable results;
std::unique_ptr<RandomResizeWithBBoxOp> op(new RandomResizeWithBBoxOp(500));
for (const auto &tensor_row_ : images_and_annotations_) {
// selected a tensorRow
TensorRow output_row;
Status s = op->Compute(tensor_row_, &output_row);
EXPECT_TRUE(s.IsOk());
results.push_back(output_row);
}
if (kSaveExpected) {
SaveImagesWithAnnotations(FileType::kExpected, std::string(kOpName), results);
}
SaveImagesWithAnnotations(FileType::kActual, std::string(kOpName), results);
if (!kSaveExpected) {
CompareActualAndExpected(std::string(kOpName));
}
GlobalContext::config_manager()->set_seed(curr_seed);
MS_LOG(INFO) << "testRandomResizeWithBBox end.";
}
/**
* 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/bboxop_common.h"
#include "dataset/kernels/image/resize_with_bbox_op.h"
#include "utils/log_adapter.h"
using namespace mindspore::dataset;
using mindspore::LogStream;
using mindspore::ExceptionType::NoExceptionType;
using mindspore::MsLogLevel::INFO;
const bool kSaveExpected = false;
const char kOpName[] = "ResizeWithBBox_C";
class MindDataTestResizeWithBBoxOp : public UT::CVOP::BBOXOP::BBoxOpCommon {
protected:
MindDataTestResizeWithBBoxOp() : BBoxOpCommon() {}
};
TEST_F(MindDataTestResizeWithBBoxOp, TestOp) {
MS_LOG(INFO) << "Doing testResizeWithBBox.";
// resize
TensorTable results;
std::unique_ptr<ResizeWithBBoxOp> op(new ResizeWithBBoxOp(500));
for (const auto &tensor_row_ : images_and_annotations_) {
// selected a tensorRow
TensorRow output_row;
Status s = op->Compute(tensor_row_, &output_row);
EXPECT_TRUE(s.IsOk());
results.push_back(output_row);
}
if (kSaveExpected) {
SaveImagesWithAnnotations(FileType::kExpected, std::string(kOpName), results);
}
SaveImagesWithAnnotations(FileType::kActual, std::string(kOpName), results);
if (!kSaveExpected) {
CompareActualAndExpected(std::string(kOpName));
}
MS_LOG(INFO) << "testResizeWithBBox end.";
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册