Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
b192374b
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b192374b
编写于
3月 27, 2019
作者:
Q
qingqing01
提交者:
GitHub
3月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update hype parameter for DeepLab (#1926) (#1928)
* fix some hyper parameters * Update README
上级
dc76c32f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
22 deletion
+33
-22
fluid/PaddleCV/deeplabv3+/.gitignore
fluid/PaddleCV/deeplabv3+/.gitignore
+6
-3
fluid/PaddleCV/deeplabv3+/README.md
fluid/PaddleCV/deeplabv3+/README.md
+4
-6
fluid/PaddleCV/deeplabv3+/eval.py
fluid/PaddleCV/deeplabv3+/eval.py
+1
-4
fluid/PaddleCV/deeplabv3+/reader.py
fluid/PaddleCV/deeplabv3+/reader.py
+16
-4
fluid/PaddleCV/deeplabv3+/train.py
fluid/PaddleCV/deeplabv3+/train.py
+6
-5
未找到文件。
fluid/PaddleCV/deeplabv3+/.gitignore
浏览文件 @
b192374b
deeplabv3plus_xception65_initialize.params
*.tgz
deeplabv3plus.params
deeplabv3plus_gn_init*
deeplabv3plus.tar.gz
deeplabv3plus_xception65_initialize*
*.log
*.sh
output*
fluid/PaddleCV/deeplabv3+/README.md
浏览文件 @
b192374b
...
@@ -72,20 +72,19 @@ python train.py --help
...
@@ -72,20 +72,19 @@ python train.py --help
以上命令用于测试训练过程是否正常,仅仅迭代了50次并且使用了1的batch size,如果需要复现
以上命令用于测试训练过程是否正常,仅仅迭代了50次并且使用了1的batch size,如果需要复现
原论文的实验,请使用以下设置:
原论文的实验,请使用以下设置:
```
```
CUDA_VISIBLE_DEVICES=0 \
python ./train.py \
python ./train.py \
--batch_size=
8
\
--batch_size=
4
\
--parallel=True \
--parallel=True \
--norm_type=gn \
--norm_type=gn \
--train_crop_size=769 \
--train_crop_size=769 \
--total_step=
9
0000 \
--total_step=
50
0000 \
--base_lr=0.001 \
--base_lr=0.001 \
--init_weights_path=deeplabv3plus_gn_init \
--init_weights_path=deeplabv3plus_gn_init \
--save_weights_path=output \
--save_weights_path=output \
--dataset_path=$DATASET_PATH
--dataset_path=$DATASET_PATH
```
```
如果您的显存不足,可以尝试减小
`batch_size`
,同时等比例放大
`total_step`
, 保证相乘的值不变,这得益于Group Norm的特性,改变
`batch_size`
并不会显著影响结果,而且能够节约更多显存, 比如您可以设置
`--batch_size=4 --total_step=180000`
。
如果您的显存不足,可以尝试减小
`batch_size`
,同时等比例放大
`total_step`
, 缩小
`base_lr`
, 保证相乘的值不变,这得益于Group Norm的特性,改变
`batch_size`
并不会显著影响结果,而且能够节约更多显存, 比如您可以设置
`--batch_size=2 --total_step=1000000 --base_lr=0.0005`
。
如果您希望使用多卡进行训练,可以同比增加
`batch_size`
,减小
`total_step`
, 比如原来单卡训练是
`--batch_size=4 --total_step=180000`
,使用4卡训练则是
`--batch_size=16 --total_step=45000`
### 测试
### 测试
执行以下命令在
`Cityscape`
测试数据集上进行测试:
执行以下命令在
`Cityscape`
测试数据集上进行测试:
...
@@ -110,7 +109,6 @@ step: 500, mIoU: 0.7881
...
@@ -110,7 +109,6 @@ step: 500, mIoU: 0.7881
|数据集 | norm type | pretrained model | trained model | mean IoU
|数据集 | norm type | pretrained model | trained model | mean IoU
|---|---|---|---|---|
|---|---|---|---|---|
|CityScape | batch norm |
[
deeplabv3plus_xception65_initialize.tgz
](
https://paddle-deeplab.bj.bcebos.com/deeplabv3plus_xception65_initialize.tgz
)
|
[
deeplabv3plus.tgz
](
https://paddle-deeplab.bj.bcebos.com/deeplabv3plus.tgz
)
| 0.7873 |
|CityScape | group norm |
[
deeplabv3plus_gn_init.tgz
](
https://paddle-deeplab.bj.bcebos.com/deeplabv3plus_gn_init.tgz
)
|
[
deeplabv3plus_gn.tgz
](
https://paddle-deeplab.bj.bcebos.com/deeplabv3plus_gn.tgz
)
| 0.7881 |
|CityScape | group norm |
[
deeplabv3plus_gn_init.tgz
](
https://paddle-deeplab.bj.bcebos.com/deeplabv3plus_gn_init.tgz
)
|
[
deeplabv3plus_gn.tgz
](
https://paddle-deeplab.bj.bcebos.com/deeplabv3plus_gn.tgz
)
| 0.7881 |
## 参考
## 参考
...
...
fluid/PaddleCV/deeplabv3+/eval.py
浏览文件 @
b192374b
...
@@ -137,7 +137,4 @@ for i in range(total_step):
...
@@ -137,7 +137,4 @@ for i in range(total_step):
all_correct
=
right
.
copy
()
all_correct
=
right
.
copy
()
mp
=
(
wrong
+
right
)
!=
0
mp
=
(
wrong
+
right
)
!=
0
miou2
=
np
.
mean
((
right
[
mp
]
*
1.0
/
(
right
[
mp
]
+
wrong
[
mp
])))
miou2
=
np
.
mean
((
right
[
mp
]
*
1.0
/
(
right
[
mp
]
+
wrong
[
mp
])))
if
args
.
verbose
:
print
(
'step: %s, mIoU: %s'
%
(
i
+
1
,
miou2
))
print
(
'step: %s, mIoU: %s'
%
(
i
+
1
,
miou2
),
flush
=
True
)
else
:
print
(
'
\r
step: %s, mIoU: %s'
%
(
i
+
1
,
miou2
),
end
=
'
\r
'
,
flush
=
True
)
fluid/PaddleCV/deeplabv3+/reader.py
浏览文件 @
b192374b
...
@@ -9,7 +9,7 @@ import six
...
@@ -9,7 +9,7 @@ import six
default_config
=
{
default_config
=
{
"shuffle"
:
True
,
"shuffle"
:
True
,
"min_resize"
:
0.5
,
"min_resize"
:
0.5
,
"max_resize"
:
2
,
"max_resize"
:
4
,
"crop_size"
:
769
,
"crop_size"
:
769
,
}
}
...
@@ -90,9 +90,21 @@ class CityscapeDataset:
...
@@ -90,9 +90,21 @@ class CityscapeDataset:
break
break
if
shape
==
-
1
:
if
shape
==
-
1
:
return
img
,
label
,
ln
return
img
,
label
,
ln
random_scale
=
np
.
random
.
rand
(
1
)
*
(
self
.
config
[
'max_resize'
]
-
self
.
config
[
'min_resize'
]
if
np
.
random
.
rand
()
>
0.5
:
)
+
self
.
config
[
'min_resize'
]
range_l
=
1
range_r
=
self
.
config
[
'max_resize'
]
else
:
range_l
=
self
.
config
[
'min_resize'
]
range_r
=
1
if
np
.
random
.
rand
()
>
0.5
:
assert
len
(
img
.
shape
)
==
3
and
len
(
label
.
shape
)
==
3
,
"{} {}"
.
format
(
img
.
shape
,
label
.
shape
)
img
=
img
[:,
:,
::
-
1
]
label
=
label
[:,
:,
::
-
1
]
random_scale
=
np
.
random
.
rand
(
1
)
*
(
range_r
-
range_l
)
+
range_l
crop_size
=
int
(
shape
/
random_scale
)
crop_size
=
int
(
shape
/
random_scale
)
bb
=
crop_size
//
2
bb
=
crop_size
//
2
...
...
fluid/PaddleCV/deeplabv3+/train.py
浏览文件 @
b192374b
...
@@ -21,10 +21,10 @@ parser = argparse.ArgumentParser()
...
@@ -21,10 +21,10 @@ parser = argparse.ArgumentParser()
add_arg
=
lambda
*
args
:
utility
.
add_arguments
(
*
args
,
argparser
=
parser
)
add_arg
=
lambda
*
args
:
utility
.
add_arguments
(
*
args
,
argparser
=
parser
)
# yapf: disable
# yapf: disable
add_arg
(
'batch_size'
,
int
,
2
,
"The number of images in each batch during training."
)
add_arg
(
'batch_size'
,
int
,
4
,
"The number of images in each batch during training."
)
add_arg
(
'train_crop_size'
,
int
,
769
,
"Image crop size during training."
)
add_arg
(
'train_crop_size'
,
int
,
769
,
"Image crop size during training."
)
add_arg
(
'base_lr'
,
float
,
0.00
01
,
"The base learning rate for model training."
)
add_arg
(
'base_lr'
,
float
,
0.00
1
,
"The base learning rate for model training."
)
add_arg
(
'total_step'
,
int
,
90000
,
"Number of the training step."
)
add_arg
(
'total_step'
,
int
,
500000
,
"Number of the training step."
)
add_arg
(
'init_weights_path'
,
str
,
None
,
"Path of the initial weights in paddlepaddle format."
)
add_arg
(
'init_weights_path'
,
str
,
None
,
"Path of the initial weights in paddlepaddle format."
)
add_arg
(
'save_weights_path'
,
str
,
None
,
"Path of the saved weights during training."
)
add_arg
(
'save_weights_path'
,
str
,
None
,
"Path of the saved weights during training."
)
add_arg
(
'dataset_path'
,
str
,
None
,
"Cityscape dataset path."
)
add_arg
(
'dataset_path'
,
str
,
None
,
"Cityscape dataset path."
)
...
@@ -39,7 +39,7 @@ add_arg('use_py_reader', bool, True, "Use py reader.")
...
@@ -39,7 +39,7 @@ add_arg('use_py_reader', bool, True, "Use py reader.")
parser
.
add_argument
(
parser
.
add_argument
(
'--enable_ce'
,
'--enable_ce'
,
action
=
'store_true'
,
action
=
'store_true'
,
help
=
'If set, run the task with continuous evaluation logs.'
)
help
=
'If set, run the task with continuous evaluation logs.
Users can ignore this agument.
'
)
#yapf: enable
#yapf: enable
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
...
@@ -87,7 +87,8 @@ def loss(logit, label):
...
@@ -87,7 +87,8 @@ def loss(logit, label):
label
=
fluid
.
layers
.
reshape
(
label
,
[
-
1
,
1
])
label
=
fluid
.
layers
.
reshape
(
label
,
[
-
1
,
1
])
label
=
fluid
.
layers
.
cast
(
label
,
'int64'
)
label
=
fluid
.
layers
.
cast
(
label
,
'int64'
)
label_nignore
=
fluid
.
layers
.
reshape
(
label_nignore
,
[
-
1
,
1
])
label_nignore
=
fluid
.
layers
.
reshape
(
label_nignore
,
[
-
1
,
1
])
loss
=
fluid
.
layers
.
softmax_with_cross_entropy
(
logit
,
label
,
ignore_index
=
255
,
numeric_stable_mode
=
True
)
logit
=
fluid
.
layers
.
softmax
(
logit
,
use_cudnn
=
False
)
loss
=
fluid
.
layers
.
cross_entropy
(
logit
,
label
,
ignore_index
=
255
)
label_nignore
.
stop_gradient
=
True
label_nignore
.
stop_gradient
=
True
label
.
stop_gradient
=
True
label
.
stop_gradient
=
True
return
loss
,
label_nignore
return
loss
,
label_nignore
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录