Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
22c785db
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看板
未验证
提交
22c785db
编写于
9月 11, 2019
作者:
L
lvmengsi
提交者:
GitHub
9月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update_save (#3173)
上级
5322ad1b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
34 deletion
+46
-34
PaddleCV/PaddleGAN/util/utility.py
PaddleCV/PaddleGAN/util/utility.py
+46
-34
未找到文件。
PaddleCV/PaddleGAN/util/utility.py
浏览文件 @
22c785db
...
...
@@ -27,8 +27,8 @@ import six
matplotlib
.
use
(
'agg'
)
import
matplotlib.pyplot
as
plt
import
matplotlib.gridspec
as
gridspec
import
imageio
import
copy
from
PIL
import
Image
img_dim
=
28
...
...
@@ -158,15 +158,18 @@ def save_test_image(epoch,
image_name
).
astype
(
'int32'
)[
0
]]
inputB_name
=
"inputB_"
+
str
(
epoch
)
+
"_"
+
A_id2name
[
np
.
array
(
image_name
).
astype
(
'int32'
)[
0
]]
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
fakeB_name
),
(
(
fake_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
inputA_name
),
(
(
input_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
inputB_name
),
(
(
input_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_fakeB
=
Image
.
fromarray
(((
fake_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_fakeB
.
save
(
os
.
path
.
join
(
out_path
,
fakeB_name
))
res_inputA
=
Image
.
fromarray
(((
input_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_inputA
.
save
(
os
.
path
.
join
(
out_path
,
inputA_name
))
res_inputB
=
Image
.
fromarray
(((
input_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_inputB
.
save
(
os
.
path
.
join
(
out_path
,
inputB_name
))
elif
cfg
.
model_net
==
"StarGAN"
:
for
data
in
A_test_reader
():
real_img
,
label_org
,
label_trg
,
image_name
=
data
[
0
][
...
...
@@ -199,9 +202,11 @@ def save_test_image(epoch,
images_concat
=
np
.
concatenate
(
images_concat
,
1
)
image_name_save
=
"fake_img"
+
str
(
epoch
)
+
"_"
+
str
(
np
.
array
(
image_name
)[
0
].
astype
(
'int32'
))
+
'.jpg'
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
image_name_save
),
(
(
images_concat
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res
=
Image
.
fromarray
(((
images_concat
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res
.
save
(
os
.
path
.
join
(
out_path
,
image_name_save
))
elif
cfg
.
model_net
==
'AttGAN'
or
cfg
.
model_net
==
'STGAN'
:
for
data
in
A_test_reader
():
real_img
,
label_org
,
label_trg
,
image_name
=
data
[
0
][
...
...
@@ -247,9 +252,10 @@ def save_test_image(epoch,
images_concat
=
np
.
concatenate
(
images_concat
,
1
)
image_name_save
=
'fake_img_'
+
str
(
epoch
)
+
'_'
+
str
(
np
.
array
(
image_name
)[
0
].
astype
(
'int32'
))
+
'.jpg'
image_path
=
os
.
path
.
join
(
out_path
,
image_name_save
)
imageio
.
imwrite
(
image_path
,
(
(
images_concat
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res
=
Image
.
fromarray
(((
images_concat
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res
.
save
(
os
.
path
.
join
(
out_path
,
image_name_save
))
else
:
for
data_A
,
data_B
in
zip
(
A_test_reader
(),
B_test_reader
()):
...
...
@@ -282,24 +288,30 @@ def save_test_image(epoch,
A_name
).
astype
(
'int32'
)[
0
]]
cycB_name
=
"cycB_"
+
str
(
epoch
)
+
"_"
+
B_id2name
[
np
.
array
(
B_name
).
astype
(
'int32'
)[
0
]]
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
fakeB_name
),
(
(
fake_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
fakeA_name
),
(
(
fake_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
cycA_name
),
(
(
cyc_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
cycB_name
),
(
(
cyc_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
inputA_name
),
(
(
input_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
imageio
.
imwrite
(
os
.
path
.
join
(
out_path
,
inputB_name
),
(
(
input_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_fakeB
=
Image
.
fromarray
(((
fake_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_fakeB
.
save
(
os
.
path
.
join
(
out_path
,
fakeB_name
))
res_fakeA
=
Image
.
fromarray
(((
fake_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_fakeA
.
save
(
os
.
path
.
join
(
out_path
,
fakeA_name
))
res_cycA
=
Image
.
fromarray
(((
cyc_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_cycA
.
save
(
os
.
path
.
join
(
out_path
,
cycA_name
))
res_cycB
=
Image
.
fromarray
(((
cyc_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_cycB
.
save
(
os
.
path
.
join
(
out_path
,
cycB_name
))
res_inputA
=
Image
.
fromarray
(((
input_A_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_inputA
.
save
(
os
.
path
.
join
(
out_path
,
inputA_name
))
res_inputB
=
Image
.
fromarray
(((
input_B_temp
+
1
)
*
127.5
).
astype
(
np
.
uint8
))
res_inputB
.
save
(
os
.
path
.
join
(
out_path
,
inputB_name
))
class
ImagePool
(
object
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录