Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleGAN
提交
daf35241
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看板
未验证
提交
daf35241
编写于
3月 07, 2022
作者:
L
lzzyzlbb
提交者:
GitHub
3月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add benchmark_infer (#590)
* add benchmark_infer
上级
0d66d0ac
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
50 addition
and
28 deletion
+50
-28
ppgan/models/base_model.py
ppgan/models/base_model.py
+5
-3
ppgan/models/firstorder_model.py
ppgan/models/firstorder_model.py
+1
-1
ppgan/models/styleganv2_model.py
ppgan/models/styleganv2_model.py
+5
-2
test_tipc/configs/CycleGAN/train_infer_python.txt
test_tipc/configs/CycleGAN/train_infer_python.txt
+6
-4
test_tipc/configs/FOMM/train_infer_python.txt
test_tipc/configs/FOMM/train_infer_python.txt
+1
-1
test_tipc/configs/Pix2pix/train_infer_python.txt
test_tipc/configs/Pix2pix/train_infer_python.txt
+6
-4
test_tipc/configs/StyleGANv2/train_infer_python.txt
test_tipc/configs/StyleGANv2/train_infer_python.txt
+6
-4
test_tipc/configs/basicvsr/train_infer_python.txt
test_tipc/configs/basicvsr/train_infer_python.txt
+6
-4
test_tipc/configs/msvsr/train_infer_python.txt
test_tipc/configs/msvsr/train_infer_python.txt
+5
-3
test_tipc/test_train_inference_python.sh
test_tipc/test_train_inference_python.sh
+1
-1
tools/export_model.py
tools/export_model.py
+8
-1
未找到文件。
ppgan/models/base_model.py
浏览文件 @
daf35241
...
...
@@ -183,7 +183,7 @@ class BaseModel(ABC):
for
param
in
net
.
parameters
():
param
.
trainable
=
requires_grad
def
export_model
(
self
,
export_model
,
output_dir
=
None
,
inputs_size
=
[],
export_serving_model
=
False
):
def
export_model
(
self
,
export_model
,
output_dir
=
None
,
inputs_size
=
[],
export_serving_model
=
False
,
model_name
=
None
):
inputs_num
=
0
for
net
in
export_model
:
input_spec
=
[
...
...
@@ -196,11 +196,13 @@ class BaseModel(ABC):
input_spec
=
input_spec
)
if
output_dir
is
None
:
output_dir
=
'inference_model'
if
model_name
is
None
:
model_name
=
'{}_{}'
.
format
(
self
.
__class__
.
__name__
.
lower
(),
net
[
"name"
])
paddle
.
jit
.
save
(
static_model
,
os
.
path
.
join
(
output_dir
,
'{}_{}'
.
format
(
self
.
__class__
.
__name__
.
lower
(),
net
[
"name"
])))
output_dir
,
model_name
))
if
export_serving_model
:
from
paddle_serving_client.io
import
inference_model_to_serving
model_name
=
'{}_{}'
.
format
(
self
.
__class__
.
__name__
.
lower
(),
...
...
ppgan/models/firstorder_model.py
浏览文件 @
daf35241
...
...
@@ -214,7 +214,7 @@ class FirstOrderModel(BaseModel):
kp_driving
=
kp_norm
)
return
out
[
'prediction'
]
def
export_model
(
self
,
export_model
=
None
,
output_dir
=
None
,
inputs_size
=
[],
export_serving_model
=
False
):
def
export_model
(
self
,
export_model
=
None
,
output_dir
=
None
,
inputs_size
=
[],
export_serving_model
=
False
,
model_name
=
None
):
source
=
paddle
.
rand
(
shape
=
inputs_size
[
0
],
dtype
=
'float32'
)
driving
=
paddle
.
rand
(
shape
=
inputs_size
[
1
],
dtype
=
'float32'
)
...
...
ppgan/models/styleganv2_model.py
浏览文件 @
daf35241
...
...
@@ -310,13 +310,16 @@ class StyleGAN2Model(BaseModel):
export_model
=
None
,
output_dir
=
None
,
inputs_size
=
[[
1
,
1
,
512
],
[
1
,
1
]],
export_serving_model
=
False
):
export_serving_model
=
False
,
model_name
=
None
):
infer_generator
=
self
.
InferGenerator
()
infer_generator
.
set_generator
(
self
.
nets
[
'gen'
])
style
=
paddle
.
rand
(
shape
=
inputs_size
[
0
],
dtype
=
'float32'
)
truncation
=
paddle
.
rand
(
shape
=
inputs_size
[
1
],
dtype
=
'float32'
)
if
output_dir
is
None
:
output_dir
=
'inference_model'
if
model_name
is
None
:
model_name
=
"stylegan2model_gen"
paddle
.
jit
.
save
(
infer_generator
,
os
.
path
.
join
(
output_dir
,
"stylegan2model_gen"
),
os
.
path
.
join
(
output_dir
,
model_name
),
input_spec
=
[
style
,
truncation
])
test_tipc/configs/CycleGAN/train_infer_python.txt
浏览文件 @
daf35241
...
...
@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1
##
auto_cast:null
epochs:lite_train_lite_infer=1|whole_train_whole_infer=200
epochs:lite_train_lite_infer=1|
lite_train_whole_infer=1|
whole_train_whole_infer=200
output_dir:./output/
dataset.train.batch_size:lite_train_lite_infer=1|whole_train_whole_infer=1
pretrained_model:null
...
...
@@ -27,13 +27,13 @@ null:null
===========================infer_params===========================
--output_dir:./output/
load:null
norm_export:tools/export_model.py -c configs/cyclegan_horse2zebra.yaml --inputs_size="-1,3,-1,-1;-1,3,-1,-1" --load
norm_export:tools/export_model.py -c configs/cyclegan_horse2zebra.yaml --inputs_size="-1,3,-1,-1;-1,3,-1,-1"
--model_name inference
--load
quant_export:null
fpgm_export:null
distill_export:null
export1:null
export2:null
inference_dir:
cycleganmodel_netG_A
inference_dir:
inference
train_model:./inference/cyclegan_horse2zebra/cycleganmodel_netG_A
infer_export:null
infer_quant:False
...
...
@@ -55,3 +55,5 @@ fp_items:fp32
epoch:1
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,256,256]}]
\ No newline at end of file
test_tipc/configs/FOMM/train_infer_python.txt
浏览文件 @
daf35241
...
...
@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0
##
auto_cast:null
epochs:lite_train_lite_infer=1|whole_train_whole_infer=100
epochs:lite_train_lite_infer=1|
lite_train_whole_infer=1|
whole_train_whole_infer=100
output_dir:./output/
dataset.train.batch_size:lite_train_lite_infer=8|whole_train_whole_infer=8
pretrained_model:null
...
...
test_tipc/configs/Pix2pix/train_infer_python.txt
浏览文件 @
daf35241
...
...
@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0
##
auto_cast:null
epochs:lite_train_lite_infer=10|whole_train_whole_infer=200
epochs:lite_train_lite_infer=10|
lite_train_whole_infer=10|
whole_train_whole_infer=200
output_dir:./output/
dataset.train.batch_size:lite_train_lite_infer=1|whole_train_whole_infer=1
pretrained_model:null
...
...
@@ -27,13 +27,13 @@ null:null
===========================infer_params===========================
--output_dir:./output/
load:null
norm_export:tools/export_model.py -c configs/pix2pix_facades.yaml --inputs_size="-1,3,-1,-1" --load
norm_export:tools/export_model.py -c configs/pix2pix_facades.yaml --inputs_size="-1,3,-1,-1"
--model_name inference
--load
quant_export:null
fpgm_export:null
distill_export:null
export1:null
export2:null
inference_dir:
pix2pixmodel_netG
inference_dir:
inference
train_model:./inference/pix2pix_facade/pix2pixmodel_netG
infer_export:null
infer_quant:False
...
...
@@ -55,3 +55,5 @@ fp_items:fp32
epoch:10
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,256,256]}]
test_tipc/configs/StyleGANv2/train_infer_python.txt
浏览文件 @
daf35241
...
...
@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0
##
auto_cast:null
total_iters:lite_train_lite_infer=10|whole_train_whole_infer=800
total_iters:lite_train_lite_infer=10|
lite_train_whole_infer=10|
whole_train_whole_infer=800
output_dir:./output/
dataset.train.batch_size:lite_train_lite_infer=3|whole_train_whole_infer=3
pretrained_model:null
...
...
@@ -27,13 +27,13 @@ null:null
===========================infer_params===========================
--output_dir:./output/
load:null
norm_export:tools/export_model.py -c configs/stylegan_v2_256_ffhq.yaml --inputs_size="1,1,512;1,1" --load
norm_export:tools/export_model.py -c configs/stylegan_v2_256_ffhq.yaml --inputs_size="1,1,512;1,1"
--model_name inference
--load
quant_export:null
fpgm_export:null
distill_export:null
export1:null
export2:null
inference_dir:
stylegan2model_gen
inference_dir:
inference
train_model:./inference/stylegan2/stylegan2model_gen
infer_export:null
infer_quant:False
...
...
@@ -55,3 +55,5 @@ fp_items:fp32
epoch:100
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[1,512]}, {float32,[1]}]
\ No newline at end of file
test_tipc/configs/basicvsr/train_infer_python.txt
浏览文件 @
daf35241
...
...
@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0
##
auto_cast:null
total_iters:lite_train_lite_infer=10|whole_train_whole_infer=200
total_iters:lite_train_lite_infer=10|
lite_train_whole_infer=10|
whole_train_whole_infer=200
output_dir:./output/
dataset.train.batch_size:lite_train_lite_infer=1|whole_train_whole_infer=1
pretrained_model:null
...
...
@@ -27,13 +27,13 @@ null:null
===========================infer_params===========================
--output_dir:./output/
load:null
norm_export:tools/export_model.py -c configs/basicvsr_reds.yaml --inputs_size="1,6,3,180,320" --load
norm_export:tools/export_model.py -c configs/basicvsr_reds.yaml --inputs_size="1,6,3,180,320" --
model_name inference --
load
quant_export:null
fpgm_export:null
distill_export:null
export1:null
export2:null
inference_dir:
basicvsrmodel_generator
inference_dir:
inference
train_model:./inference/basicvsr/basicvsrmodel_generator
infer_export:null
infer_quant:False
...
...
@@ -55,3 +55,5 @@ fp_items:fp32
total_iters:50
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[6,3,180,320]}]
\ No newline at end of file
test_tipc/configs/msvsr/train_infer_python.txt
浏览文件 @
daf35241
...
...
@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0
##
auto_cast:null
total_iters:lite_train_lite_infer=10|whole_train_whole_infer=200
total_iters:lite_train_lite_infer=10|
lite_train_whole_infer=10|
whole_train_whole_infer=200
output_dir:./output/
dataset.train.batch_size:lite_train_lite_infer=1|whole_train_whole_infer=1
pretrained_model:null
...
...
@@ -27,13 +27,13 @@ null:null
===========================infer_params===========================
--output_dir:./output/
load:null
norm_export:tools/export_model.py -c configs/msvsr_reds.yaml --inputs_size="1,2,3,180,320" --load
norm_export:tools/export_model.py -c configs/msvsr_reds.yaml --inputs_size="1,2,3,180,320"
--model_name inference
--load
quant_export:null
fpgm_export:null
distill_export:null
export1:null
export2:null
inference_dir:
multistagevsrmodel_generator
inference_dir:
inference
train_model:./inference/msvsr/multistagevsrmodel_generator
infer_export:null
infer_quant:False
...
...
@@ -49,3 +49,5 @@ null:null
null:null
--benchmark:True
null:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[2,3,180,320]}]
test_tipc/test_train_inference_python.sh
浏览文件 @
daf35241
...
...
@@ -73,7 +73,7 @@ save_log_key=$(func_parser_key "${lines[48]}")
infer_key1
=
$(
func_parser_key
"
${
lines
[50]
}
"
)
infer_value1
=
$(
func_parser_value
"
${
lines
[50]
}
"
)
LOG_PATH
=
"./test_tipc/output"
LOG_PATH
=
"./test_tipc/output
/
${
model_name
}
"
mkdir
-p
${
LOG_PATH
}
status_log
=
"
${
LOG_PATH
}
/results_python.log"
...
...
tools/export_model.py
浏览文件 @
daf35241
...
...
@@ -57,6 +57,12 @@ def parse_args():
type
=
bool
,
help
=
"export serving model."
,
)
parser
.
add_argument
(
"--model_name"
,
default
=
None
,
type
=
str
,
help
=
"model_name."
,
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -70,7 +76,8 @@ def main(args, cfg):
for
net_name
,
net
in
model
.
nets
.
items
():
if
net_name
in
state_dicts
:
net
.
set_state_dict
(
state_dicts
[
net_name
])
model
.
export_model
(
cfg
.
export_model
,
args
.
output_dir
,
inputs_size
,
args
.
export_serving_model
)
model
.
export_model
(
cfg
.
export_model
,
args
.
output_dir
,
inputs_size
,
args
.
export_serving_model
,
args
.
model_name
)
if
__name__
==
"__main__"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录