Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
44ed5fed
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
接近 2 年 前同步成功
通知
116
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
44ed5fed
编写于
10月 11, 2020
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix cpp inference pre-process
上级
d923c5bb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
16 deletion
+10
-16
deploy/cpp_infer/include/preprocess_op.h
deploy/cpp_infer/include/preprocess_op.h
+1
-2
deploy/cpp_infer/src/cls.cpp
deploy/cpp_infer/src/cls.cpp
+2
-5
deploy/cpp_infer/src/preprocess_op.cpp
deploy/cpp_infer/src/preprocess_op.cpp
+7
-9
未找到文件。
deploy/cpp_infer/include/preprocess_op.h
浏览文件 @
44ed5fed
...
...
@@ -51,8 +51,7 @@ public:
class
ResizeImg
{
public:
virtual
void
Run
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
resize_img
,
int
max_size_len
,
float
&
ratio_h
,
float
&
ratio_w
);
virtual
void
Run
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
resize_img
,
int
max_size_len
);
};
}
// namespace PaddleClas
\ No newline at end of file
deploy/cpp_infer/src/cls.cpp
浏览文件 @
44ed5fed
...
...
@@ -47,15 +47,12 @@ void Classifier::LoadModel(const std::string &model_dir) {
}
void
Classifier
::
Run
(
cv
::
Mat
&
img
)
{
float
ratio_h
{};
float
ratio_w
{};
cv
::
Mat
srcimg
;
cv
::
Mat
resize_img
;
img
.
copyTo
(
srcimg
);
this
->
resize_op_
.
Run
(
img
,
resize_img
,
this
->
resize_short_size_
,
ratio_h
,
ratio_w
);
this
->
resize_op_
.
Run
(
img
,
resize_img
,
this
->
resize_short_size_
);
this
->
crop_op_
.
Run
(
resize_img
,
this
->
crop_size_
);
this
->
normalize_op_
.
Run
(
&
resize_img
,
this
->
mean_
,
this
->
scale_
,
...
...
deploy/cpp_infer/src/preprocess_op.cpp
浏览文件 @
44ed5fed
...
...
@@ -25,6 +25,7 @@
#include <cstring>
#include <fstream>
#include <math.h>
#include <numeric>
#include <include/preprocess_op.h>
...
...
@@ -68,25 +69,22 @@ void CenterCropImg::Run(cv::Mat &img, const int crop_size) {
img
=
img
(
rect
);
}
void
ResizeImg
::
Run
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
resize_img
,
int
max_size_len
,
float
&
ratio_h
,
float
&
ratio_w
)
{
void
ResizeImg
::
Run
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
resize_img
,
int
resize_short_size
)
{
int
w
=
img
.
cols
;
int
h
=
img
.
rows
;
float
ratio
=
1.
f
;
if
(
h
<
w
)
{
ratio
=
float
(
max_size_len
)
/
float
(
h
);
ratio
=
float
(
resize_short_size
)
/
float
(
h
);
}
else
{
ratio
=
float
(
max_size_len
)
/
float
(
w
);
ratio
=
float
(
resize_short_size
)
/
float
(
w
);
}
int
resize_h
=
int
(
float
(
h
)
*
ratio
);
int
resize_w
=
int
(
float
(
w
)
*
ratio
);
int
resize_h
=
round
(
float
(
h
)
*
ratio
);
int
resize_w
=
round
(
float
(
w
)
*
ratio
);
cv
::
resize
(
img
,
resize_img
,
cv
::
Size
(
resize_w
,
resize_h
));
ratio_h
=
float
(
resize_h
)
/
float
(
h
);
ratio_w
=
float
(
resize_w
)
/
float
(
w
);
}
}
// namespace PaddleClas
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录