Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
deadba2c
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
deadba2c
编写于
10月 29, 2021
作者:
C
chenjian
提交者:
GitHub
10月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix MOT module bug (#1665)
上级
756d321a
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
122 addition
and
108 deletion
+122
-108
modules/video/multiple_object_tracking/fairmot_dla34/README.md
...es/video/multiple_object_tracking/fairmot_dla34/README.md
+2
-1
modules/video/multiple_object_tracking/fairmot_dla34/module.py
...es/video/multiple_object_tracking/fairmot_dla34/module.py
+45
-43
modules/video/multiple_object_tracking/fairmot_dla34/requirements.txt
...o/multiple_object_tracking/fairmot_dla34/requirements.txt
+3
-1
modules/video/multiple_object_tracking/fairmot_dla34/tracker.py
...s/video/multiple_object_tracking/fairmot_dla34/tracker.py
+9
-9
modules/video/multiple_object_tracking/jde_darknet53/README.md
...es/video/multiple_object_tracking/jde_darknet53/README.md
+2
-1
modules/video/multiple_object_tracking/jde_darknet53/module.py
...es/video/multiple_object_tracking/jde_darknet53/module.py
+45
-43
modules/video/multiple_object_tracking/jde_darknet53/requirements.txt
...o/multiple_object_tracking/jde_darknet53/requirements.txt
+3
-1
modules/video/multiple_object_tracking/jde_darknet53/tracker.py
...s/video/multiple_object_tracking/jde_darknet53/tracker.py
+13
-9
未找到文件。
modules/video/multiple_object_tracking/fairmot_dla34/README.md
浏览文件 @
deadba2c
...
...
@@ -31,7 +31,7 @@
-
### 1、环境依赖
-
paddledet >= 2.
1
.0
-
paddledet >= 2.
2
.0
-
opencv-python
...
...
@@ -42,6 +42,7 @@
```
-
如您安装时遇到问题,可参考:
[
零基础windows安装
](
../../../../docs/docs_ch/get_start/windows_quickstart.md
)
|
[
零基础Linux安装
](
../../../../docs/docs_ch/get_start/linux_quickstart.md
)
|
[
零基础MacOS安装
](
../../../../docs/docs_ch/get_start/mac_quickstart.md
)
-
在windows下安装,由于paddledet package会依赖cython-bbox以及pycocotools, 这两个包需要windows用户提前装好,可参考
[
cython-bbox安装
](
https://blog.csdn.net/qq_24739717/article/details/105588729
)
和
[
pycocotools安装
](
https://github.com/PaddlePaddle/PaddleX/blob/release/1.3/docs/install.md#pycocotools安装问题
)
## 三、模型API预测
-
### 1、命令行预测
...
...
modules/video/multiple_object_tracking/fairmot_dla34/module.py
浏览文件 @
deadba2c
...
...
@@ -31,7 +31,8 @@ from .tracker import StreamTracker
logger
=
setup_logger
(
'Predict'
)
@
moduleinfo
(
name
=
"fairmot_dla34"
,
@
moduleinfo
(
name
=
"fairmot_dla34"
,
type
=
"CV/multiple_object_tracking"
,
author
=
"paddlepaddle"
,
author_email
=
""
,
...
...
@@ -70,7 +71,8 @@ class FairmotTracker_1088x608:
tracker
.
load_weights_jde
(
self
.
pretrained_model
)
signal
.
signal
(
signal
.
SIGINT
,
self
.
signalhandler
)
# inference
tracker
.
videostream_predict
(
video_stream
=
video_stream
,
tracker
.
videostream_predict
(
video_stream
=
video_stream
,
output_dir
=
output_dir
,
data_type
=
'mot'
,
model_type
=
'FairMOT'
,
...
...
@@ -106,7 +108,8 @@ class FairmotTracker_1088x608:
return
self
def
__enter__
(
self
):
self
.
tracker_generator
=
self
.
tracker
.
imagestream_predict
(
self
.
output_dir
,
self
.
tracker_generator
=
self
.
tracker
.
imagestream_predict
(
self
.
output_dir
,
data_type
=
'mot'
,
model_type
=
'FairMOT'
,
visualization
=
self
.
visualization
,
...
...
@@ -129,10 +132,12 @@ class FairmotTracker_1088x608:
logger
.
info
(
'No output images to save for video'
)
return
img
=
cv2
.
imread
(
os
.
path
.
join
(
save_dir
,
'00000.jpg'
))
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
apiPreference
=
0
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
[
img
.
shape
[
1
],
img
.
shape
[
0
]]
)
frameSize
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
)
for
i
in
range
(
len
(
imgnames
)):
imgpath
=
os
.
path
.
join
(
save_dir
,
'{:05d}.jpg'
.
format
(
i
))
img
=
cv2
.
imread
(
imgpath
)
...
...
@@ -169,7 +174,8 @@ class FairmotTracker_1088x608:
"""
Run as a command.
"""
self
.
parser
=
argparse
.
ArgumentParser
(
description
=
"Run the {} module."
.
format
(
self
.
name
),
self
.
parser
=
argparse
.
ArgumentParser
(
description
=
"Run the {} module."
.
format
(
self
.
name
),
prog
=
'hub run {}'
.
format
(
self
.
name
),
usage
=
'%(prog)s'
,
add_help
=
True
)
...
...
@@ -204,10 +210,12 @@ class FairmotTracker_1088x608:
logger
.
info
(
'No output images to save for video'
)
return
img
=
cv2
.
imread
(
os
.
path
.
join
(
save_dir
,
'00000.jpg'
))
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
apiPreference
=
0
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
[
img
.
shape
[
1
],
img
.
shape
[
0
]]
)
frameSize
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
)
for
i
in
range
(
len
(
imgnames
)):
imgpath
=
os
.
path
.
join
(
save_dir
,
'{:05d}.jpg'
.
format
(
i
))
img
=
cv2
.
imread
(
imgpath
)
...
...
@@ -223,22 +231,16 @@ class FairmotTracker_1088x608:
"""
self
.
arg_config_group
.
add_argument
(
'--use_gpu'
,
action
=
'store_true'
,
help
=
"use GPU or not"
)
self
.
arg_config_group
.
add_argument
(
'--output_dir'
,
type
=
str
,
default
=
'mot_result'
,
help
=
'Directory name for output tracking results.'
)
self
.
arg_config_group
.
add_argument
(
'--visualization'
,
action
=
'store_true'
,
help
=
"whether to save output as images."
)
self
.
arg_config_group
.
add_argument
(
"--draw_threshold"
,
type
=
float
,
default
=
0.5
,
help
=
"Threshold to reserve the result for visualization."
)
self
.
arg_config_group
.
add_argument
(
'--output_dir'
,
type
=
str
,
default
=
'mot_result'
,
help
=
'Directory name for output tracking results.'
)
self
.
arg_config_group
.
add_argument
(
'--visualization'
,
action
=
'store_true'
,
help
=
"whether to save output as images."
)
self
.
arg_config_group
.
add_argument
(
"--draw_threshold"
,
type
=
float
,
default
=
0.5
,
help
=
"Threshold to reserve the result for visualization."
)
def
add_module_input_arg
(
self
):
"""
Add the command input options.
"""
self
.
arg_input_group
.
add_argument
(
'--video_stream'
,
type
=
str
,
help
=
"path to video stream, can be a video file or stream device number."
)
self
.
arg_input_group
.
add_argument
(
'--video_stream'
,
type
=
str
,
help
=
"path to video stream, can be a video file or stream device number."
)
modules/video/multiple_object_tracking/fairmot_dla34/requirements.txt
浏览文件 @
deadba2c
paddledet >= 2.1.0
cython
paddledet >= 2.2.0
opencv-python
imageio
modules/video/multiple_object_tracking/fairmot_dla34/tracker.py
浏览文件 @
deadba2c
...
...
@@ -159,7 +159,6 @@ class StreamTracker(object):
yield
results
=
[]
while
True
:
with
paddle
.
no_grad
():
try
:
results
,
nf
=
next
(
generator
)
yield
results
...
...
@@ -175,7 +174,7 @@ class StreamTracker(object):
visualization
=
True
,
draw_threshold
=
0.5
):
assert
video_stream
is
not
None
,
\
"--video_
file or --image_dir
should be set."
"--video_
stream
should be set."
if
not
os
.
path
.
exists
(
output_dir
):
os
.
makedirs
(
output_dir
)
result_root
=
os
.
path
.
join
(
output_dir
,
'mot_results'
)
...
...
@@ -215,9 +214,10 @@ class StreamTracker(object):
img
=
cv2
.
imread
(
os
.
path
.
join
(
save_dir
,
'00000.jpg'
))
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
apiPreference
=
0
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
[
img
.
shape
[
1
],
img
.
shape
[
0
]]
)
frameSize
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
)
for
i
in
range
(
len
(
imgnames
)):
imgpath
=
os
.
path
.
join
(
save_dir
,
'{:05d}.jpg'
.
format
(
i
))
img
=
cv2
.
imread
(
imgpath
)
...
...
modules/video/multiple_object_tracking/jde_darknet53/README.md
浏览文件 @
deadba2c
...
...
@@ -31,7 +31,7 @@
-
### 1、环境依赖
-
paddledet >= 2.
1
.0
-
paddledet >= 2.
2
.0
-
opencv-python
...
...
@@ -42,6 +42,7 @@
```
-
如您安装时遇到问题,可参考:
[
零基础windows安装
](
../../../../docs/docs_ch/get_start/windows_quickstart.md
)
|
[
零基础Linux安装
](
../../../../docs/docs_ch/get_start/linux_quickstart.md
)
|
[
零基础MacOS安装
](
../../../../docs/docs_ch/get_start/mac_quickstart.md
)
-
在windows下安装,由于paddledet package会依赖cython-bbox以及pycocotools, 这两个包需要windows用户提前装好,可参考
[
cython-bbox安装
](
https://blog.csdn.net/qq_24739717/article/details/105588729
)
和
[
pycocotools安装
](
https://github.com/PaddlePaddle/PaddleX/blob/release/1.3/docs/install.md#pycocotools安装问题
)
## 三、模型API预测
...
...
modules/video/multiple_object_tracking/jde_darknet53/module.py
浏览文件 @
deadba2c
...
...
@@ -31,7 +31,8 @@ from .tracker import StreamTracker
logger
=
setup_logger
(
'Predict'
)
@
moduleinfo
(
name
=
"jde_darknet53"
,
@
moduleinfo
(
name
=
"jde_darknet53"
,
type
=
"CV/multiple_object_tracking"
,
author
=
"paddlepaddle"
,
author_email
=
""
,
...
...
@@ -70,7 +71,8 @@ class JDETracker_1088x608:
tracker
.
load_weights_jde
(
self
.
pretrained_model
)
signal
.
signal
(
signal
.
SIGINT
,
self
.
signalhandler
)
# inference
tracker
.
videostream_predict
(
video_stream
=
video_stream
,
tracker
.
videostream_predict
(
video_stream
=
video_stream
,
output_dir
=
output_dir
,
data_type
=
'mot'
,
model_type
=
'JDE'
,
...
...
@@ -106,7 +108,8 @@ class JDETracker_1088x608:
return
self
def
__enter__
(
self
):
self
.
tracker_generator
=
self
.
tracker
.
imagestream_predict
(
self
.
output_dir
,
self
.
tracker_generator
=
self
.
tracker
.
imagestream_predict
(
self
.
output_dir
,
data_type
=
'mot'
,
model_type
=
'JDE'
,
visualization
=
self
.
visualization
,
...
...
@@ -129,10 +132,12 @@ class JDETracker_1088x608:
logger
.
info
(
'No output images to save for video'
)
return
img
=
cv2
.
imread
(
os
.
path
.
join
(
save_dir
,
'00000.jpg'
))
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
apiPreference
=
0
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
[
img
.
shape
[
1
],
img
.
shape
[
0
]]
)
frameSize
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
)
for
i
in
range
(
len
(
imgnames
)):
imgpath
=
os
.
path
.
join
(
save_dir
,
'{:05d}.jpg'
.
format
(
i
))
img
=
cv2
.
imread
(
imgpath
)
...
...
@@ -169,7 +174,8 @@ class JDETracker_1088x608:
"""
Run as a command.
"""
self
.
parser
=
argparse
.
ArgumentParser
(
description
=
"Run the {} module."
.
format
(
self
.
name
),
self
.
parser
=
argparse
.
ArgumentParser
(
description
=
"Run the {} module."
.
format
(
self
.
name
),
prog
=
'hub run {}'
.
format
(
self
.
name
),
usage
=
'%(prog)s'
,
add_help
=
True
)
...
...
@@ -204,10 +210,12 @@ class JDETracker_1088x608:
logger
.
info
(
'No output images to save for video'
)
return
img
=
cv2
.
imread
(
os
.
path
.
join
(
save_dir
,
'00000.jpg'
))
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
apiPreference
=
0
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
[
img
.
shape
[
1
],
img
.
shape
[
0
]]
)
frameSize
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
)
for
i
in
range
(
len
(
imgnames
)):
imgpath
=
os
.
path
.
join
(
save_dir
,
'{:05d}.jpg'
.
format
(
i
))
img
=
cv2
.
imread
(
imgpath
)
...
...
@@ -223,22 +231,16 @@ class JDETracker_1088x608:
"""
self
.
arg_config_group
.
add_argument
(
'--use_gpu'
,
action
=
'store_true'
,
help
=
"use GPU or not"
)
self
.
arg_config_group
.
add_argument
(
'--output_dir'
,
type
=
str
,
default
=
'mot_result'
,
help
=
'Directory name for output tracking results.'
)
self
.
arg_config_group
.
add_argument
(
'--visualization'
,
action
=
'store_true'
,
help
=
"whether to save output as images."
)
self
.
arg_config_group
.
add_argument
(
"--draw_threshold"
,
type
=
float
,
default
=
0.5
,
help
=
"Threshold to reserve the result for visualization."
)
self
.
arg_config_group
.
add_argument
(
'--output_dir'
,
type
=
str
,
default
=
'mot_result'
,
help
=
'Directory name for output tracking results.'
)
self
.
arg_config_group
.
add_argument
(
'--visualization'
,
action
=
'store_true'
,
help
=
"whether to save output as images."
)
self
.
arg_config_group
.
add_argument
(
"--draw_threshold"
,
type
=
float
,
default
=
0.5
,
help
=
"Threshold to reserve the result for visualization."
)
def
add_module_input_arg
(
self
):
"""
Add the command input options.
"""
self
.
arg_input_group
.
add_argument
(
'--video_stream'
,
type
=
str
,
help
=
"path to video stream, can be a video file or stream device number."
)
self
.
arg_input_group
.
add_argument
(
'--video_stream'
,
type
=
str
,
help
=
"path to video stream, can be a video file or stream device number."
)
modules/video/multiple_object_tracking/jde_darknet53/requirements.txt
浏览文件 @
deadba2c
paddledet >= 2.1.0
cython
paddledet >= 2.2.0
opencv-python
imageio
modules/video/multiple_object_tracking/jde_darknet53/tracker.py
浏览文件 @
deadba2c
...
...
@@ -160,7 +160,6 @@ class StreamTracker(object):
yield
results
=
[]
while
True
:
with
paddle
.
no_grad
():
try
:
results
,
nf
=
next
(
generator
)
yield
results
...
...
@@ -176,7 +175,7 @@ class StreamTracker(object):
visualization
=
True
,
draw_threshold
=
0.5
):
assert
video_stream
is
not
None
,
\
"--video_
file or --image_dir
should be set."
"--video_
stream
should be set."
if
not
os
.
path
.
exists
(
output_dir
):
os
.
makedirs
(
output_dir
)
result_root
=
os
.
path
.
join
(
output_dir
,
'mot_results'
)
...
...
@@ -214,7 +213,12 @@ class StreamTracker(object):
logger
.
info
(
'No output images to save for video'
)
return
img
=
cv2
.
imread
(
os
.
path
.
join
(
save_dir
,
'00000.jpg'
))
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
[
img
.
shape
[
1
],
img
.
shape
[
0
]])
video_writer
=
cv2
.
VideoWriter
(
output_video_path
,
apiPreference
=
0
,
fourcc
=
cv2
.
VideoWriter_fourcc
(
'M'
,
'J'
,
'P'
,
'G'
),
fps
=
30
,
frameSize
=
(
img
.
shape
[
1
],
img
.
shape
[
0
]))
for
i
in
range
(
len
(
imgnames
)):
imgpath
=
os
.
path
.
join
(
save_dir
,
'{:05d}.jpg'
.
format
(
i
))
img
=
cv2
.
imread
(
imgpath
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录