Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
0bd09f64
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0bd09f64
编写于
7月 22, 2019
作者:
L
lvmengsi
提交者:
GitHub
7月 22, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix_gan_gpu (#2864)
* fix dir and gpu
上级
87906f04
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
20 deletion
+18
-20
PaddleCV/PaddleGAN/download.py
PaddleCV/PaddleGAN/download.py
+2
-2
PaddleCV/PaddleGAN/infer.py
PaddleCV/PaddleGAN/infer.py
+5
-3
PaddleCV/PaddleGAN/trainer/CGAN.py
PaddleCV/PaddleGAN/trainer/CGAN.py
+3
-4
PaddleCV/PaddleGAN/trainer/DCGAN.py
PaddleCV/PaddleGAN/trainer/DCGAN.py
+3
-4
PaddleCV/PaddleGAN/util/utility.py
PaddleCV/PaddleGAN/util/utility.py
+5
-7
未找到文件。
PaddleCV/PaddleGAN/download.py
浏览文件 @
0bd09f64
...
...
@@ -159,9 +159,9 @@ if __name__ == '__main__':
if
args
.
dataset
==
'mnist'
:
print
(
'Download dataset: {}'
.
format
(
args
.
dataset
))
download_mnist
(
'
./data/
'
)
download_mnist
(
'
data
'
)
elif
args
.
dataset
in
cycle_pix_dataset
:
print
(
'Download dataset: {}'
.
format
(
args
.
dataset
))
download_cycle_pix
(
'./data/'
,
args
.
dataset
)
download_cycle_pix
(
os
.
path
.
join
(
'data'
,
args
.
dataset
)
)
else
:
print
(
'Please download by yourself, thanks'
)
PaddleCV/PaddleGAN/infer.py
浏览文件 @
0bd09f64
...
...
@@ -138,7 +138,7 @@ def infer(args):
for
var
in
fluid
.
default_main_program
().
global_block
().
all_parameters
():
print
(
var
.
name
)
print
(
args
.
init_model
+
'/'
+
model_name
)
fluid
.
io
.
load_persistables
(
exe
,
args
.
init_model
+
"/"
+
model_name
)
fluid
.
io
.
load_persistables
(
exe
,
os
.
path
.
join
(
args
.
init_model
,
model_name
)
)
print
(
'load params done'
)
if
not
os
.
path
.
exists
(
args
.
output
):
os
.
makedirs
(
args
.
output
)
...
...
@@ -270,7 +270,8 @@ def infer(args):
fake_image
=
np
.
reshape
(
fake_temp
,
(
args
.
batch_size
,
-
1
))
fig
=
utility
.
plot
(
fake_image
)
plt
.
savefig
(
args
.
output
+
'/fake_cgan.png'
,
bbox_inches
=
'tight'
)
plt
.
savefig
(
os
.
path
.
join
(
args
.
output
,
'fake_cgan.png'
),
bbox_inches
=
'tight'
)
plt
.
close
(
fig
)
elif
args
.
model_net
==
'DCGAN'
:
...
...
@@ -284,7 +285,8 @@ def infer(args):
fake_image
=
np
.
reshape
(
fake_temp
,
(
args
.
batch_size
,
-
1
))
fig
=
utility
.
plot
(
fake_image
)
plt
.
savefig
(
args
.
output
+
'/fake_dcgan.png'
,
bbox_inches
=
'tight'
)
plt
.
savefig
(
os
.
path
.
join
(
args
.
output
,
'/fake_dcgan.png'
),
bbox_inches
=
'tight'
)
plt
.
close
(
fig
)
else
:
raise
NotImplementedError
(
"model_net {} is not support"
.
format
(
...
...
PaddleCV/PaddleGAN/trainer/CGAN.py
浏览文件 @
0bd09f64
...
...
@@ -181,7 +181,7 @@ class CGAN(object):
t_time
+=
batch_time
if
batch_id
%
self
.
cfg
.
print_freq
==
0
:
image_path
=
self
.
cfg
.
output
+
'/images'
image_path
=
os
.
path
.
join
(
self
.
cfg
.
output
,
'images'
)
if
not
os
.
path
.
exists
(
image_path
):
os
.
makedirs
(
image_path
)
generate_const_image
=
exe
.
run
(
...
...
@@ -201,10 +201,9 @@ class CGAN(object):
batch_time
))
plt
.
title
(
'Epoch ID={}, Batch ID={}'
.
format
(
epoch_id
,
batch_id
))
img_name
=
'{:04d}_{:04d}.png'
.
format
(
epoch_id
,
batch_id
)
plt
.
savefig
(
'{}/{:04d}_{:04d}.png'
.
format
(
image_path
,
epoch_id
,
batch_id
),
bbox_inches
=
'tight'
)
os
.
path
.
join
(
image_path
,
img_name
),
bbox_inches
=
'tight'
)
plt
.
close
(
fig
)
if
self
.
cfg
.
save_checkpoints
:
...
...
PaddleCV/PaddleGAN/trainer/DCGAN.py
浏览文件 @
0bd09f64
...
...
@@ -166,7 +166,7 @@ class DCGAN(object):
t_time
+=
batch_time
if
batch_id
%
self
.
cfg
.
print_freq
==
0
:
image_path
=
self
.
cfg
.
output
+
'/images'
image_path
=
os
.
path
.
join
(
self
.
cfg
.
output
,
'images'
)
if
not
os
.
path
.
exists
(
image_path
):
os
.
makedirs
(
image_path
)
generate_const_image
=
exe
.
run
(
...
...
@@ -185,10 +185,9 @@ class DCGAN(object):
batch_time
))
plt
.
title
(
'Epoch ID={}, Batch ID={}'
.
format
(
epoch_id
,
batch_id
))
img_name
=
'{:04d}_{:04d}.png'
.
format
(
epoch_id
,
batch_id
)
plt
.
savefig
(
'{}/{:04d}_{:04d}.png'
.
format
(
image_path
,
epoch_id
,
batch_id
),
bbox_inches
=
'tight'
)
os
.
path
.
join
(
image_path
,
img_name
),
bbox_inches
=
'tight'
)
plt
.
close
(
fig
)
if
self
.
cfg
.
save_checkpoints
:
...
...
PaddleCV/PaddleGAN/util/utility.py
浏览文件 @
0bd09f64
...
...
@@ -49,7 +49,7 @@ def plot(gen_data):
def
checkpoints
(
epoch
,
cfg
,
exe
,
trainer
,
name
):
output_path
=
cfg
.
output
+
'/checkpoints/'
+
str
(
epoch
)
output_path
=
os
.
path
.
join
(
cfg
.
output
,
'checkpoints'
,
str
(
epoch
)
)
if
not
os
.
path
.
exists
(
output_path
):
os
.
makedirs
(
output_path
)
fluid
.
io
.
save_persistables
(
...
...
@@ -75,7 +75,7 @@ def save_test_image(epoch,
g_trainer
,
A_test_reader
,
B_test_reader
=
None
):
out_path
=
cfg
.
output
+
'/test'
out_path
=
os
.
path
.
join
(
cfg
.
output
,
'test'
)
if
not
os
.
path
.
exists
(
out_path
):
os
.
makedirs
(
out_path
)
if
cfg
.
model_net
==
"Pix2pix"
:
...
...
@@ -242,6 +242,8 @@ class ImagePool(object):
def
check_attribute_conflict
(
label_batch
,
attr
,
attrs
):
''' Based on https://github.com/LynnHo/AttGAN-Tensorflow'''
def
_set
(
label
,
value
,
attr
):
if
attr
in
attrs
:
label
[
attrs
.
index
(
attr
)]
=
value
...
...
@@ -262,10 +264,6 @@ def check_attribute_conflict(label_batch, attr, attrs):
for
a
in
[
'Straight_Hair'
,
'Wavy_Hair'
]:
if
a
!=
attr
:
_set
(
label
,
0
,
a
)
elif
attr
in
[
'Mustache'
,
'No_Beard'
]
and
attrs
[
attr_id
]
!=
0
:
for
a
in
[
'Mustache'
,
'No_Beard'
]:
if
a
!=
attr
:
_set
(
label
,
0
,
a
)
return
label_batch
...
...
@@ -290,7 +288,7 @@ def check_gpu(use_gpu):
try
:
if
use_gpu
and
not
fluid
.
is_compiled_with_cuda
():
logger
.
error
(
err
)
print
(
err
)
sys
.
exit
(
1
)
except
Exception
as
e
:
pass
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录