Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
284cc910
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
284cc910
编写于
7月 06, 2020
作者:
I
islam_amin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
C++ UTs for RandomHorizontalFlipWithBBox and Bounding Box Augment
上级
9ba937b1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
110 addition
and
3 deletion
+110
-3
tests/ut/cpp/dataset/CMakeLists.txt
tests/ut/cpp/dataset/CMakeLists.txt
+2
-0
tests/ut/cpp/dataset/bounding_box_augment_op_test.cc
tests/ut/cpp/dataset/bounding_box_augment_op_test.cc
+52
-0
tests/ut/cpp/dataset/common/bboxop_common.cc
tests/ut/cpp/dataset/common/bboxop_common.cc
+6
-3
tests/ut/cpp/dataset/random_horizontal_flip_with_bbox_test.cc
...s/ut/cpp/dataset/random_horizontal_flip_with_bbox_test.cc
+50
-0
tests/ut/data/dataset/imagefolder/ExpectedBoundingBoxAugmentOp0.jpg
...ata/dataset/imagefolder/ExpectedBoundingBoxAugmentOp0.jpg
+0
-0
tests/ut/data/dataset/imagefolder/ExpectedRandomHorizontalFlipWithBBox0.jpg
...set/imagefolder/ExpectedRandomHorizontalFlipWithBBox0.jpg
+0
-0
未找到文件。
tests/ut/cpp/dataset/CMakeLists.txt
浏览文件 @
284cc910
...
...
@@ -11,6 +11,7 @@ SET(DE_UT_SRCS
interrupt_test.cc
image_folder_op_test.cc
buddy_test.cc
bounding_box_augment_op_test.cc
arena_test.cc
btree_test.cc
center_crop_op_test.cc
...
...
@@ -39,6 +40,7 @@ SET(DE_UT_SRCS
random_crop_and_resize_op_test.cc
random_color_adjust_op_test.cc
random_horizontal_flip_op_test.cc
random_horizontal_flip_with_bbox_test.cc
random_resize_op_test.cc
random_rotation_op_test.cc
random_vertical_flip_op_test.cc
...
...
tests/ut/cpp/dataset/bounding_box_augment_op_test.cc
0 → 100644
浏览文件 @
284cc910
/**
* 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/bounding_box_augment_op.h"
#include "dataset/kernels/image/random_rotation_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
[]
=
"BoundingBoxAugmentOp"
;
class
MindDataTestBoundingBoxAugmentOp
:
public
UT
::
CVOP
::
BBOXOP
::
BBoxOpCommon
{
protected:
MindDataTestBoundingBoxAugmentOp
()
:
UT
::
CVOP
::
BBOXOP
::
BBoxOpCommon
()
{}
};
TEST_F
(
MindDataTestBoundingBoxAugmentOp
,
TestOp
)
{
MS_LOG
(
INFO
)
<<
"Doing testBoundingBoxAugment."
;
TensorTable
results
;
std
::
unique_ptr
<
BoundingBoxAugmentOp
>
op
=
std
::
make_unique
<
BoundingBoxAugmentOp
>
(
std
::
make_shared
<
RandomRotationOp
>
(
90
,
90
),
1
);
for
(
const
auto
&
row
:
images_and_annotations_
)
{
TensorRow
output_row
;
Status
s
=
op
->
Compute
(
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
));
}
}
tests/ut/cpp/dataset/common/bboxop_common.cc
浏览文件 @
284cc910
...
...
@@ -66,17 +66,16 @@ void BBoxOpCommon::GetInputImagesAndAnnotations(const std::string &dir, std::siz
MS_LOG
(
ERROR
)
<<
"Images folder was not found : "
+
images_path
;
EXPECT_TRUE
(
dir_path
.
Exists
());
}
std
::
size_t
files_fetched
=
0
;
// get image file paths
while
(
image_dir_itr
->
hasNext
()
&&
files_fetched
<
num_of_samples
)
{
while
(
image_dir_itr
->
hasNext
())
{
Path
image_path
=
image_dir_itr
->
next
();
if
(
image_path
.
Extension
()
==
std
::
string
(
kImageExt
))
{
paths_to_fetch
.
push_back
(
image_path
.
toString
());
files_fetched
++
;
}
}
// sort fetched files
std
::
sort
(
paths_to_fetch
.
begin
(),
paths_to_fetch
.
end
());
std
::
size_t
files_fetched
=
0
;
for
(
const
auto
&
image_file
:
paths_to_fetch
)
{
std
::
string
image_ext
=
std
::
string
(
kImageExt
);
std
::
string
annot_file
=
image_file
;
...
...
@@ -100,6 +99,10 @@ void BBoxOpCommon::GetInputImagesAndAnnotations(const std::string &dir, std::siz
// add image and annotation to the tensor table
TensorRow
row_data
({
std
::
move
(
input_tensor_
),
std
::
move
(
annotation_tensor
)});
images_and_annotations_
.
push_back
(
row_data
);
files_fetched
++
;
if
(
files_fetched
==
num_of_samples
)
{
break
;
}
}
}
...
...
tests/ut/cpp/dataset/random_horizontal_flip_with_bbox_test.cc
0 → 100644
浏览文件 @
284cc910
/**
* 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_horizontal_flip_with_bbox_op.h"
#include "utils/log_adapter.h"
using
namespace
mindspore
::
dataset
;
using
mindspore
::
MsLogLevel
::
INFO
;
using
mindspore
::
ExceptionType
::
NoExceptionType
;
using
mindspore
::
LogStream
;
const
bool
kSaveExpected
=
false
;
const
char
kOpName
[]
=
"RandomHorizontalFlipWithBBox"
;
class
MindDataTestRandomHorizontalFlipWithBBoxOp
:
public
UT
::
CVOP
::
BBOXOP
::
BBoxOpCommon
{
protected:
MindDataTestRandomHorizontalFlipWithBBoxOp
()
:
UT
::
CVOP
::
BBOXOP
::
BBoxOpCommon
()
{}
};
TEST_F
(
MindDataTestRandomHorizontalFlipWithBBoxOp
,
TestOp
)
{
MS_LOG
(
INFO
)
<<
"Doing testRandomHorizontalFlipWithBBox."
;
TensorTable
results
;
std
::
unique_ptr
<
RandomHorizontalFlipWithBBoxOp
>
op
(
new
RandomHorizontalFlipWithBBoxOp
(
1
));
for
(
const
auto
&
row
:
images_and_annotations_
)
{
TensorRow
output_row
;
Status
s
=
op
->
Compute
(
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
));
}
}
tests/ut/data/dataset/imagefolder/ExpectedBoundingBoxAugmentOp0.jpg
0 → 100644
浏览文件 @
284cc910
74.6 KB
tests/ut/data/dataset/imagefolder/ExpectedRandomHorizontalFlipWithBBox0.jpg
0 → 100644
浏览文件 @
284cc910
76.1 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录