Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
096dde95
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
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看板
提交
096dde95
编写于
9月 23, 2020
作者:
W
wangxinxin08
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add comment to trigger pre-commit
上级
d576a61a
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
16 addition
and
20 deletion
+16
-20
ppdet/data/transform/op_helper.py
ppdet/data/transform/op_helper.py
+16
-20
未找到文件。
ppdet/data/transform/op_helper.py
浏览文件 @
096dde95
...
...
@@ -61,10 +61,7 @@ def is_overlap(object_bbox, sample_bbox):
return
True
def
filter_and_process
(
sample_bbox
,
bboxes
,
labels
,
scores
=
None
,
def
filter_and_process
(
sample_bbox
,
bboxes
,
labels
,
scores
=
None
,
keypoints
=
None
):
new_bboxes
=
[]
new_labels
=
[]
...
...
@@ -95,8 +92,8 @@ def filter_and_process(sample_bbox,
for
j
in
range
(
len
(
sample_keypoint
)):
kp_len
=
sample_height
if
j
%
2
else
sample_width
sample_coord
=
sample_bbox
[
1
]
if
j
%
2
else
sample_bbox
[
0
]
sample_keypoint
[
j
]
=
(
sample_keypoint
[
j
]
-
sample_coord
)
/
kp_len
sample_keypoint
[
j
]
=
(
sample_keypoint
[
j
]
-
sample_coord
)
/
kp_len
sample_keypoint
[
j
]
=
max
(
min
(
sample_keypoint
[
j
],
1.0
),
0.0
)
new_keypoints
.
append
(
sample_keypoint
)
new_kp_ignore
.
append
(
keypoints
[
1
][
i
])
...
...
@@ -264,12 +261,12 @@ def jaccard_overlap(sample_bbox, object_bbox):
intersect_ymin
=
max
(
sample_bbox
[
1
],
object_bbox
[
1
])
intersect_xmax
=
min
(
sample_bbox
[
2
],
object_bbox
[
2
])
intersect_ymax
=
min
(
sample_bbox
[
3
],
object_bbox
[
3
])
intersect_size
=
(
intersect_xmax
-
intersect_xmin
)
*
(
intersect_ymax
-
intersect_ymin
)
intersect_size
=
(
intersect_xmax
-
intersect_xmin
)
*
(
intersect_ymax
-
intersect_ymin
)
sample_bbox_size
=
bbox_area
(
sample_bbox
)
object_bbox_size
=
bbox_area
(
object_bbox
)
overlap
=
intersect_size
/
(
sample_bbox_size
+
object_bbox_size
-
intersect_size
)
overlap
=
intersect_size
/
(
sample_bbox_size
+
object_bbox_size
-
intersect_size
)
return
overlap
...
...
@@ -279,10 +276,8 @@ def intersect_bbox(bbox1, bbox2):
intersection_box
=
[
0.0
,
0.0
,
0.0
,
0.0
]
else
:
intersection_box
=
[
max
(
bbox1
[
0
],
bbox2
[
0
]),
max
(
bbox1
[
1
],
bbox2
[
1
]),
min
(
bbox1
[
2
],
bbox2
[
2
]),
min
(
bbox1
[
3
],
bbox2
[
3
])
max
(
bbox1
[
0
],
bbox2
[
0
]),
max
(
bbox1
[
1
],
bbox2
[
1
]),
min
(
bbox1
[
2
],
bbox2
[
2
]),
min
(
bbox1
[
3
],
bbox2
[
3
])
]
return
intersection_box
...
...
@@ -406,8 +401,8 @@ def crop_image_sampling(img, sample_bbox, image_width, image_height,
sample_img
[
roi_y1
:
roi_y2
,
roi_x1
:
roi_x2
]
=
\
img
[
cross_y1
:
cross_y2
,
cross_x1
:
cross_x2
]
sample_img
=
cv2
.
resize
(
sample_img
,
(
target_size
,
target_size
),
interpolation
=
cv2
.
INTER_AREA
)
sample_img
=
cv2
.
resize
(
sample_img
,
(
target_size
,
target_size
),
interpolation
=
cv2
.
INTER_AREA
)
return
sample_img
...
...
@@ -454,8 +449,8 @@ def draw_gaussian(heatmap, center, radius, k=1, delte=6):
top
,
bottom
=
min
(
y
,
radius
),
min
(
height
-
y
,
radius
+
1
)
masked_heatmap
=
heatmap
[
y
-
top
:
y
+
bottom
,
x
-
left
:
x
+
right
]
masked_gaussian
=
gaussian
[
radius
-
top
:
radius
+
bottom
,
radius
-
left
:
radius
+
right
]
masked_gaussian
=
gaussian
[
radius
-
top
:
radius
+
bottom
,
radius
-
left
:
radius
+
right
]
np
.
maximum
(
masked_heatmap
,
masked_gaussian
*
k
,
out
=
masked_heatmap
)
...
...
@@ -463,8 +458,8 @@ def gaussian2D(shape, sigma_x=1, sigma_y=1):
m
,
n
=
[(
ss
-
1.
)
/
2.
for
ss
in
shape
]
y
,
x
=
np
.
ogrid
[
-
m
:
m
+
1
,
-
n
:
n
+
1
]
h
=
np
.
exp
(
-
(
x
*
x
/
(
2
*
sigma_x
*
sigma_x
)
+
y
*
y
/
(
2
*
sigma_y
*
sigma_y
)))
h
=
np
.
exp
(
-
(
x
*
x
/
(
2
*
sigma_x
*
sigma_x
)
+
y
*
y
/
(
2
*
sigma_y
*
sigma_y
)))
h
[
h
<
np
.
finfo
(
h
.
dtype
).
eps
*
h
.
max
()]
=
0
return
h
...
...
@@ -482,6 +477,7 @@ def transform_bbox(bbox,
n
=
len
(
bbox
)
xy
=
np
.
ones
((
n
*
4
,
3
),
dtype
=
np
.
float32
)
xy
[:,
:
2
]
=
bbox
[:,
[
0
,
1
,
2
,
3
,
0
,
3
,
2
,
1
]].
reshape
(
n
*
4
,
2
)
# xy = xy @ M.T
xy
=
np
.
matmul
(
xy
,
M
.
T
)
if
perspective
:
xy
=
(
xy
[:,
:
2
]
/
xy
[:,
2
:
3
]).
reshape
(
n
,
8
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录