Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
f677f61e
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
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看板
未验证
提交
f677f61e
编写于
5月 11, 2022
作者:
W
Walter
提交者:
GitHub
5月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1913 from HydrogenSulfate/release/2.3
[cherry-pick] change labe_list to label_list
上级
8cc4295e
bd5aee15
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
107 addition
and
107 deletion
+107
-107
deploy/configs/inference_cartoon.yaml
deploy/configs/inference_cartoon.yaml
+1
-1
deploy/configs/inference_det.yaml
deploy/configs/inference_det.yaml
+1
-1
deploy/configs/inference_drink.yaml
deploy/configs/inference_drink.yaml
+1
-1
deploy/configs/inference_general.yaml
deploy/configs/inference_general.yaml
+1
-1
deploy/configs/inference_general_binary.yaml
deploy/configs/inference_general_binary.yaml
+1
-1
deploy/configs/inference_logo.yaml
deploy/configs/inference_logo.yaml
+1
-1
deploy/configs/inference_product.yaml
deploy/configs/inference_product.yaml
+1
-1
deploy/configs/inference_vehicle.yaml
deploy/configs/inference_vehicle.yaml
+1
-1
deploy/cpp_shitu/include/object_detector.h
deploy/cpp_shitu/include/object_detector.h
+97
-97
deploy/lite_shitu/generate_json_config.py
deploy/lite_shitu/generate_json_config.py
+1
-1
deploy/python/predict_det.py
deploy/python/predict_det.py
+1
-1
未找到文件。
deploy/configs/inference_cartoon.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
use_gpu
:
True
...
...
deploy/configs/inference_det.yaml
浏览文件 @
f677f61e
...
...
@@ -5,7 +5,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
1
labe_list
:
labe
l
_list
:
-
foreground
# inference engine config
...
...
deploy/configs/inference_drink.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
use_gpu
:
True
...
...
deploy/configs/inference_general.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
use_gpu
:
True
...
...
deploy/configs/inference_general_binary.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
use_gpu
:
True
...
...
deploy/configs/inference_logo.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
use_gpu
:
True
...
...
deploy/configs/inference_product.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
# inference engine config
...
...
deploy/configs/inference_vehicle.yaml
浏览文件 @
f677f61e
...
...
@@ -8,7 +8,7 @@ Global:
image_shape
:
[
3
,
640
,
640
]
threshold
:
0.2
max_det_results
:
5
labe_list
:
labe
l
_list
:
-
foreground
use_gpu
:
True
...
...
deploy/cpp_shitu/include/object_detector.h
浏览文件 @
f677f61e
...
...
@@ -33,106 +33,106 @@ using namespace paddle_infer;
namespace
Detection
{
// Object Detection Result
struct
ObjectResult
{
// Rectangle coordinates of detected object: left, right, top, down
std
::
vector
<
int
>
rect
;
// Class id of detected object
int
class_id
;
// Confidence of detected object
float
confidence
;
};
struct
ObjectResult
{
// Rectangle coordinates of detected object: left, right, top, down
std
::
vector
<
int
>
rect
;
// Class id of detected object
int
class_id
;
// Confidence of detected object
float
confidence
;
};
// Generate visualization colormap for each class
std
::
vector
<
int
>
GenerateColorMap
(
int
num_class
);
std
::
vector
<
int
>
GenerateColorMap
(
int
num_class
);
// Visualiztion Detection Result
cv
::
Mat
VisualizeResult
(
const
cv
::
Mat
&
img
,
const
std
::
vector
<
ObjectResult
>
&
results
,
const
std
::
vector
<
std
::
string
>
&
lables
,
const
std
::
vector
<
int
>
&
colormap
,
const
bool
is_rbox
);
class
ObjectDetector
{
public:
explicit
ObjectDetector
(
const
YAML
::
Node
&
config_file
)
{
this
->
use_gpu_
=
config_file
[
"Global"
][
"use_gpu"
].
as
<
bool
>
();
if
(
config_file
[
"Global"
][
"gpu_id"
].
IsDefined
())
this
->
gpu_id_
=
config_file
[
"Global"
][
"gpu_id"
].
as
<
int
>
();
this
->
gpu_mem_
=
config_file
[
"Global"
][
"gpu_mem"
].
as
<
int
>
();
this
->
cpu_math_library_num_threads_
=
config_file
[
"Global"
][
"cpu_num_threads"
].
as
<
int
>
();
this
->
use_mkldnn_
=
config_file
[
"Global"
][
"enable_mkldnn"
].
as
<
bool
>
();
this
->
use_tensorrt_
=
config_file
[
"Global"
][
"use_tensorrt"
].
as
<
bool
>
();
this
->
use_fp16_
=
config_file
[
"Global"
][
"use_fp16"
].
as
<
bool
>
();
this
->
model_dir_
=
config_file
[
"Global"
][
"det_inference_model_dir"
].
as
<
std
::
string
>
();
this
->
threshold_
=
config_file
[
"Global"
][
"threshold"
].
as
<
float
>
();
this
->
max_det_results_
=
config_file
[
"Global"
][
"max_det_results"
].
as
<
int
>
();
this
->
image_shape_
=
config_file
[
"Global"
][
"image_shape"
].
as
<
std
::
vector
<
int
>>
();
this
->
label_list_
=
config_file
[
"Global"
][
"labe_list"
].
as
<
std
::
vector
<
std
::
string
>>
();
this
->
ir_optim_
=
config_file
[
"Global"
][
"ir_optim"
].
as
<
bool
>
();
this
->
batch_size_
=
config_file
[
"Global"
][
"batch_size"
].
as
<
int
>
();
preprocessor_
.
Init
(
config_file
[
"DetPreProcess"
][
"transform_ops"
]);
LoadModel
(
model_dir_
,
batch_size_
,
run_mode
);
}
// Load Paddle inference model
void
LoadModel
(
const
std
::
string
&
model_dir
,
const
int
batch_size
=
1
,
const
std
::
string
&
run_mode
=
"fluid"
);
// Run predictor
void
Predict
(
const
std
::
vector
<
cv
::
Mat
>
imgs
,
const
int
warmup
=
0
,
const
int
repeats
=
1
,
std
::
vector
<
ObjectResult
>
*
result
=
nullptr
,
std
::
vector
<
int
>
*
bbox_num
=
nullptr
,
std
::
vector
<
double
>
*
times
=
nullptr
);
const
std
::
vector
<
std
::
string
>
&
GetLabelList
()
const
{
return
this
->
label_list_
;
}
const
float
&
GetThreshold
()
const
{
return
this
->
threshold_
;
}
private:
bool
use_gpu_
=
true
;
int
gpu_id_
=
0
;
int
gpu_mem_
=
800
;
int
cpu_math_library_num_threads_
=
6
;
std
::
string
run_mode
=
"fluid"
;
bool
use_mkldnn_
=
false
;
bool
use_tensorrt_
=
false
;
bool
batch_size_
=
1
;
bool
use_fp16_
=
false
;
std
::
string
model_dir_
;
float
threshold_
=
0.5
;
float
max_det_results_
=
5
;
std
::
vector
<
int
>
image_shape_
=
{
3
,
640
,
640
};
std
::
vector
<
std
::
string
>
label_list_
;
bool
ir_optim_
=
true
;
bool
det_permute_
=
true
;
bool
det_postprocess_
=
true
;
int
min_subgraph_size_
=
30
;
bool
use_dynamic_shape_
=
false
;
int
trt_min_shape_
=
1
;
int
trt_max_shape_
=
1280
;
int
trt_opt_shape_
=
640
;
bool
trt_calib_mode_
=
false
;
// Preprocess image and copy data to input buffer
void
Preprocess
(
const
cv
::
Mat
&
image_mat
);
// Postprocess result
void
Postprocess
(
const
std
::
vector
<
cv
::
Mat
>
mats
,
std
::
vector
<
ObjectResult
>
*
result
,
std
::
vector
<
int
>
bbox_num
,
bool
is_rbox
);
std
::
shared_ptr
<
Predictor
>
predictor_
;
Preprocessor
preprocessor_
;
ImageBlob
inputs_
;
std
::
vector
<
float
>
output_data_
;
std
::
vector
<
int
>
out_bbox_num_data_
;
};
cv
::
Mat
VisualizeResult
(
const
cv
::
Mat
&
img
,
const
std
::
vector
<
ObjectResult
>
&
results
,
const
std
::
vector
<
std
::
string
>
&
lables
,
const
std
::
vector
<
int
>
&
colormap
,
const
bool
is_rbox
);
class
ObjectDetector
{
public:
explicit
ObjectDetector
(
const
YAML
::
Node
&
config_file
)
{
this
->
use_gpu_
=
config_file
[
"Global"
][
"use_gpu"
].
as
<
bool
>
();
if
(
config_file
[
"Global"
][
"gpu_id"
].
IsDefined
())
this
->
gpu_id_
=
config_file
[
"Global"
][
"gpu_id"
].
as
<
int
>
();
this
->
gpu_mem_
=
config_file
[
"Global"
][
"gpu_mem"
].
as
<
int
>
();
this
->
cpu_math_library_num_threads_
=
config_file
[
"Global"
][
"cpu_num_threads"
].
as
<
int
>
();
this
->
use_mkldnn_
=
config_file
[
"Global"
][
"enable_mkldnn"
].
as
<
bool
>
();
this
->
use_tensorrt_
=
config_file
[
"Global"
][
"use_tensorrt"
].
as
<
bool
>
();
this
->
use_fp16_
=
config_file
[
"Global"
][
"use_fp16"
].
as
<
bool
>
();
this
->
model_dir_
=
config_file
[
"Global"
][
"det_inference_model_dir"
].
as
<
std
::
string
>
();
this
->
threshold_
=
config_file
[
"Global"
][
"threshold"
].
as
<
float
>
();
this
->
max_det_results_
=
config_file
[
"Global"
][
"max_det_results"
].
as
<
int
>
();
this
->
image_shape_
=
config_file
[
"Global"
][
"image_shape"
].
as
<
std
::
vector
<
int
>>
();
this
->
label_list_
=
config_file
[
"Global"
][
"label_list"
].
as
<
std
::
vector
<
std
::
string
>>
();
this
->
ir_optim_
=
config_file
[
"Global"
][
"ir_optim"
].
as
<
bool
>
();
this
->
batch_size_
=
config_file
[
"Global"
][
"batch_size"
].
as
<
int
>
();
preprocessor_
.
Init
(
config_file
[
"DetPreProcess"
][
"transform_ops"
]);
LoadModel
(
model_dir_
,
batch_size_
,
run_mode
);
}
// Load Paddle inference model
void
LoadModel
(
const
std
::
string
&
model_dir
,
const
int
batch_size
=
1
,
const
std
::
string
&
run_mode
=
"fluid"
);
// Run predictor
void
Predict
(
const
std
::
vector
<
cv
::
Mat
>
imgs
,
const
int
warmup
=
0
,
const
int
repeats
=
1
,
std
::
vector
<
ObjectResult
>
*
result
=
nullptr
,
std
::
vector
<
int
>
*
bbox_num
=
nullptr
,
std
::
vector
<
double
>
*
times
=
nullptr
);
const
std
::
vector
<
std
::
string
>
&
GetLabelList
()
const
{
return
this
->
label_list_
;
}
const
float
&
GetThreshold
()
const
{
return
this
->
threshold_
;
}
private:
bool
use_gpu_
=
true
;
int
gpu_id_
=
0
;
int
gpu_mem_
=
800
;
int
cpu_math_library_num_threads_
=
6
;
std
::
string
run_mode
=
"fluid"
;
bool
use_mkldnn_
=
false
;
bool
use_tensorrt_
=
false
;
bool
batch_size_
=
1
;
bool
use_fp16_
=
false
;
std
::
string
model_dir_
;
float
threshold_
=
0.5
;
float
max_det_results_
=
5
;
std
::
vector
<
int
>
image_shape_
=
{
3
,
640
,
640
};
std
::
vector
<
std
::
string
>
label_list_
;
bool
ir_optim_
=
true
;
bool
det_permute_
=
true
;
bool
det_postprocess_
=
true
;
int
min_subgraph_size_
=
30
;
bool
use_dynamic_shape_
=
false
;
int
trt_min_shape_
=
1
;
int
trt_max_shape_
=
1280
;
int
trt_opt_shape_
=
640
;
bool
trt_calib_mode_
=
false
;
// Preprocess image and copy data to input buffer
void
Preprocess
(
const
cv
::
Mat
&
image_mat
);
// Postprocess result
void
Postprocess
(
const
std
::
vector
<
cv
::
Mat
>
mats
,
std
::
vector
<
ObjectResult
>
*
result
,
std
::
vector
<
int
>
bbox_num
,
bool
is_rbox
);
std
::
shared_ptr
<
Predictor
>
predictor_
;
Preprocessor
preprocessor_
;
ImageBlob
inputs_
;
std
::
vector
<
float
>
output_data_
;
std
::
vector
<
int
>
out_bbox_num_data_
;
};
}
// namespace Detection
deploy/lite_shitu/generate_json_config.py
浏览文件 @
f677f61e
...
...
@@ -95,7 +95,7 @@ def main():
config_json
[
"Global"
][
"det_model_path"
]
=
args
.
det_model_path
config_json
[
"Global"
][
"rec_model_path"
]
=
args
.
rec_model_path
config_json
[
"Global"
][
"rec_label_path"
]
=
args
.
rec_label_path
config_json
[
"Global"
][
"label_list"
]
=
config_yaml
[
"Global"
][
"labe_list"
]
config_json
[
"Global"
][
"label_list"
]
=
config_yaml
[
"Global"
][
"labe
l
_list"
]
config_json
[
"Global"
][
"rec_nms_thresold"
]
=
config_yaml
[
"Global"
][
"rec_nms_thresold"
]
config_json
[
"Global"
][
"max_det_results"
]
=
config_yaml
[
"Global"
][
...
...
deploy/python/predict_det.py
浏览文件 @
f677f61e
...
...
@@ -134,7 +134,7 @@ class DetPredictor(Predictor):
results
=
self
.
parse_det_results
(
results
,
self
.
config
[
"Global"
][
"threshold"
],
self
.
config
[
"Global"
][
"labe_list"
])
self
.
config
[
"Global"
][
"labe
l
_list"
])
return
results
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录