Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
7aa70fd5
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
284
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看板
未验证
提交
7aa70fd5
编写于
11月 25, 2022
作者:
jm_12138
提交者:
GitHub
11月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rm core.eager.Tensor (#2134)
* rm core.eager.Tensor * update requirement * update mot
上级
65f8c07d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
74 addition
and
34 deletion
+74
-34
modules/video/multiple_object_tracking/fairmot_dla34/dataset.py
...s/video/multiple_object_tracking/fairmot_dla34/dataset.py
+1
-1
modules/video/multiple_object_tracking/fairmot_dla34/modeling/mot/matching/jde_matching.py
...cking/fairmot_dla34/modeling/mot/matching/jde_matching.py
+35
-16
modules/video/multiple_object_tracking/fairmot_dla34/requirements.txt
...o/multiple_object_tracking/fairmot_dla34/requirements.txt
+1
-0
modules/video/multiple_object_tracking/jde_darknet53/dataset.py
...s/video/multiple_object_tracking/jde_darknet53/dataset.py
+1
-1
modules/video/multiple_object_tracking/jde_darknet53/modeling/mot/matching/jde_matching.py
...cking/jde_darknet53/modeling/mot/matching/jde_matching.py
+35
-16
modules/video/multiple_object_tracking/jde_darknet53/requirements.txt
...o/multiple_object_tracking/jde_darknet53/requirements.txt
+1
-0
未找到文件。
modules/video/multiple_object_tracking/fairmot_dla34/dataset.py
浏览文件 @
7aa70fd5
...
...
@@ -64,7 +64,7 @@ def default_collate_fn(batch):
if
isinstance
(
sample
,
np
.
ndarray
):
batch
=
np
.
stack
(
batch
,
axis
=
0
)
return
batch
elif
isinstance
(
sample
,
(
paddle
.
Tensor
,
core
.
eager
.
Tensor
)):
elif
isinstance
(
sample
,
(
paddle
.
Tensor
)):
return
paddle
.
stack
(
batch
,
axis
=
0
)
elif
isinstance
(
sample
,
numbers
.
Number
):
batch
=
np
.
array
(
batch
)
...
...
modules/video/multiple_object_tracking/fairmot_dla34/modeling/mot/matching/jde_matching.py
浏览文件 @
7aa70fd5
...
...
@@ -12,22 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This code is b
orrow from
https://github.com/Zhongdao/Towards-Realtime-MOT/blob/master/tracker/matching.py
This code is b
ased on
https://github.com/Zhongdao/Towards-Realtime-MOT/blob/master/tracker/matching.py
"""
import
lap
try
:
import
lap
except
:
print
(
'Warning: Unable to use JDE/FairMOT/ByteTrack, please install lap, for example: `pip install lap`, see https://github.com/gatagat/lap'
)
pass
import
scipy
import
numpy
as
np
from
scipy.spatial.distance
import
cdist
from
..motion
import
kalman_filter
import
warnings
from
ppdet.utils.logger
import
setup_logger
logger
=
setup_logger
(
__name__
)
warnings
.
filterwarnings
(
"ignore"
)
__all__
=
[
'merge_matches'
,
'linear_assignment'
,
'
cython_
bbox_ious'
,
'bbox_ious'
,
'iou_distance'
,
'embedding_distance'
,
'fuse_motion'
,
...
...
@@ -52,6 +59,12 @@ def merge_matches(m1, m2, shape):
def
linear_assignment
(
cost_matrix
,
thresh
):
try
:
import
lap
except
Exception
as
e
:
raise
RuntimeError
(
'Unable to use JDE/FairMOT/ByteTrack, please install lap, for example: `pip install lap`, see https://github.com/gatagat/lap'
)
if
cost_matrix
.
size
==
0
:
return
np
.
empty
((
0
,
2
),
dtype
=
int
),
tuple
(
range
(
cost_matrix
.
shape
[
0
])),
tuple
(
range
(
cost_matrix
.
shape
[
1
]))
matches
,
unmatched_a
,
unmatched_b
=
[],
[],
[]
...
...
@@ -65,18 +78,24 @@ def linear_assignment(cost_matrix, thresh):
return
matches
,
unmatched_a
,
unmatched_b
def
cython_bbox_ious
(
atlbrs
,
btlbrs
):
ious
=
np
.
zeros
((
len
(
atlbrs
),
len
(
btlbrs
)),
dtype
=
np
.
float
)
if
ious
.
size
==
0
:
def
bbox_ious
(
atlbrs
,
btlbrs
):
boxes
=
np
.
ascontiguousarray
(
atlbrs
,
dtype
=
np
.
float
)
query_boxes
=
np
.
ascontiguousarray
(
btlbrs
,
dtype
=
np
.
float
)
N
=
boxes
.
shape
[
0
]
K
=
query_boxes
.
shape
[
0
]
ious
=
np
.
zeros
((
N
,
K
),
dtype
=
boxes
.
dtype
)
if
N
*
K
==
0
:
return
ious
try
:
import
cython_bbox
except
Exception
as
e
:
logger
.
error
(
'cython_bbox not found, please install cython_bbox.'
'for example: `pip install cython_bbox`.'
)
raise
e
ious
=
cython_bbox
.
bbox_overlaps
(
np
.
ascontiguousarray
(
atlbrs
,
dtype
=
np
.
float
),
np
.
ascontiguousarray
(
btlbrs
,
dtype
=
np
.
float
))
for
k
in
range
(
K
):
box_area
=
((
query_boxes
[
k
,
2
]
-
query_boxes
[
k
,
0
]
+
1
)
*
(
query_boxes
[
k
,
3
]
-
query_boxes
[
k
,
1
]
+
1
))
for
n
in
range
(
N
):
iw
=
(
min
(
boxes
[
n
,
2
],
query_boxes
[
k
,
2
])
-
max
(
boxes
[
n
,
0
],
query_boxes
[
k
,
0
])
+
1
)
if
iw
>
0
:
ih
=
(
min
(
boxes
[
n
,
3
],
query_boxes
[
k
,
3
])
-
max
(
boxes
[
n
,
1
],
query_boxes
[
k
,
1
])
+
1
)
if
ih
>
0
:
ua
=
float
((
boxes
[
n
,
2
]
-
boxes
[
n
,
0
]
+
1
)
*
(
boxes
[
n
,
3
]
-
boxes
[
n
,
1
]
+
1
)
+
box_area
-
iw
*
ih
)
ious
[
n
,
k
]
=
iw
*
ih
/
ua
return
ious
...
...
@@ -91,7 +110,7 @@ def iou_distance(atracks, btracks):
else
:
atlbrs
=
[
track
.
tlbr
for
track
in
atracks
]
btlbrs
=
[
track
.
tlbr
for
track
in
btracks
]
_ious
=
cython_
bbox_ious
(
atlbrs
,
btlbrs
)
_ious
=
bbox_ious
(
atlbrs
,
btlbrs
)
cost_matrix
=
1
-
_ious
return
cost_matrix
...
...
modules/video/multiple_object_tracking/fairmot_dla34/requirements.txt
浏览文件 @
7aa70fd5
...
...
@@ -2,3 +2,4 @@ cython
paddledet >= 2.2.0
opencv-python
imageio
pillow==7.1.2
modules/video/multiple_object_tracking/jde_darknet53/dataset.py
浏览文件 @
7aa70fd5
...
...
@@ -65,7 +65,7 @@ def default_collate_fn(batch):
if
isinstance
(
sample
,
np
.
ndarray
):
batch
=
np
.
stack
(
batch
,
axis
=
0
)
return
batch
elif
isinstance
(
sample
,
(
paddle
.
Tensor
,
core
.
eager
.
Tensor
)):
elif
isinstance
(
sample
,
(
paddle
.
Tensor
)):
return
paddle
.
stack
(
batch
,
axis
=
0
)
elif
isinstance
(
sample
,
numbers
.
Number
):
batch
=
np
.
array
(
batch
)
...
...
modules/video/multiple_object_tracking/jde_darknet53/modeling/mot/matching/jde_matching.py
浏览文件 @
7aa70fd5
...
...
@@ -12,22 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This code is b
orrow from
https://github.com/Zhongdao/Towards-Realtime-MOT/blob/master/tracker/matching.py
This code is b
ased on
https://github.com/Zhongdao/Towards-Realtime-MOT/blob/master/tracker/matching.py
"""
import
lap
try
:
import
lap
except
:
print
(
'Warning: Unable to use JDE/FairMOT/ByteTrack, please install lap, for example: `pip install lap`, see https://github.com/gatagat/lap'
)
pass
import
scipy
import
numpy
as
np
from
scipy.spatial.distance
import
cdist
from
..motion
import
kalman_filter
import
warnings
from
ppdet.utils.logger
import
setup_logger
logger
=
setup_logger
(
__name__
)
warnings
.
filterwarnings
(
"ignore"
)
__all__
=
[
'merge_matches'
,
'linear_assignment'
,
'
cython_
bbox_ious'
,
'bbox_ious'
,
'iou_distance'
,
'embedding_distance'
,
'fuse_motion'
,
...
...
@@ -52,6 +59,12 @@ def merge_matches(m1, m2, shape):
def
linear_assignment
(
cost_matrix
,
thresh
):
try
:
import
lap
except
Exception
as
e
:
raise
RuntimeError
(
'Unable to use JDE/FairMOT/ByteTrack, please install lap, for example: `pip install lap`, see https://github.com/gatagat/lap'
)
if
cost_matrix
.
size
==
0
:
return
np
.
empty
((
0
,
2
),
dtype
=
int
),
tuple
(
range
(
cost_matrix
.
shape
[
0
])),
tuple
(
range
(
cost_matrix
.
shape
[
1
]))
matches
,
unmatched_a
,
unmatched_b
=
[],
[],
[]
...
...
@@ -65,18 +78,24 @@ def linear_assignment(cost_matrix, thresh):
return
matches
,
unmatched_a
,
unmatched_b
def
cython_bbox_ious
(
atlbrs
,
btlbrs
):
ious
=
np
.
zeros
((
len
(
atlbrs
),
len
(
btlbrs
)),
dtype
=
np
.
float
)
if
ious
.
size
==
0
:
def
bbox_ious
(
atlbrs
,
btlbrs
):
boxes
=
np
.
ascontiguousarray
(
atlbrs
,
dtype
=
np
.
float
)
query_boxes
=
np
.
ascontiguousarray
(
btlbrs
,
dtype
=
np
.
float
)
N
=
boxes
.
shape
[
0
]
K
=
query_boxes
.
shape
[
0
]
ious
=
np
.
zeros
((
N
,
K
),
dtype
=
boxes
.
dtype
)
if
N
*
K
==
0
:
return
ious
try
:
import
cython_bbox
except
Exception
as
e
:
logger
.
error
(
'cython_bbox not found, please install cython_bbox.'
'for example: `pip install cython_bbox`.'
)
raise
e
ious
=
cython_bbox
.
bbox_overlaps
(
np
.
ascontiguousarray
(
atlbrs
,
dtype
=
np
.
float
),
np
.
ascontiguousarray
(
btlbrs
,
dtype
=
np
.
float
))
for
k
in
range
(
K
):
box_area
=
((
query_boxes
[
k
,
2
]
-
query_boxes
[
k
,
0
]
+
1
)
*
(
query_boxes
[
k
,
3
]
-
query_boxes
[
k
,
1
]
+
1
))
for
n
in
range
(
N
):
iw
=
(
min
(
boxes
[
n
,
2
],
query_boxes
[
k
,
2
])
-
max
(
boxes
[
n
,
0
],
query_boxes
[
k
,
0
])
+
1
)
if
iw
>
0
:
ih
=
(
min
(
boxes
[
n
,
3
],
query_boxes
[
k
,
3
])
-
max
(
boxes
[
n
,
1
],
query_boxes
[
k
,
1
])
+
1
)
if
ih
>
0
:
ua
=
float
((
boxes
[
n
,
2
]
-
boxes
[
n
,
0
]
+
1
)
*
(
boxes
[
n
,
3
]
-
boxes
[
n
,
1
]
+
1
)
+
box_area
-
iw
*
ih
)
ious
[
n
,
k
]
=
iw
*
ih
/
ua
return
ious
...
...
@@ -91,7 +110,7 @@ def iou_distance(atracks, btracks):
else
:
atlbrs
=
[
track
.
tlbr
for
track
in
atracks
]
btlbrs
=
[
track
.
tlbr
for
track
in
btracks
]
_ious
=
cython_
bbox_ious
(
atlbrs
,
btlbrs
)
_ious
=
bbox_ious
(
atlbrs
,
btlbrs
)
cost_matrix
=
1
-
_ious
return
cost_matrix
...
...
modules/video/multiple_object_tracking/jde_darknet53/requirements.txt
浏览文件 @
7aa70fd5
...
...
@@ -2,3 +2,4 @@ cython
paddledet >= 2.2.0
opencv-python
imageio
pillow==7.1.2
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录