Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_77200941
mindspore
提交
913b5b03
M
mindspore
项目概览
2301_77200941
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
913b5b03
编写于
5月 29, 2020
作者:
U
unknown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify
上级
ec7cbb99
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
36 deletion
+20
-36
model_zoo/deeplabv3/src/backbone/__init__.py
model_zoo/deeplabv3/src/backbone/__init__.py
+8
-0
model_zoo/deeplabv3/src/backbone/resnet_deeplab.py
model_zoo/deeplabv3/src/backbone/resnet_deeplab.py
+3
-0
model_zoo/deeplabv3/src/ei_datasest.py
model_zoo/deeplabv3/src/ei_datasest.py
+1
-24
model_zoo/deeplabv3/src/md_dataset.py
model_zoo/deeplabv3/src/md_dataset.py
+2
-6
model_zoo/deeplabv3/train.py
model_zoo/deeplabv3/train.py
+6
-6
未找到文件。
model_zoo/deeplabv3/src/backbone/__init__.py
0 → 100644
浏览文件 @
913b5b03
from
.resnet_deeplab
import
Subsample
,
DepthwiseConv2dNative
,
SpaceToBatch
,
BatchToSpace
,
ResNetV1
,
\
RootBlockBeta
,
resnet50_dl
__all__
=
[
"Subsample"
,
"DepthwiseConv2dNative"
,
"SpaceToBatch"
,
"BatchToSpace"
,
"ResNetV1"
,
"RootBlockBeta"
,
"resnet50_dl"
]
\ No newline at end of file
model_zoo/deeplabv3/src/backbone/resnet_deeplab.py
浏览文件 @
913b5b03
...
@@ -532,3 +532,6 @@ class RootBlockBeta(nn.Cell):
...
@@ -532,3 +532,6 @@ class RootBlockBeta(nn.Cell):
x
=
self
.
conv2
(
x
)
x
=
self
.
conv2
(
x
)
x
=
self
.
conv3
(
x
)
x
=
self
.
conv3
(
x
)
return
x
return
x
class
resnet50_dl
(
fine_tune_batch_norm
=
False
):
return
ResNetV1
(
fine_tune_batch_norm
)
model_zoo/deeplabv3/src/ei_datasest.py
浏览文件 @
913b5b03
...
@@ -17,7 +17,7 @@ import abc
...
@@ -17,7 +17,7 @@ import abc
import
os
import
os
import
time
import
time
from
.utils.adapter
import
get_
manifest_samples
,
get_
raw_samples
,
read_image
from
.utils.adapter
import
get_raw_samples
,
read_image
class
BaseDataset
(
object
):
class
BaseDataset
(
object
):
...
@@ -62,29 +62,6 @@ class BaseDataset(object):
...
@@ -62,29 +62,6 @@ class BaseDataset(object):
pass
pass
class
HwVocManifestDataset
(
BaseDataset
):
"""
Create dataset with manifest data.
Args:
data_url (str): The path of data.
usage (str): Whether to use train or eval (default='train').
Returns:
Dataset.
"""
def
__init__
(
self
,
data_url
,
usage
=
"train"
):
super
().
__init__
(
data_url
,
usage
)
def
_load_samples
(
self
):
try
:
self
.
samples
=
get_manifest_samples
(
self
.
data_url
,
self
.
usage
)
except
Exception
as
e
:
print
(
"load HwVocManifestDataset samples failed!!!"
)
raise
e
class
HwVocRawDataset
(
BaseDataset
):
class
HwVocRawDataset
(
BaseDataset
):
"""
"""
Create dataset with raw data.
Create dataset with raw data.
...
...
model_zoo/deeplabv3/src/md_dataset.py
浏览文件 @
913b5b03
...
@@ -17,7 +17,7 @@ from PIL import Image
...
@@ -17,7 +17,7 @@ from PIL import Image
import
mindspore.dataset
as
de
import
mindspore.dataset
as
de
import
mindspore.dataset.transforms.vision.c_transforms
as
C
import
mindspore.dataset.transforms.vision.c_transforms
as
C
from
.ei_dataset
import
HwVoc
ManifestDataset
,
HwVoc
RawDataset
from
.ei_dataset
import
HwVocRawDataset
from
.utils
import
custom_transforms
as
tr
from
.utils
import
custom_transforms
as
tr
...
@@ -77,10 +77,7 @@ def create_dataset(args, data_url, epoch_num=1, batch_size=1, usage="train"):
...
@@ -77,10 +77,7 @@ def create_dataset(args, data_url, epoch_num=1, batch_size=1, usage="train"):
Dataset.
Dataset.
"""
"""
# create iter dataset
# create iter dataset
if
data_url
.
endswith
(
".manifest"
):
dataset
=
HwVocRawDataset
(
data_url
,
usage
=
usage
)
dataset
=
HwVocManifestDataset
(
data_url
,
usage
=
usage
)
else
:
dataset
=
HwVocRawDataset
(
data_url
,
usage
=
usage
)
dataset_len
=
len
(
dataset
)
dataset_len
=
len
(
dataset
)
# wrapped with GeneratorDataset
# wrapped with GeneratorDataset
...
@@ -100,5 +97,4 @@ def create_dataset(args, data_url, epoch_num=1, batch_size=1, usage="train"):
...
@@ -100,5 +97,4 @@ def create_dataset(args, data_url, epoch_num=1, batch_size=1, usage="train"):
dataset
=
dataset
.
repeat
(
count
=
epoch_num
)
dataset
=
dataset
.
repeat
(
count
=
epoch_num
)
dataset
.
map_model
=
4
dataset
.
map_model
=
4
dataset
.
__loop_size__
=
1
return
dataset
return
dataset
model_zoo/deeplabv3/train.py
浏览文件 @
913b5b03
...
@@ -87,13 +87,13 @@ if __name__ == "__main__":
...
@@ -87,13 +87,13 @@ if __name__ == "__main__":
keep_checkpoint_max
=
args_opt
.
save_checkpoint_num
)
keep_checkpoint_max
=
args_opt
.
save_checkpoint_num
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
'checkpoint_deeplabv3'
,
config
=
config_ck
)
ckpoint_cb
=
ModelCheckpoint
(
prefix
=
'checkpoint_deeplabv3'
,
config
=
config_ck
)
callback
.
append
(
ckpoint_cb
)
callback
.
append
(
ckpoint_cb
)
net
=
deeplabv3_resnet50
(
c
rop_size
.
seg_num_classes
,
[
args_opt
.
batch_size
,
3
,
args_opt
.
crop_size
,
args_opt
.
crop_size
],
net
=
deeplabv3_resnet50
(
c
onfig
.
seg_num_classes
,
[
args_opt
.
batch_size
,
3
,
args_opt
.
crop_size
,
args_opt
.
crop_size
],
infer_scale_sizes
=
c
rop_size
.
eval_scales
,
atrous_rates
=
crop_size
.
atrous_rates
,
infer_scale_sizes
=
c
onfig
.
eval_scales
,
atrous_rates
=
config
.
atrous_rates
,
decoder_output_stride
=
c
rop_size
.
decoder_output_stride
,
output_stride
=
crop_size
.
output_stride
,
decoder_output_stride
=
c
onfig
.
decoder_output_stride
,
output_stride
=
config
.
output_stride
,
fine_tune_batch_norm
=
c
rop_size
.
fine_tune_batch_norm
,
image_pyramid
=
crop_size
.
image_pyramid
)
fine_tune_batch_norm
=
c
onfig
.
fine_tune_batch_norm
,
image_pyramid
=
config
.
image_pyramid
)
net
.
set_train
()
net
.
set_train
()
model_fine_tune
(
args_opt
,
net
,
'layer'
)
model_fine_tune
(
args_opt
,
net
,
'layer'
)
loss
=
OhemLoss
(
c
rop_size
.
seg_num_classes
,
crop_size
.
ignore_label
)
loss
=
OhemLoss
(
c
onfig
.
seg_num_classes
,
config
.
ignore_label
)
opt
=
Momentum
(
filter
(
lambda
x
:
'beta'
not
in
x
.
name
and
'gamma'
not
in
x
.
name
and
'depth'
not
in
x
.
name
and
'bias'
not
in
x
.
name
,
net
.
trainable_params
()),
learning_rate
=
args_opt
.
learning_rate
,
momentum
=
args_opt
.
momentum
,
weight_decay
=
args_opt
.
weight_decay
)
opt
=
Momentum
(
filter
(
lambda
x
:
'beta'
not
in
x
.
name
and
'gamma'
not
in
x
.
name
and
'depth'
not
in
x
.
name
and
'bias'
not
in
x
.
name
,
net
.
trainable_params
()),
learning_rate
=
config
.
learning_rate
,
momentum
=
config
.
momentum
,
weight_decay
=
config
.
weight_decay
)
model
=
Model
(
net
,
loss
,
opt
)
model
=
Model
(
net
,
loss
,
opt
)
model
.
train
(
args_opt
.
epoch_size
,
train_dataset
,
callback
)
model
.
train
(
args_opt
.
epoch_size
,
train_dataset
,
callback
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录