Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
3322e65d
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
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看板
提交
3322e65d
编写于
4月 24, 2020
作者:
A
Adel Shafiei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added ut for uniform augment C++ op
上级
4f612ae0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
64 addition
and
2 deletion
+64
-2
mindspore/ccsrc/mindrecord/common/shard_utils.cc
mindspore/ccsrc/mindrecord/common/shard_utils.cc
+1
-1
mindspore/ccsrc/mindrecord/io/shard_reader.cc
mindspore/ccsrc/mindrecord/io/shard_reader.cc
+1
-1
tests/ut/python/dataset/test_uniform_augment.py
tests/ut/python/dataset/test_uniform_augment.py
+62
-0
未找到文件。
mindspore/ccsrc/mindrecord/common/shard_utils.cc
浏览文件 @
3322e65d
...
...
@@ -39,7 +39,7 @@ std::vector<std::string> StringSplit(const std::string &field, char separator) {
}
s_pos
=
e_pos
+
1
;
}
return
std
::
move
(
res
)
;
return
res
;
}
bool
ValidateFieldName
(
const
std
::
string
&
str
)
{
...
...
mindspore/ccsrc/mindrecord/io/shard_reader.cc
浏览文件 @
3322e65d
...
...
@@ -914,7 +914,7 @@ vector<std::string> ShardReader::GetAllColumns() {
}
else
{
columns
=
selected_columns_
;
}
return
std
::
move
(
columns
)
;
return
columns
;
}
MSRStatus
ShardReader
::
CreateTasksByBlock
(
const
std
::
vector
<
std
::
tuple
<
int
,
int
,
int
,
uint64_t
>>
&
row_group_summary
,
...
...
tests/ut/python/dataset/test_uniform_augment.py
浏览文件 @
3322e65d
...
...
@@ -18,6 +18,7 @@ import matplotlib.pyplot as plt
from
mindspore
import
log
as
logger
import
mindspore.dataset.engine
as
de
import
mindspore.dataset.transforms.vision.py_transforms
as
F
import
mindspore.dataset.transforms.vision.c_transforms
as
C
DATA_DIR
=
"../data/dataset/testImageNetData/train/"
...
...
@@ -101,7 +102,68 @@ def test_uniform_augment(plot=False, num_ops=2):
if
plot
:
visualize
(
images_original
,
images_ua
)
def
test_cpp_uniform_augment
(
plot
=
False
,
num_ops
=
2
):
"""
Test UniformAugment
"""
logger
.
info
(
"Test CPP UniformAugment"
)
# Original Images
ds
=
de
.
ImageFolderDatasetV2
(
dataset_dir
=
DATA_DIR
,
shuffle
=
False
)
transforms_original
=
[
C
.
Decode
(),
C
.
Resize
(
size
=
[
224
,
224
]),
F
.
ToTensor
()]
ds_original
=
ds
.
map
(
input_columns
=
"image"
,
operations
=
transforms_original
)
ds_original
=
ds_original
.
batch
(
512
)
for
idx
,
(
image
,
label
)
in
enumerate
(
ds_original
):
if
idx
==
0
:
images_original
=
np
.
transpose
(
image
,
(
0
,
2
,
3
,
1
))
else
:
images_original
=
np
.
append
(
images_original
,
np
.
transpose
(
image
,
(
0
,
2
,
3
,
1
)),
axis
=
0
)
# UniformAugment Images
ds
=
de
.
ImageFolderDatasetV2
(
dataset_dir
=
DATA_DIR
,
shuffle
=
False
)
transforms_ua
=
[
C
.
RandomCrop
(
size
=
[
224
,
224
],
padding
=
[
32
,
32
,
32
,
32
]),
C
.
RandomHorizontalFlip
(),
C
.
RandomVerticalFlip
(),
C
.
RandomColorAdjust
(),
C
.
RandomRotation
(
degrees
=
45
)]
uni_aug
=
C
.
UniformAugment
(
operations
=
transforms_ua
,
num_ops
=
num_ops
)
transforms_all
=
[
C
.
Decode
(),
C
.
Resize
(
size
=
[
224
,
224
]),
uni_aug
,
F
.
ToTensor
()]
ds_ua
=
ds
.
map
(
input_columns
=
"image"
,
operations
=
transforms_all
,
num_parallel_workers
=
1
)
ds_ua
=
ds_ua
.
batch
(
512
)
for
idx
,
(
image
,
label
)
in
enumerate
(
ds_ua
):
if
idx
==
0
:
images_ua
=
np
.
transpose
(
image
,
(
0
,
2
,
3
,
1
))
else
:
images_ua
=
np
.
append
(
images_ua
,
np
.
transpose
(
image
,
(
0
,
2
,
3
,
1
)),
axis
=
0
)
if
plot
:
visualize
(
images_original
,
images_ua
)
num_samples
=
images_original
.
shape
[
0
]
mse
=
np
.
zeros
(
num_samples
)
for
i
in
range
(
num_samples
):
mse
[
i
]
=
np
.
mean
((
images_ua
[
i
]
-
images_original
[
i
])
**
2
)
logger
.
info
(
"MSE= {}"
.
format
(
str
(
np
.
mean
(
mse
))))
if
__name__
==
"__main__"
:
test_uniform_augment
(
num_ops
=
1
)
test_cpp_uniform_augment
(
num_ops
=
1
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录