forked from mindspore-Ecosystem/mindspore
supporting cpp unit tests for random_resize_with_bbox_op and resize_with_bbox_op.
This commit is contained in:
parent
b23fc4e492
commit
b2bfb0342b
|
@ -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
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* 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.";
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* 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.";
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Loading…
Reference in New Issue