Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
a5c2db94
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看板
未验证
提交
a5c2db94
编写于
5月 07, 2020
作者:
C
ceci3
提交者:
GitHub
5月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix dygraph cyclegan (#4592)
* fix init * update * fix
上级
ccdbfe77
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
28 addition
and
10 deletion
+28
-10
PaddleCV/gan/data_reader.py
PaddleCV/gan/data_reader.py
+23
-6
dygraph/cycle_gan/infer.py
dygraph/cycle_gan/infer.py
+1
-1
dygraph/cycle_gan/test.py
dygraph/cycle_gan/test.py
+1
-1
dygraph/cycle_gan/train.py
dygraph/cycle_gan/train.py
+3
-2
未找到文件。
PaddleCV/gan/data_reader.py
浏览文件 @
a5c2db94
...
...
@@ -99,16 +99,24 @@ class reader_creator(object):
def
make_reader
(
self
,
args
,
return_name
=
False
):
print
(
self
.
image_dir
,
self
.
list_filename
)
self
.
with_label
=
False
def
reader
():
batch_out
=
[]
batch_out_label
=
[]
batch_out_name
=
[]
if
self
.
shuffle
:
np
.
random
.
shuffle
(
self
.
lines
)
for
i
,
file
in
enumerate
(
self
.
lines
):
file
=
file
.
strip
(
'
\n\r\t
'
)
for
i
,
line
in
enumerate
(
self
.
lines
):
line
=
line
.
strip
(
'
\n\r\t
'
).
split
(
' '
)
if
len
(
line
)
>
1
:
self
.
with_label
=
True
batch_out_label
.
append
(
line
[
1
])
file
=
line
[
0
]
else
:
file
=
line
[
0
]
self
.
name2id
[
os
.
path
.
basename
(
file
)]
=
i
self
.
id2name
[
i
]
=
os
.
path
.
basename
(
file
)
img
=
Image
.
open
(
os
.
path
.
join
(
self
.
image_dir
,
file
)).
convert
(
...
...
@@ -133,8 +141,16 @@ class reader_creator(object):
batch_out
.
append
(
img
)
if
len
(
batch_out
)
==
self
.
batch_size
:
if
return_name
:
if
self
.
with_label
:
yield
[[
batch_out
,
batch_out_label
,
batch_out_name
]]
batch_out_label
=
[]
else
:
yield
batch_out
,
batch_out_name
batch_out_name
=
[]
else
:
if
self
.
with_label
:
yield
[[
batch_out
,
batch_out_label
]]
batch_out_label
=
[]
else
:
yield
[
batch_out
]
batch_out
=
[]
...
...
@@ -667,8 +683,9 @@ class data_reader(object):
image_dir
=
dataset_dir
,
list_filename
=
test_list
,
batch_size
=
self
.
cfg
.
n_samples
)
reader_test
=
test_reader
.
get_test
_reader
(
reader_test
=
test_reader
.
make
_reader
(
self
.
cfg
,
shuffle
=
False
,
return_name
=
True
)
id2name
=
test_reader
.
id2name
batch_num
=
train_reader
.
len
()
return
train_reader
,
reader_test
,
batch_num
,
id2name
reader
=
train_reader
.
make_reader
(
self
.
cfg
)
return
reader
,
reader_test
,
batch_num
,
id2name
dygraph/cycle_gan/infer.py
浏览文件 @
a5c2db94
...
...
@@ -50,7 +50,7 @@ def infer():
out_path
=
args
.
output
+
"/single"
if
not
os
.
path
.
exists
(
out_path
):
os
.
makedirs
(
out_path
)
cycle_gan
=
Cycle_Gan
(
"cycle_gan"
)
cycle_gan
=
Cycle_Gan
(
3
)
save_dir
=
args
.
init_model
restore
,
_
=
fluid
.
load_dygraph
(
save_dir
)
cycle_gan
.
set_dict
(
restore
)
...
...
dygraph/cycle_gan/test.py
浏览文件 @
a5c2db94
...
...
@@ -50,7 +50,7 @@ def test():
out_path
=
args
.
output
+
"/eval"
+
"/"
+
str
(
epoch
)
if
not
os
.
path
.
exists
(
out_path
):
os
.
makedirs
(
out_path
)
cycle_gan
=
Cycle_Gan
(
"cycle_gan"
)
cycle_gan
=
Cycle_Gan
(
3
)
save_dir
=
args
.
init_model
+
str
(
epoch
)
restore
,
_
=
fluid
.
load_dygraph
(
save_dir
)
cycle_gan
.
set_dict
(
restore
)
...
...
dygraph/cycle_gan/train.py
浏览文件 @
a5c2db94
...
...
@@ -44,7 +44,7 @@ add_arg('save_checkpoints', bool, True, "Whether to save checkpoints.")
lambda_A
=
10.0
lambda_B
=
10.0
lambda_identity
=
0.5
tep_per_epoch
=
2974
s
tep_per_epoch
=
2974
def
optimizer_setting
(
parameters
):
...
...
@@ -90,7 +90,8 @@ def train(args):
losses
=
[[],
[]]
t_time
=
0
vars_G
=
cycle_gan
.
build_generator_resnet_9blocks_a
.
parameters
()
+
cycle_gan
.
build_generator_resnet_9blocks_b
.
parameters
()
vars_G
=
cycle_gan
.
build_generator_resnet_9blocks_a
.
parameters
(
)
+
cycle_gan
.
build_generator_resnet_9blocks_b
.
parameters
()
vars_da
=
cycle_gan
.
build_gen_discriminator_a
.
parameters
()
vars_db
=
cycle_gan
.
build_gen_discriminator_b
.
parameters
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录