Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
acce0c42
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
285
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
acce0c42
编写于
7月 29, 2020
作者:
C
chenguowei01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update train/eval judge
上级
0a9249c9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
7 addition
and
7 deletion
+7
-7
dygraph/infer.py
dygraph/infer.py
+1
-1
dygraph/models/hrnet.py
dygraph/models/hrnet.py
+1
-1
dygraph/models/unet.py
dygraph/models/unet.py
+2
-2
dygraph/train.py
dygraph/train.py
+2
-2
dygraph/val.py
dygraph/val.py
+1
-1
未找到文件。
dygraph/infer.py
浏览文件 @
acce0c42
...
@@ -99,7 +99,7 @@ def infer(model, test_dataset=None, model_dir=None, save_dir='output'):
...
@@ -99,7 +99,7 @@ def infer(model, test_dataset=None, model_dir=None, save_dir='output'):
logging
.
info
(
"Start to predict..."
)
logging
.
info
(
"Start to predict..."
)
for
im
,
im_info
,
im_path
in
tqdm
.
tqdm
(
test_dataset
):
for
im
,
im_info
,
im_path
in
tqdm
.
tqdm
(
test_dataset
):
im
=
to_variable
(
im
)
im
=
to_variable
(
im
)
pred
,
_
=
model
(
im
,
mode
=
'test'
)
pred
,
_
=
model
(
im
)
pred
=
pred
.
numpy
()
pred
=
pred
.
numpy
()
pred
=
np
.
squeeze
(
pred
).
astype
(
'uint8'
)
pred
=
np
.
squeeze
(
pred
).
astype
(
'uint8'
)
for
info
in
im_info
[::
-
1
]:
for
info
in
im_info
[::
-
1
]:
...
...
dygraph/models/hrnet.py
浏览文件 @
acce0c42
...
@@ -171,7 +171,7 @@ class HRNet(fluid.dygraph.Layer):
...
@@ -171,7 +171,7 @@ class HRNet(fluid.dygraph.Layer):
logit
=
self
.
conv_last_1
(
x
)
logit
=
self
.
conv_last_1
(
x
)
logit
=
fluid
.
layers
.
resize_bilinear
(
logit
,
input_shape
)
logit
=
fluid
.
layers
.
resize_bilinear
(
logit
,
input_shape
)
if
mode
==
'train'
:
if
self
.
training
:
if
label
is
None
:
if
label
is
None
:
raise
Exception
(
'Label is need during training'
)
raise
Exception
(
'Label is need during training'
)
return
self
.
_get_loss
(
logit
,
label
)
return
self
.
_get_loss
(
logit
,
label
)
...
...
dygraph/models/unet.py
浏览文件 @
acce0c42
...
@@ -29,11 +29,11 @@ class UNet(fluid.dygraph.Layer):
...
@@ -29,11 +29,11 @@ class UNet(fluid.dygraph.Layer):
self
.
ignore_index
=
ignore_index
self
.
ignore_index
=
ignore_index
self
.
EPS
=
1e-5
self
.
EPS
=
1e-5
def
forward
(
self
,
x
,
label
=
None
,
mode
=
'train'
):
def
forward
(
self
,
x
,
label
=
None
):
encode_data
,
short_cuts
=
self
.
encode
(
x
)
encode_data
,
short_cuts
=
self
.
encode
(
x
)
decode_data
=
self
.
decode
(
encode_data
,
short_cuts
)
decode_data
=
self
.
decode
(
encode_data
,
short_cuts
)
logit
=
self
.
get_logit
(
decode_data
)
logit
=
self
.
get_logit
(
decode_data
)
if
mode
==
'train'
:
if
self
.
training
:
return
self
.
_get_loss
(
logit
,
label
)
return
self
.
_get_loss
(
logit
,
label
)
else
:
else
:
score_map
=
fluid
.
layers
.
softmax
(
logit
,
axis
=
1
)
score_map
=
fluid
.
layers
.
softmax
(
logit
,
axis
=
1
)
...
...
dygraph/train.py
浏览文件 @
acce0c42
...
@@ -188,12 +188,12 @@ def train(model,
...
@@ -188,12 +188,12 @@ def train(model,
images
=
data
[
0
]
images
=
data
[
0
]
labels
=
data
[
1
].
astype
(
'int64'
)
labels
=
data
[
1
].
astype
(
'int64'
)
if
nranks
>
1
:
if
nranks
>
1
:
loss
=
model_parallel
(
images
,
labels
,
mode
=
'train'
)
loss
=
model_parallel
(
images
,
labels
)
loss
=
model_parallel
.
scale_loss
(
loss
)
loss
=
model_parallel
.
scale_loss
(
loss
)
loss
.
backward
()
loss
.
backward
()
model_parallel
.
apply_collective_grads
()
model_parallel
.
apply_collective_grads
()
else
:
else
:
loss
=
model
(
images
,
labels
,
mode
=
'train'
)
loss
=
model
(
images
,
labels
)
loss
.
backward
()
loss
.
backward
()
optimizer
.
minimize
(
loss
)
optimizer
.
minimize
(
loss
)
model
.
clear_gradients
()
model
.
clear_gradients
()
...
...
dygraph/val.py
浏览文件 @
acce0c42
...
@@ -94,7 +94,7 @@ def evaluate(model,
...
@@ -94,7 +94,7 @@ def evaluate(model,
timer
.
start
()
timer
.
start
()
for
step
,
(
im
,
im_info
,
label
)
in
enumerate
(
eval_dataset
):
for
step
,
(
im
,
im_info
,
label
)
in
enumerate
(
eval_dataset
):
im
=
to_variable
(
im
)
im
=
to_variable
(
im
)
pred
,
_
=
model
(
im
,
mode
=
'eval'
)
pred
,
_
=
model
(
im
)
pred
=
pred
.
numpy
().
astype
(
'float32'
)
pred
=
pred
.
numpy
().
astype
(
'float32'
)
pred
=
np
.
squeeze
(
pred
)
pred
=
np
.
squeeze
(
pred
)
for
info
in
im_info
[::
-
1
]:
for
info
in
im_info
[::
-
1
]:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录