Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
6e5eecd7
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看板
提交
6e5eecd7
编写于
9月 16, 2020
作者:
F
FlyingQianMM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename input_channel to input_channel_
上级
ea94deb9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
15 addition
and
15 deletion
+15
-15
deploy/cpp/include/paddlex/paddlex.h
deploy/cpp/include/paddlex/paddlex.h
+1
-1
deploy/cpp/src/paddlex.cpp
deploy/cpp/src/paddlex.cpp
+14
-14
未找到文件。
deploy/cpp/include/paddlex/paddlex.h
浏览文件 @
6e5eecd7
...
@@ -233,6 +233,6 @@ class Model {
...
@@ -233,6 +233,6 @@ class Model {
// a predictor which run the model predicting
// a predictor which run the model predicting
std
::
unique_ptr
<
paddle
::
PaddlePredictor
>
predictor_
;
std
::
unique_ptr
<
paddle
::
PaddlePredictor
>
predictor_
;
// input channel
// input channel
int
input_channel
;
int
input_channel
_
;
};
};
}
// namespace PaddleX
}
// namespace PaddleX
deploy/cpp/src/paddlex.cpp
浏览文件 @
6e5eecd7
...
@@ -135,9 +135,9 @@ bool Model::load_config(const std::string& yaml_input) {
...
@@ -135,9 +135,9 @@ bool Model::load_config(const std::string& yaml_input) {
labels
[
index
]
=
item
.
as
<
std
::
string
>
();
labels
[
index
]
=
item
.
as
<
std
::
string
>
();
}
}
if
(
config
[
"_init_params"
][
"input_channel"
].
IsDefined
())
{
if
(
config
[
"_init_params"
][
"input_channel"
].
IsDefined
())
{
input_channel
=
config
[
"_init_params"
][
"input_channel"
].
as
<
int
>
();
input_channel
_
=
config
[
"_init_params"
][
"input_channel"
].
as
<
int
>
();
}
else
{
}
else
{
input_channel
=
3
;
input_channel
_
=
3
;
}
}
return
true
;
return
true
;
}
}
...
@@ -184,7 +184,7 @@ bool Model::predict(const cv::Mat& im, ClsResult* result) {
...
@@ -184,7 +184,7 @@ bool Model::predict(const cv::Mat& im, ClsResult* result) {
auto
in_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
auto
in_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
int
h
=
inputs_
.
new_im_size_
[
0
];
int
h
=
inputs_
.
new_im_size_
[
0
];
int
w
=
inputs_
.
new_im_size_
[
1
];
int
w
=
inputs_
.
new_im_size_
[
1
];
in_tensor
->
Reshape
({
1
,
input_channel
,
h
,
w
});
in_tensor
->
Reshape
({
1
,
input_channel
_
,
h
,
w
});
in_tensor
->
copy_from_cpu
(
inputs_
.
im_data_
.
data
());
in_tensor
->
copy_from_cpu
(
inputs_
.
im_data_
.
data
());
predictor_
->
ZeroCopyRun
();
predictor_
->
ZeroCopyRun
();
// get result
// get result
...
@@ -231,12 +231,12 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
...
@@ -231,12 +231,12 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
auto
in_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
auto
in_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
int
h
=
inputs_batch_
[
0
].
new_im_size_
[
0
];
int
h
=
inputs_batch_
[
0
].
new_im_size_
[
0
];
int
w
=
inputs_batch_
[
0
].
new_im_size_
[
1
];
int
w
=
inputs_batch_
[
0
].
new_im_size_
[
1
];
in_tensor
->
Reshape
({
batch_size
,
input_channel
,
h
,
w
});
in_tensor
->
Reshape
({
batch_size
,
input_channel
_
,
h
,
w
});
std
::
vector
<
float
>
inputs_data
(
batch_size
*
input_channel
*
h
*
w
);
std
::
vector
<
float
>
inputs_data
(
batch_size
*
input_channel
_
*
h
*
w
);
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
std
::
copy
(
inputs_batch_
[
i
].
im_data_
.
begin
(),
std
::
copy
(
inputs_batch_
[
i
].
im_data_
.
begin
(),
inputs_batch_
[
i
].
im_data_
.
end
(),
inputs_batch_
[
i
].
im_data_
.
end
(),
inputs_data
.
begin
()
+
i
*
input_channel
*
h
*
w
);
inputs_data
.
begin
()
+
i
*
input_channel
_
*
h
*
w
);
}
}
in_tensor
->
copy_from_cpu
(
inputs_data
.
data
());
in_tensor
->
copy_from_cpu
(
inputs_data
.
data
());
// in_tensor->copy_from_cpu(inputs_.im_data_.data());
// in_tensor->copy_from_cpu(inputs_.im_data_.data());
...
@@ -290,7 +290,7 @@ bool Model::predict(const cv::Mat& im, DetResult* result) {
...
@@ -290,7 +290,7 @@ bool Model::predict(const cv::Mat& im, DetResult* result) {
int
h
=
inputs_
.
new_im_size_
[
0
];
int
h
=
inputs_
.
new_im_size_
[
0
];
int
w
=
inputs_
.
new_im_size_
[
1
];
int
w
=
inputs_
.
new_im_size_
[
1
];
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
im_tensor
->
Reshape
({
1
,
input_channel
,
h
,
w
});
im_tensor
->
Reshape
({
1
,
input_channel
_
,
h
,
w
});
im_tensor
->
copy_from_cpu
(
inputs_
.
im_data_
.
data
());
im_tensor
->
copy_from_cpu
(
inputs_
.
im_data_
.
data
());
if
(
name
==
"YOLOv3"
||
name
==
"PPYOLO"
)
{
if
(
name
==
"YOLOv3"
||
name
==
"PPYOLO"
)
{
...
@@ -444,12 +444,12 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
...
@@ -444,12 +444,12 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
int
h
=
inputs_batch_
[
0
].
new_im_size_
[
0
];
int
h
=
inputs_batch_
[
0
].
new_im_size_
[
0
];
int
w
=
inputs_batch_
[
0
].
new_im_size_
[
1
];
int
w
=
inputs_batch_
[
0
].
new_im_size_
[
1
];
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
im_tensor
->
Reshape
({
batch_size
,
input_channel
,
h
,
w
});
im_tensor
->
Reshape
({
batch_size
,
input_channel
_
,
h
,
w
});
std
::
vector
<
float
>
inputs_data
(
batch_size
*
input_channel
*
h
*
w
);
std
::
vector
<
float
>
inputs_data
(
batch_size
*
input_channel
_
*
h
*
w
);
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
std
::
copy
(
inputs_batch_
[
i
].
im_data_
.
begin
(),
std
::
copy
(
inputs_batch_
[
i
].
im_data_
.
begin
(),
inputs_batch_
[
i
].
im_data_
.
end
(),
inputs_batch_
[
i
].
im_data_
.
end
(),
inputs_data
.
begin
()
+
i
*
input_channel
*
h
*
w
);
inputs_data
.
begin
()
+
i
*
input_channel
_
*
h
*
w
);
}
}
im_tensor
->
copy_from_cpu
(
inputs_data
.
data
());
im_tensor
->
copy_from_cpu
(
inputs_data
.
data
());
if
(
name
==
"YOLOv3"
||
name
==
"PPYOLO"
)
{
if
(
name
==
"YOLOv3"
||
name
==
"PPYOLO"
)
{
...
@@ -589,7 +589,7 @@ bool Model::predict(const cv::Mat& im, SegResult* result) {
...
@@ -589,7 +589,7 @@ bool Model::predict(const cv::Mat& im, SegResult* result) {
int
h
=
inputs_
.
new_im_size_
[
0
];
int
h
=
inputs_
.
new_im_size_
[
0
];
int
w
=
inputs_
.
new_im_size_
[
1
];
int
w
=
inputs_
.
new_im_size_
[
1
];
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
im_tensor
->
Reshape
({
1
,
input_channel
,
h
,
w
});
im_tensor
->
Reshape
({
1
,
input_channel
_
,
h
,
w
});
im_tensor
->
copy_from_cpu
(
inputs_
.
im_data_
.
data
());
im_tensor
->
copy_from_cpu
(
inputs_
.
im_data_
.
data
());
// predict
// predict
...
@@ -703,12 +703,12 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
...
@@ -703,12 +703,12 @@ bool Model::predict(const std::vector<cv::Mat>& im_batch,
int
h
=
inputs_batch_
[
0
].
new_im_size_
[
0
];
int
h
=
inputs_batch_
[
0
].
new_im_size_
[
0
];
int
w
=
inputs_batch_
[
0
].
new_im_size_
[
1
];
int
w
=
inputs_batch_
[
0
].
new_im_size_
[
1
];
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
auto
im_tensor
=
predictor_
->
GetInputTensor
(
"image"
);
im_tensor
->
Reshape
({
batch_size
,
input_channel
,
h
,
w
});
im_tensor
->
Reshape
({
batch_size
,
input_channel
_
,
h
,
w
});
std
::
vector
<
float
>
inputs_data
(
batch_size
*
input_channel
*
h
*
w
);
std
::
vector
<
float
>
inputs_data
(
batch_size
*
input_channel
_
*
h
*
w
);
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
for
(
int
i
=
0
;
i
<
batch_size
;
++
i
)
{
std
::
copy
(
inputs_batch_
[
i
].
im_data_
.
begin
(),
std
::
copy
(
inputs_batch_
[
i
].
im_data_
.
begin
(),
inputs_batch_
[
i
].
im_data_
.
end
(),
inputs_batch_
[
i
].
im_data_
.
end
(),
inputs_data
.
begin
()
+
i
*
input_channel
*
h
*
w
);
inputs_data
.
begin
()
+
i
*
input_channel
_
*
h
*
w
);
}
}
im_tensor
->
copy_from_cpu
(
inputs_data
.
data
());
im_tensor
->
copy_from_cpu
(
inputs_data
.
data
());
// im_tensor->copy_from_cpu(inputs_.im_data_.data());
// im_tensor->copy_from_cpu(inputs_.im_data_.data());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录