Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
1cd6ae0d
P
PaddleGAN
项目概览
PaddlePaddle
/
PaddleGAN
1 年多 前同步成功
通知
97
Star
7254
Fork
1210
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleGAN
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1cd6ae0d
编写于
1月 17, 2022
作者:
W
wangna11BD
提交者:
GitHub
1月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix lapstyle input (#560)
* fix lapstyle input * fix image path * fix image path * fix image path
上级
3e17a8c2
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
9 addition
and
10 deletion
+9
-10
applications/tools/lapstyle.py
applications/tools/lapstyle.py
+2
-1
ppgan/apps/lapstyle_predictor.py
ppgan/apps/lapstyle_predictor.py
+7
-9
未找到文件。
applications/tools/lapstyle.py
浏览文件 @
1cd6ae0d
...
...
@@ -24,6 +24,7 @@ if __name__ == "__main__":
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--content_img_path"
,
type
=
str
,
required
=
True
,
help
=
"path to content image"
)
parser
.
add_argument
(
"--output_path"
,
...
...
@@ -46,7 +47,7 @@ if __name__ == "__main__":
parser
.
add_argument
(
"--style_image_path"
,
type
=
str
,
default
=
Non
e
,
required
=
Tru
e
,
help
=
"path to style image"
)
parser
.
add_argument
(
"--cpu"
,
...
...
ppgan/apps/lapstyle_predictor.py
浏览文件 @
1cd6ae0d
...
...
@@ -144,10 +144,17 @@ class LapStylePredictor(BasePredictor):
self
.
net_rev_2
.
eval
()
def
run
(
self
,
content_img_path
,
style_image_path
):
if
not
self
.
is_image
(
content_img_path
):
raise
ValueError
(
'The path of content_img does not exist or is not image'
)
if
not
self
.
is_image
(
style_image_path
):
raise
ValueError
(
'The path of style_image does not exist or is not image'
)
content_img
,
style_img
,
h
,
w
=
img_read
(
content_img_path
,
style_image_path
)
content_img_visual
=
tensor2img
(
content_img
,
min_max
=
(
0.
,
1.
))
content_img_visual
=
cv
.
cvtColor
(
content_img_visual
,
cv
.
COLOR_RGB2BGR
)
content_img_visual
=
cv
.
resize
(
content_img_visual
,
(
w
,
h
))
cv
.
imwrite
(
os
.
path
.
join
(
self
.
output
,
'content.png'
),
content_img_visual
)
style_img_visual
=
tensor2img
(
style_img
,
min_max
=
(
0.
,
1.
))
style_img_visual
=
cv
.
cvtColor
(
style_img_visual
,
cv
.
COLOR_RGB2BGR
)
...
...
@@ -159,20 +166,11 @@ class LapStylePredictor(BasePredictor):
cF
=
self
.
net_enc
(
pyr_ci
[
2
])
sF
=
self
.
net_enc
(
pyr_si
[
2
])
stylized_small
=
self
.
net_dec
(
cF
,
sF
)
stylized_small_visual
=
tensor2img
(
stylized_small
,
min_max
=
(
0.
,
1.
))
stylized_small_visual
=
cv
.
cvtColor
(
stylized_small_visual
,
cv
.
COLOR_RGB2BGR
)
cv
.
imwrite
(
os
.
path
.
join
(
self
.
output
,
'stylized_small.png'
),
stylized_small_visual
)
stylized_up
=
F
.
interpolate
(
stylized_small
,
scale_factor
=
2
)
revnet_input
=
paddle
.
concat
(
x
=
[
pyr_ci
[
1
],
stylized_up
],
axis
=
1
)
stylized_rev_lap
=
self
.
net_rev
(
revnet_input
)
stylized_rev
=
fold_laplace_pyramid
([
stylized_rev_lap
,
stylized_small
])
stylized_rev_visual
=
tensor2img
(
stylized_rev
,
min_max
=
(
0.
,
1.
))
stylized_rev_visual
=
cv
.
cvtColor
(
stylized_rev_visual
,
cv
.
COLOR_RGB2BGR
)
cv
.
imwrite
(
os
.
path
.
join
(
self
.
output
,
'stylized_rev_first.png'
),
stylized_rev_visual
)
stylized_up
=
F
.
interpolate
(
stylized_rev
,
scale_factor
=
2
)
revnet_input
=
paddle
.
concat
(
x
=
[
pyr_ci
[
0
],
stylized_up
],
axis
=
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录