Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
68c3c73f
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看板
提交
68c3c73f
编写于
6月 11, 2020
作者:
P
panfengfeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update mobilenetV2 dataset codes
上级
7ffcc606
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
12 deletion
+19
-12
example/mobilenetv2_imagenet/src/dataset.py
example/mobilenetv2_imagenet/src/dataset.py
+19
-12
未找到文件。
example/mobilenetv2_imagenet/src/dataset.py
浏览文件 @
68c3c73f
...
...
@@ -37,24 +37,31 @@ def create_dataset(dataset_path, do_train, config, platform, repeat_num=1, batch
if
platform
==
"Ascend"
:
rank_size
=
int
(
os
.
getenv
(
"RANK_SIZE"
))
rank_id
=
int
(
os
.
getenv
(
"RANK_ID"
))
if
rank_size
==
1
:
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
)
if
do_train
:
if
rank_size
==
1
:
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
)
else
:
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
,
num_shards
=
rank_size
,
shard_id
=
rank_id
)
else
:
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
,
num_shards
=
rank_size
,
shard_id
=
rank_id
)
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
False
)
elif
platform
==
"GPU"
:
if
do_train
:
from
mindspore.communication.management
import
get_rank
,
get_group_size
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
True
,
num_shards
=
get_group_size
(),
shard_id
=
get_rank
())
else
:
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
Tru
e
)
ds
=
de
.
ImageFolderDatasetV2
(
dataset_path
,
num_parallel_workers
=
8
,
shuffle
=
Fals
e
)
else
:
raise
ValueError
(
"Unsupport platform."
)
resize_height
=
config
.
image_height
resize_width
=
config
.
image_width
buffer_size
=
1000
if
do_train
:
buffer_size
=
20480
# apply shuffle operations
ds
=
ds
.
shuffle
(
buffer_size
=
buffer_size
)
# define map operations
decode_op
=
C
.
Decode
()
...
...
@@ -63,23 +70,23 @@ def create_dataset(dataset_path, do_train, config, platform, repeat_num=1, batch
resize_op
=
C
.
Resize
((
256
,
256
))
center_crop
=
C
.
CenterCrop
(
resize_width
)
r
escale
_op
=
C
.
RandomColorAdjust
(
brightness
=
0.4
,
contrast
=
0.4
,
saturation
=
0.4
)
r
andom_color
_op
=
C
.
RandomColorAdjust
(
brightness
=
0.4
,
contrast
=
0.4
,
saturation
=
0.4
)
normalize_op
=
C
.
Normalize
(
mean
=
[
0.485
*
255
,
0.456
*
255
,
0.406
*
255
],
std
=
[
0.229
*
255
,
0.224
*
255
,
0.225
*
255
])
change_swap_op
=
C
.
HWC2CHW
()
transform_uniform
=
[
horizontal_flip_op
,
random_color_op
]
uni_aug
=
C
.
UniformAugment
(
operations
=
transform_uniform
,
num_ops
=
2
)
if
do_train
:
trans
=
[
resize_crop_op
,
horizontal_flip_op
,
rescale_op
,
normalize_op
,
change_swap_op
]
trans
=
[
resize_crop_op
,
uni_aug
,
normalize_op
,
change_swap_op
]
else
:
trans
=
[
decode_op
,
resize_op
,
center_crop
,
normalize_op
,
change_swap_op
]
type_cast_op
=
C2
.
TypeCast
(
mstype
.
int32
)
ds
=
ds
.
map
(
input_columns
=
"image"
,
operations
=
trans
,
num_parallel_workers
=
8
)
ds
=
ds
.
map
(
input_columns
=
"image"
,
operations
=
trans
,
num_parallel_workers
=
16
)
ds
=
ds
.
map
(
input_columns
=
"label"
,
operations
=
type_cast_op
,
num_parallel_workers
=
8
)
# apply shuffle operations
ds
=
ds
.
shuffle
(
buffer_size
=
buffer_size
)
# apply batch operations
ds
=
ds
.
batch
(
batch_size
,
drop_remainder
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录