Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
0611fe1a
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0611fe1a
编写于
5月 11, 2020
作者:
C
Channingss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stylize cpp code
上级
a7474606
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
16 deletion
+28
-16
deploy/cpp/include/paddlex/transforms.h
deploy/cpp/include/paddlex/transforms.h
+1
-1
deploy/cpp/src/paddlex.cpp
deploy/cpp/src/paddlex.cpp
+13
-11
deploy/cpp/src/transforms.cpp
deploy/cpp/src/transforms.cpp
+4
-4
paddlex/command.py
paddlex/command.py
+10
-0
未找到文件。
deploy/cpp/include/paddlex/transforms.h
浏览文件 @
0611fe1a
...
...
@@ -158,7 +158,7 @@ class Padding : public Transform {
exit
(
-
1
);
}
}
if
(
item
[
"target_size"
].
IsDefined
()){
if
(
item
[
"target_size"
].
IsDefined
())
{
if
(
item
[
"target_size"
].
IsScalar
())
{
width_
=
item
[
"target_size"
].
as
<
int
>
();
height_
=
item
[
"target_size"
].
as
<
int
>
();
...
...
deploy/cpp/src/paddlex.cpp
浏览文件 @
0611fe1a
...
...
@@ -38,13 +38,14 @@ void Model::create_predictor(const std::string& model_dir,
config
.
SwitchSpecifyInputNames
(
true
);
// 开启内存优化
config
.
EnableMemoryOptim
();
if
(
use_trt
){
config
.
EnableTensorRtEngine
(
1
<<
20
/* workspace_size*/
,
32
/* max_batch_size*/
,
20
/* min_subgraph_size*/
,
paddle
::
AnalysisConfig
::
Precision
::
kFloat32
/* precision*/
,
true
/* use_static*/
,
false
/* use_calib_mode*/
);
if
(
use_trt
)
{
config
.
EnableTensorRtEngine
(
1
<<
20
/* workspace_size*/
,
32
/* max_batch_size*/
,
20
/* min_subgraph_size*/
,
paddle
::
AnalysisConfig
::
Precision
::
kFloat32
/* precision*/
,
true
/* use_static*/
,
false
/* use_calib_mode*/
);
}
predictor_
=
std
::
move
(
CreatePaddlePredictor
(
config
));
}
...
...
@@ -294,20 +295,21 @@ bool Model::predict(const cv::Mat& im, SegResult* result) {
result
->
score_map
.
shape
[
3
],
CV_32FC1
,
result
->
score_map
.
data
.
data
());
int
idx
=
1
;
int
idx
=
1
;
int
len_postprocess
=
inputs_
.
im_size_before_resize_
.
size
();
for
(
std
::
vector
<
std
::
string
>::
reverse_iterator
iter
=
inputs_
.
reshape_order_
.
rbegin
();
iter
!=
inputs_
.
reshape_order_
.
rend
();
++
iter
)
{
iter
!=
inputs_
.
reshape_order_
.
rend
();
++
iter
)
{
if
(
*
iter
==
"padding"
)
{
auto
before_shape
=
inputs_
.
im_size_before_resize_
[
len_postprocess
-
idx
];
auto
before_shape
=
inputs_
.
im_size_before_resize_
[
len_postprocess
-
idx
];
inputs_
.
im_size_before_resize_
.
pop_back
();
auto
padding_w
=
before_shape
[
0
];
auto
padding_h
=
before_shape
[
1
];
mask_label
=
mask_label
(
cv
::
Rect
(
0
,
0
,
padding_w
,
padding_h
));
mask_score
=
mask_score
(
cv
::
Rect
(
0
,
0
,
padding_w
,
padding_h
));
}
else
if
(
*
iter
==
"resize"
)
{
auto
before_shape
=
inputs_
.
im_size_before_resize_
[
len_postprocess
-
idx
];
auto
before_shape
=
inputs_
.
im_size_before_resize_
[
len_postprocess
-
idx
];
inputs_
.
im_size_before_resize_
.
pop_back
();
auto
resize_w
=
before_shape
[
0
];
auto
resize_h
=
before_shape
[
1
];
...
...
deploy/cpp/src/transforms.cpp
浏览文件 @
0611fe1a
...
...
@@ -56,7 +56,7 @@ float ResizeByShort::GenerateScale(const cv::Mat& im) {
}
bool
ResizeByShort
::
Run
(
cv
::
Mat
*
im
,
ImageBlob
*
data
)
{
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
reshape_order_
.
push_back
(
"resize"
);
float
scale
=
GenerateScale
(
*
im
);
...
...
@@ -87,7 +87,7 @@ bool CenterCrop::Run(cv::Mat* im, ImageBlob* data) {
}
bool
Padding
::
Run
(
cv
::
Mat
*
im
,
ImageBlob
*
data
)
{
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
reshape_order_
.
push_back
(
"padding"
);
int
padding_w
=
0
;
...
...
@@ -121,7 +121,7 @@ bool ResizeByLong::Run(cv::Mat* im, ImageBlob* data) {
<<
std
::
endl
;
return
false
;
}
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
reshape_order_
.
push_back
(
"resize"
);
int
origin_w
=
im
->
cols
;
int
origin_h
=
im
->
rows
;
...
...
@@ -147,7 +147,7 @@ bool Resize::Run(cv::Mat* im, ImageBlob* data) {
<<
std
::
endl
;
return
false
;
}
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
im_size_before_resize_
.
push_back
({
im
->
rows
,
im
->
cols
});
data
->
reshape_order_
.
push_back
(
"resize"
);
cv
::
resize
(
...
...
paddlex/command.py
浏览文件 @
0611fe1a
...
...
@@ -64,6 +64,16 @@ def main():
model
=
pdx
.
load_model
(
args
.
model_dir
,
fixed_input_shape
)
model
.
export_inference_model
(
args
.
save_dir
)
if
args
.
export_onnx
:
assert
args
.
model_dir
is
not
None
,
"--model_dir should be defined while exporting onnx model"
assert
args
.
save_dir
is
not
None
,
"--save_dir should be defined to save onnx model"
fixed_input_shape
=
eval
(
args
.
fixed_input_shape
)
assert
len
(
fixed_input_shape
)
==
2
,
"len of fixed input shape must == 2"
model
=
pdx
.
load_model
(
args
.
model_dir
,
fixed_input_shape
)
model
.
export_onnx_model
(
args
.
save_dir
)
if
__name__
==
"__main__"
:
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录