!2982 supporting cpp unit tests for randomresizewithbbox and resizewithbbox
Merge pull request !2982 from ava/CPP_test3pull/2982/MERGE
commit
2c3c204b14
@ -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.";
|
||||
}
|
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 60 KiB |
Loading…
Reference in new issue