Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
adac158d
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
285
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
adac158d
编写于
11月 04, 2019
作者:
J
joey12300
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change utils.h, seg_conf_parser.h to google code style.
上级
0fc9b582
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
258 addition
and
254 deletion
+258
-254
inference/utils/seg_conf_parser.h
inference/utils/seg_conf_parser.h
+165
-166
inference/utils/utils.h
inference/utils/utils.h
+93
-88
未找到文件。
inference/utils/seg_conf_parser.h
浏览文件 @
adac158d
...
@@ -13,14 +13,13 @@
...
@@ -13,14 +13,13 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <yaml-cpp/yaml.h>
#include <iostream>
#include <iostream>
#include <vector>
#include <vector>
#include <string>
#include <string>
#include <yaml-cpp/yaml.h>
namespace
PaddleSolution
{
namespace
PaddleSolution
{
class
PaddleSegModelConfigPaser
{
class
PaddleSegModelConfigPaser
{
public:
public:
PaddleSegModelConfigPaser
()
PaddleSegModelConfigPaser
()
:
_class_num
(
0
),
:
_class_num
(
0
),
...
@@ -70,7 +69,6 @@ namespace PaddleSolution {
...
@@ -70,7 +69,6 @@ namespace PaddleSolution {
}
}
bool
load_config
(
const
std
::
string
&
conf_file
)
{
bool
load_config
(
const
std
::
string
&
conf_file
)
{
reset
();
reset
();
YAML
::
Node
config
=
YAML
::
LoadFile
(
conf_file
);
YAML
::
Node
config
=
YAML
::
LoadFile
(
conf_file
);
...
@@ -97,7 +95,8 @@ namespace PaddleSolution {
...
@@ -97,7 +95,8 @@ namespace PaddleSolution {
// 8. get model file_name
// 8. get model file_name
_model_file_name
=
config
[
"DEPLOY"
][
"MODEL_FILENAME"
].
as
<
std
::
string
>
();
_model_file_name
=
config
[
"DEPLOY"
][
"MODEL_FILENAME"
].
as
<
std
::
string
>
();
// 9. get model param file name
// 9. get model param file name
_param_file_name
=
config
[
"DEPLOY"
][
"PARAMS_FILENAME"
].
as
<
std
::
string
>
();
_param_file_name
=
config
[
"DEPLOY"
][
"PARAMS_FILENAME"
].
as
<
std
::
string
>
();
// 10. get pre_processor
// 10. get pre_processor
_pre_processor
=
config
[
"DEPLOY"
][
"PRE_PROCESSOR"
].
as
<
std
::
string
>
();
_pre_processor
=
config
[
"DEPLOY"
][
"PRE_PROCESSOR"
].
as
<
std
::
string
>
();
// 11. use_gpu
// 11. use_gpu
...
@@ -112,9 +111,9 @@ namespace PaddleSolution {
...
@@ -112,9 +111,9 @@ namespace PaddleSolution {
}
}
void
debug
()
const
{
void
debug
()
const
{
std
::
cout
<<
"EVAL_CROP_SIZE: ("
std
::
cout
<<
"EVAL_CROP_SIZE: ("
<<
_resize
[
0
]
<<
", "
<<
_resize
[
1
]
<<
")"
<<
std
::
endl
;
<<
_resize
[
0
]
<<
", "
<<
_resize
[
1
]
<<
")"
<<
std
::
endl
;
std
::
cout
<<
"MEAN: ["
;
std
::
cout
<<
"MEAN: ["
;
for
(
int
i
=
0
;
i
<
_mean
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
_mean
.
size
();
++
i
)
{
if
(
i
!=
_mean
.
size
()
-
1
)
{
if
(
i
!=
_mean
.
size
()
-
1
)
{
...
@@ -129,8 +128,7 @@ namespace PaddleSolution {
...
@@ -129,8 +128,7 @@ namespace PaddleSolution {
for
(
int
i
=
0
;
i
<
_std
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
_std
.
size
();
++
i
)
{
if
(
i
!=
_std
.
size
()
-
1
)
{
if
(
i
!=
_std
.
size
()
-
1
)
{
std
::
cout
<<
_std
[
i
]
<<
", "
;
std
::
cout
<<
_std
[
i
]
<<
", "
;
}
}
else
{
else
{
std
::
cout
<<
_std
[
i
];
std
::
cout
<<
_std
[
i
];
}
}
}
}
...
@@ -141,7 +139,8 @@ namespace PaddleSolution {
...
@@ -141,7 +139,8 @@ namespace PaddleSolution {
std
::
cout
<<
"DEPLOY.CHANNELS: "
<<
_channels
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.CHANNELS: "
<<
_channels
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.MODEL_PATH: "
<<
_model_path
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.MODEL_PATH: "
<<
_model_path
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.MODEL_FILENAME: "
<<
_model_file_name
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.MODEL_FILENAME: "
<<
_model_file_name
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.PARAMS_FILENAME: "
<<
_param_file_name
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.PARAMS_FILENAME: "
<<
_param_file_name
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.PRE_PROCESSOR: "
<<
_pre_processor
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.PRE_PROCESSOR: "
<<
_pre_processor
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.USE_GPU: "
<<
_use_gpu
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.USE_GPU: "
<<
_use_gpu
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.PREDICTOR_MODE: "
<<
_predictor_mode
<<
std
::
endl
;
std
::
cout
<<
"DEPLOY.PREDICTOR_MODE: "
<<
_predictor_mode
<<
std
::
endl
;
...
@@ -174,6 +173,6 @@ namespace PaddleSolution {
...
@@ -174,6 +173,6 @@ namespace PaddleSolution {
std
::
string
_predictor_mode
;
std
::
string
_predictor_mode
;
// DEPLOY.BATCH_SIZE
// DEPLOY.BATCH_SIZE
int
_batch_size
;
int
_batch_size
;
};
};
}
}
// namespace PaddleSolution
inference/utils/utils.h
浏览文件 @
adac158d
...
@@ -30,8 +30,9 @@
...
@@ -30,8 +30,9 @@
#endif
#endif
namespace
PaddleSolution
{
namespace
PaddleSolution
{
namespace
utils
{
namespace
utils
{
inline
std
::
string
path_join
(
const
std
::
string
&
dir
,
const
std
::
string
&
path
)
{
inline
std
::
string
path_join
(
const
std
::
string
&
dir
,
const
std
::
string
&
path
)
{
std
::
string
seperator
=
"/"
;
std
::
string
seperator
=
"/"
;
#ifdef _WIN32
#ifdef _WIN32
seperator
=
"
\\
"
;
seperator
=
"
\\
"
;
...
@@ -40,8 +41,8 @@ namespace PaddleSolution {
...
@@ -40,8 +41,8 @@ namespace PaddleSolution {
}
}
#ifndef _WIN32
#ifndef _WIN32
// scan a directory and get all files with input extensions
// scan a directory and get all files with input extensions
inline
std
::
vector
<
std
::
string
>
get_directory_images
(
const
std
::
string
&
path
,
const
std
::
string
&
exts
)
inline
std
::
vector
<
std
::
string
>
get_directory_images
(
{
const
std
::
string
&
path
,
const
std
::
string
&
exts
)
{
std
::
vector
<
std
::
string
>
imgs
;
std
::
vector
<
std
::
string
>
imgs
;
struct
dirent
*
entry
;
struct
dirent
*
entry
;
DIR
*
dir
=
opendir
(
path
.
c_str
());
DIR
*
dir
=
opendir
(
path
.
c_str
());
...
@@ -64,13 +65,15 @@ namespace PaddleSolution {
...
@@ -64,13 +65,15 @@ namespace PaddleSolution {
}
}
#else
#else
// scan a directory and get all files with input extensions
// scan a directory and get all files with input extensions
inline
std
::
vector
<
std
::
string
>
get_directory_images
(
const
std
::
string
&
path
,
const
std
::
string
&
exts
)
inline
std
::
vector
<
std
::
string
>
get_directory_images
(
{
const
std
::
string
&
path
,
const
std
::
string
&
exts
)
{
std
::
vector
<
std
::
string
>
imgs
;
std
::
vector
<
std
::
string
>
imgs
;
for
(
const
auto
&
item
:
std
::
experimental
::
filesystem
::
directory_iterator
(
path
))
{
for
(
const
auto
&
item
:
std
::
experimental
::
filesystem
::
directory_iterator
(
path
))
{
auto
suffix
=
item
.
path
().
extension
().
string
();
auto
suffix
=
item
.
path
().
extension
().
string
();
if
(
exts
.
find
(
suffix
)
!=
std
::
string
::
npos
&&
suffix
.
size
()
>
0
)
{
if
(
exts
.
find
(
suffix
)
!=
std
::
string
::
npos
&&
suffix
.
size
()
>
0
)
{
auto
fullname
=
path_join
(
path
,
item
.
path
().
filename
().
string
());
auto
fullname
=
path_join
(
path
,
item
.
path
().
filename
().
string
());
imgs
.
push_back
(
item
.
path
().
string
());
imgs
.
push_back
(
item
.
path
().
string
());
}
}
}
}
...
@@ -79,11 +82,12 @@ namespace PaddleSolution {
...
@@ -79,11 +82,12 @@ namespace PaddleSolution {
#endif
#endif
// normalize and HWC_BGR -> CHW_RGB
// normalize and HWC_BGR -> CHW_RGB
inline
void
normalize
(
cv
::
Mat
&
im
,
float
*
data
,
std
::
vector
<
float
>&
fmean
,
std
::
vector
<
float
>&
fstd
)
{
inline
void
normalize
(
cv
::
Mat
&
im
,
float
*
data
,
std
::
vector
<
float
>&
fmean
,
std
::
vector
<
float
>&
fstd
)
{
int
rh
=
im
.
rows
;
int
rh
=
im
.
rows
;
int
rw
=
im
.
cols
;
int
rw
=
im
.
cols
;
int
rc
=
im
.
channels
();
int
rc
=
im
.
channels
();
double
normf
=
(
double
)
1.0
/
255.0
;
double
normf
=
static_cast
<
double
>
(
1.0
)
/
255.0
;
#pragma omp parallel for
#pragma omp parallel for
for
(
int
h
=
0
;
h
<
rh
;
++
h
)
{
for
(
int
h
=
0
;
h
<
rh
;
++
h
)
{
const
uchar
*
ptr
=
im
.
ptr
<
uchar
>
(
h
);
const
uchar
*
ptr
=
im
.
ptr
<
uchar
>
(
h
);
...
@@ -100,7 +104,8 @@ namespace PaddleSolution {
...
@@ -100,7 +104,8 @@ namespace PaddleSolution {
}
}
// argmax
// argmax
inline
void
argmax
(
float
*
out
,
std
::
vector
<
int
>&
shape
,
std
::
vector
<
uchar
>&
mask
,
std
::
vector
<
uchar
>&
scoremap
)
{
inline
void
argmax
(
float
*
out
,
std
::
vector
<
int
>&
shape
,
std
::
vector
<
uchar
>&
mask
,
std
::
vector
<
uchar
>&
scoremap
)
{
int
out_img_len
=
shape
[
1
]
*
shape
[
2
];
int
out_img_len
=
shape
[
1
]
*
shape
[
2
];
int
blob_out_len
=
out_img_len
*
shape
[
0
];
int
blob_out_len
=
out_img_len
*
shape
[
0
];
/*
/*
...
@@ -130,5 +135,5 @@ namespace PaddleSolution {
...
@@ -130,5 +135,5 @@ namespace PaddleSolution {
scoremap
[
i
]
=
uchar
(
max_value
*
255
);
scoremap
[
i
]
=
uchar
(
max_value
*
255
);
}
}
}
}
}
}
// namespace utils
}
}
// namespace PaddleSolution
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录