Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
c902676e
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c902676e
编写于
11月 11, 2021
作者:
W
wangguanzhong
提交者:
GitHub
11月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MOT]add model_dir as input (#4543)
* add model_dir as input * unify log output
上级
d3927dde
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
29 deletion
+84
-29
deploy/pptracking/include/pipeline.h
deploy/pptracking/include/pipeline.h
+14
-3
deploy/pptracking/src/main.cc
deploy/pptracking/src/main.cc
+21
-8
deploy/pptracking/src/pipeline.cc
deploy/pptracking/src/pipeline.cc
+49
-18
未找到文件。
deploy/pptracking/include/pipeline.h
浏览文件 @
c902676e
...
...
@@ -53,7 +53,10 @@ class Pipeline {
const
std
::
string
&
scene
=
"pedestrian"
,
const
bool
tiny_obj
=
false
,
const
bool
is_mtmct
=
false
,
const
int
secs_interval
=
10
)
{
const
int
secs_interval
=
10
,
const
std
::
string
track_model_dir
=
""
,
const
std
::
string
det_model_dir
=
""
,
const
std
::
string
reid_model_dir
=
""
)
{
std
::
vector
<
std
::
string
>
input
;
this
->
input_
=
input
;
this
->
device_
=
device
;
...
...
@@ -67,7 +70,12 @@ class Pipeline {
this
->
do_entrance_counting_
=
do_entrance_counting
;
this
->
secs_interval_
=
secs_interval_
;
this
->
save_result_
=
save_result
;
SelectModel
(
scene
,
tiny_obj
,
is_mtmct
);
SelectModel
(
scene
,
tiny_obj
,
is_mtmct
,
track_model_dir
,
det_model_dir
,
reid_model_dir
);
InitPredictor
();
}
...
...
@@ -102,7 +110,10 @@ class Pipeline {
// Select model according to scenes, it must execute before Run()
void
SelectModel
(
const
std
::
string
&
scene
=
"pedestrian"
,
const
bool
tiny_obj
=
false
,
const
bool
is_mtmct
=
false
);
const
bool
is_mtmct
=
false
,
const
std
::
string
track_model_dir
=
""
,
const
std
::
string
det_model_dir
=
""
,
const
std
::
string
reid_model_dir
=
""
);
void
InitPredictor
();
std
::
shared_ptr
<
PaddleDetection
::
JDEPredictor
>
jde_sct_
;
...
...
deploy/pptracking/src/main.cc
浏览文件 @
c902676e
...
...
@@ -54,7 +54,8 @@ DEFINE_bool(trt_calib_mode,
"If the model is produced by TRT offline quantitative calibration, "
"trt_calib_mode need to set True"
);
DEFINE_bool
(
tiny_obj
,
false
,
"Whether tracking tiny object"
);
DEFINE_bool
(
do_entrance_counting
,
false
,
DEFINE_bool
(
do_entrance_counting
,
false
,
"Whether counting the numbers of identifiers entering "
"or getting out from the entrance."
);
DEFINE_int32
(
secs_interval
,
10
,
"The seconds interval to count after tracking"
);
...
...
@@ -64,6 +65,9 @@ DEFINE_string(
""
,
"scene of tracking system, it can be : pedestrian/vehicle/multiclass"
);
DEFINE_bool
(
is_mtmct
,
false
,
"Whether use multi-target multi-camera tracking"
);
DEFINE_string
(
track_model_dir
,
""
,
"Path of tracking model"
);
DEFINE_string
(
det_model_dir
,
""
,
"Path of detection model"
);
DEFINE_string
(
reid_model_dir
,
""
,
"Path of reid model"
);
static
std
::
string
DirName
(
const
std
::
string
&
filepath
)
{
auto
pos
=
filepath
.
rfind
(
OS_PATH_SEP
);
...
...
@@ -109,15 +113,21 @@ static void MkDirs(const std::string& path) {
int
main
(
int
argc
,
char
**
argv
)
{
// Parsing command-line
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
if
(
FLAGS_video_file
.
empty
()
||
FLAGS_scene
.
empty
())
{
std
::
cout
<<
"Usage: ./main "
<<
"-video_file=/PATH/TO/INPUT/IMAGE/ "
<<
"-scene=pedestrian/vehicle/multiclass"
<<
std
::
endl
;
bool
has_model_dir
=
!
(
FLAGS_track_model_dir
.
empty
()
&&
FLAGS_det_model_dir
.
empty
()
&&
FLAGS_reid_model_dir
.
empty
());
if
(
FLAGS_video_file
.
empty
()
||
(
FLAGS_scene
.
empty
()
&&
!
has_model_dir
))
{
LOG
(
ERROR
)
<<
"Usage:
\n
"
<<
"1. ./main -video_file=/PATH/TO/INPUT/IMAGE/ "
<<
"-scene=pedestrian/vehicle/multiclass
\n
"
<<
"2. ./main -video_file=/PATH/TO/INPUT/IMAGE/ "
<<
"-track_model_dir=/PATH/TO/MODEL_DIR"
<<
std
::
endl
;
return
-
1
;
}
if
(
!
(
FLAGS_run_mode
==
"fluid"
||
FLAGS_run_mode
==
"trt_fp32"
||
FLAGS_run_mode
==
"trt_fp16"
||
FLAGS_run_mode
==
"trt_int8"
))
{
std
::
cout
LOG
(
ERROR
)
<<
"run_mode should be 'fluid', 'trt_fp32', 'trt_fp16' or 'trt_int8'."
;
return
-
1
;
}
...
...
@@ -127,7 +137,7 @@ int main(int argc, char** argv) {
::
toupper
);
if
(
!
(
FLAGS_device
==
"CPU"
||
FLAGS_device
==
"GPU"
||
FLAGS_device
==
"XPU"
))
{
std
::
cout
<<
"device should be 'CPU', 'GPU' or 'XPU'."
;
LOG
(
ERROR
)
<<
"device should be 'CPU', 'GPU' or 'XPU'."
;
return
-
1
;
}
...
...
@@ -148,7 +158,10 @@ int main(int argc, char** argv) {
FLAGS_scene
,
FLAGS_tiny_obj
,
FLAGS_is_mtmct
,
FLAGS_secs_interval
);
FLAGS_secs_interval
,
FLAGS_track_model_dir
,
FLAGS_det_model_dir
,
FLAGS_reid_model_dir
);
pipeline
.
SetInput
(
FLAGS_video_file
);
if
(
!
FLAGS_video_other_file
.
empty
())
{
...
...
deploy/pptracking/src/pipeline.cc
浏览文件 @
c902676e
...
...
@@ -36,7 +36,21 @@ void Pipeline::ClearInput() {
void
Pipeline
::
SelectModel
(
const
std
::
string
&
scene
,
const
bool
tiny_obj
,
const
bool
is_mtmct
)
{
const
bool
is_mtmct
,
const
std
::
string
track_model_dir
,
const
std
::
string
det_model_dir
,
const
std
::
string
reid_model_dir
)
{
// model_dir has higher priority
if
(
!
track_model_dir
.
empty
())
{
track_model_dir_
=
track_model_dir
;
return
;
}
if
(
!
det_model_dir
.
empty
()
&&
!
reid_model_dir
.
empty
())
{
det_model_dir_
=
det_model_dir
;
reid_model_dir_
=
reid_model_dir
;
return
;
}
// Single camera model, based on FairMot
if
(
scene
==
"pedestrian"
)
{
if
(
tiny_obj
)
{
...
...
@@ -100,11 +114,11 @@ void Pipeline::InitPredictor() {
void
Pipeline
::
Run
()
{
if
(
track_model_dir_
.
empty
()
&&
det_model_dir_
.
empty
())
{
std
::
cout
<<
"Pipeline must use SelectModel before Run"
;
LOG
(
ERROR
)
<<
"Pipeline must use SelectModel before Run"
;
return
;
}
if
(
input_
.
size
()
==
0
)
{
std
::
cout
<<
"Pipeline must use SetInput before Run"
;
LOG
(
ERROR
)
<<
"Pipeline must use SetInput before Run"
;
return
;
}
...
...
@@ -165,7 +179,8 @@ void Pipeline::PredictMOT(const std::string& video_path) {
std
::
vector
<
int
>
in_id_list
;
std
::
vector
<
int
>
out_id_list
;
std
::
map
<
int
,
std
::
vector
<
float
>>
prev_center
;
Rect
entrance
=
{
0
,
static_cast
<
float
>
(
video_height
)
/
2
,
Rect
entrance
=
{
0
,
static_cast
<
float
>
(
video_height
)
/
2
,
static_cast
<
float
>
(
video_width
),
static_cast
<
float
>
(
video_height
)
/
2
};
double
times
;
...
...
@@ -195,12 +210,20 @@ void Pipeline::PredictMOT(const std::string& video_path) {
cv
::
Mat
out_img
=
PaddleDetection
::
VisualizeTrackResult
(
frame
,
result
,
1000.
/
times
,
frame_id
);
// TODO: the entrance line can be set by users
PaddleDetection
::
FlowStatistic
(
result
,
frame_id
,
secs_interval_
,
do_entrance_counting_
,
video_fps
,
entrance
,
&
id_set
,
&
interval_id_set
,
&
in_id_list
,
&
out_id_list
,
&
prev_center
,
&
flow_records
);
// TODO(qianhui): the entrance line can be set by users
PaddleDetection
::
FlowStatistic
(
result
,
frame_id
,
secs_interval_
,
do_entrance_counting_
,
video_fps
,
entrance
,
&
id_set
,
&
interval_id_set
,
&
in_id_list
,
&
out_id_list
,
&
prev_center
,
&
flow_records
);
if
(
save_result_
)
{
PaddleDetection
::
SaveMOTResult
(
result
,
frame_id
,
&
records
);
...
...
@@ -228,7 +251,7 @@ void Pipeline::PredictMOT(const std::string& video_path) {
fclose
(
fp
);
LOG
(
INFO
)
<<
"txt result output saved as "
<<
result_output_path
.
c_str
();
result_output_path
=
output_dir_
+
OS_PATH_SEP
+
"flow_statistic.txt"
;
if
((
fp
=
fopen
(
result_output_path
.
c_str
(),
"w+"
))
==
NULL
)
{
printf
(
"Open %s error.
\n
"
,
result_output_path
);
...
...
@@ -273,15 +296,23 @@ void Pipeline::RunMOTStream(const cv::Mat img,
LOG
(
INFO
)
<<
"frame_id: "
<<
frame_id
<<
" predict time(s): "
<<
total_time
/
1000
;
out_img
=
PaddleDetection
::
VisualizeTrackResult
(
img
,
result
,
1000.
/
times
,
frame_id
);
out_img
=
PaddleDetection
::
VisualizeTrackResult
(
img
,
result
,
1000.
/
times
,
frame_id
);
// Count total number
// Count in & out number
PaddleDetection
::
FlowStatistic
(
result
,
frame_id
,
secs_interval_
,
do_entrance_counting_
,
video_fps
,
entrance
,
id_set
,
interval_id_set
,
in_id_list
,
out_id_list
,
prev_center
,
flow_records
);
PaddleDetection
::
FlowStatistic
(
result
,
frame_id
,
secs_interval_
,
do_entrance_counting_
,
video_fps
,
entrance
,
id_set
,
interval_id_set
,
in_id_list
,
out_id_list
,
prev_center
,
flow_records
);
PrintBenchmarkLog
(
det_times
,
frame_id
);
if
(
save_result_
)
{
...
...
@@ -326,4 +357,4 @@ void Pipeline::PrintBenchmarkLog(const std::vector<double> det_time,
<<
", postprocess_time(ms): "
<<
det_time
[
2
]
/
num
;
}
}
// namespace PaddleDetection
}
// namespace PaddleDetection
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录