Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
df12e321
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
df12e321
编写于
9月 23, 2020
作者:
W
wangxinxin08
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add commments
上级
ca6a3a89
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
93 addition
and
0 deletion
+93
-0
ppdet/data/transform/op_helper.py
ppdet/data/transform/op_helper.py
+6
-0
ppdet/data/transform/operators.py
ppdet/data/transform/operators.py
+87
-0
未找到文件。
ppdet/data/transform/op_helper.py
浏览文件 @
df12e321
...
...
@@ -473,6 +473,9 @@ def transform_bbox(bbox,
wh_thr
=
2
,
ar_thr
=
20
,
perspective
=
False
):
"""
Transfrom bbox according to tranformation matrix M
"""
# rotate bbox
n
=
len
(
bbox
)
xy
=
np
.
ones
((
n
*
4
,
3
),
dtype
=
np
.
float32
)
...
...
@@ -495,6 +498,9 @@ def transform_bbox(bbox,
def
clip_bbox
(
bbox
,
w
,
h
,
area_thr
=
0.25
,
wh_thr
=
2
,
ar_thr
=
20
):
"""
clip bbox according to w and h
"""
# clip boxes
area1
=
(
bbox
[:,
2
:
4
]
-
bbox
[:,
0
:
2
]).
prod
(
1
)
bbox
[:,
[
0
,
2
]]
=
bbox
[:,
[
0
,
2
]].
clip
(
0
,
w
)
...
...
ppdet/data/transform/operators.py
浏览文件 @
df12e321
...
...
@@ -2559,6 +2559,15 @@ class DebugVisibleImage(BaseOperator):
@
register_op
class
Rotate
(
BaseOperator
):
"""Rotate image and bboxes
Args:
degree (int, float): the angle of rotation in degrees
scale (float): scale factor
center (tuple): center of the rotation in the source image
area_thr (float): the area threshold of bbox to be kept after rotation, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
degree
,
scale
=
1.0
,
...
...
@@ -2599,6 +2608,16 @@ class Rotate(BaseOperator):
@
register_op
class
RandomRotate
(
BaseOperator
):
"""Rotate image and bboxes randomly
Args:
degree (int, float, list, tuple): if(int, float), the rotation degree will be uniformly sampled uniformly in [-abs(degree), abs(degree)]
if (list, tuple), the rotation degree will be uniformly sampled in [degree[0], degree[1]]
scale (float): the scale factor will be uniformly sampled in [1 - scale, 1 + scale]
center (tuple): center of the rotation in the source image
area_thr (float): the area threshold of bbox to be kept after rotation, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
degree
,
scale
=
0.0
,
...
...
@@ -2630,6 +2649,14 @@ class RandomRotate(BaseOperator):
@
register_op
class
Shear
(
BaseOperator
):
"""Shear image and bboxes
Args:
shear (int, float, list, tuple): if (int, float), shear_x and shear_y are both equal to shear,
if (list, tuple), it means [shear_x, shear_y], the shear is in the format of degrees
area_thr (float): the area threshold of bbox to be kept after sheared, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
shear
,
area_thr
=
0.25
,
border_value
=
(
114
,
114
,
114
)):
super
(
Shear
,
self
).
__init__
()
if
isinstance
(
shear
,
(
int
,
float
)):
...
...
@@ -2670,6 +2697,16 @@ class Shear(BaseOperator):
@
register_op
class
RandomShear
(
BaseOperator
):
"""Shear image and bboxes randomly
Args:
shear_x (int, float, list, tuple): if (int, float), shear_x will be uniformly sampled in [-abs(shear_x), abs(shear_x)],
if (list, tuple), shear_x will be uniformly sampled in [shear_x[0], shear_x[1]], the shear_x is in the format of degrees
shear_y (int, float, list, tuple): if (int, float), shear_y will be uniformly sampled in [-abs(shear_y), abs(shear_y)],
if (list, tuple), shear_y will be uniformly sampled in [shear_y[0], shear_y[1]], the shear_y is in the format of degrees
area_thr (float): the area threshold of bbox to be kept after sheared, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
shear_x
,
shear_y
,
...
...
@@ -2706,6 +2743,14 @@ class RandomShear(BaseOperator):
@
register_op
class
Translate
(
BaseOperator
):
"""Translate image and bboxes
Args:
translate (int, float, list, tuple): if (int, float), translate_x and translate_y are both equal to translate,
if (list, tuple), it means [translate_x, translate_y], translate is the fraction relative to original shape
area_thr (float): the area threshold of bbox to be kept after translation, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
translate
,
area_thr
=
0.25
,
border_value
=
(
114
,
114
,
114
)):
super
(
Translate
,
self
).
__init__
()
if
isinstance
(
translate
,
(
int
,
float
)):
...
...
@@ -2761,6 +2806,18 @@ class Translate(BaseOperator):
@
register_op
class
RandomTranslate
(
BaseOperator
):
"""Translate image and bboxes randomly
Args:
translate_x (int, float, list, tuple): if (int, float), translate_x will be unifromly sampled in [-abs(translate_x), abs(translate_x)],
if (list, tuple), translate_x will be unifromly sampled in [translate_x[0], translate_x[1]],
translate_x is the fraction relative to original shape
translate_y (int, float, list, tuple): if (int, float), translate_y will be unifromly sampled in [-abs(translate_y), abs(translate_y)],
if (list, tuple), translate_y will be unifromly sampled in [translate_y[0], translate_y[1]],
translate_y is the fraction relative to original shape
area_thr (float): the area threshold of bbox to be kept after translation, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
translate_x
,
translate_y
,
...
...
@@ -2798,6 +2855,14 @@ class RandomTranslate(BaseOperator):
@
register_op
class
Scale
(
BaseOperator
):
"""Scale image and bboxes
Args:
scale (int, float, list, tuple): if (int, float), scale_x and scale_y are both equal to scale,
if (list, tuple), it means [scale_x, scale_y]
area_thr (float): the area threshold of bbox to be kept after scaled, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
scale
,
area_thr
=
0.25
,
border_value
=
(
114
,
114
,
114
)):
super
(
Scale
,
self
).
__init__
()
if
isinstance
(
scale
,
(
int
,
float
)):
...
...
@@ -2844,6 +2909,16 @@ class Scale(BaseOperator):
@
register_op
class
RandomScale
(
BaseOperator
):
"""Scale image and bboxes randomly
Args:
scale_x (int, float, list, tuple): if (int, float), scale_x will be uniformly sampled in [0, scale_x],
if (list, tuple), scale_x will be uniformly sampled in [scale_x[0], scale_x[1]]
scale_y (int, float, list, tuple): if (int, float), scale_y will be uniformly sampled in [0, scale_y],
if (list, tuple), scale_y will be uniformly sampled in [scale_y[0], scale_y[1]]
area_thr (float): the area threshold of bbox to be kept after scaled, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
scale_x
,
scale_y
,
...
...
@@ -2880,6 +2955,18 @@ class RandomScale(BaseOperator):
@
register_op
class
RandomPerspective
(
BaseOperator
):
"""Rotate, tranlate, scale, shear and perspect image and bboxes randomly
Args:
degree (int): rotation degree, uniformly sampled in [-degree, degree]
translate (float): translate fraction, translate_x and translate_y are uniformly sampled
in [0.5 - translate, 0.5 + translate]
scale (float): scale factor, uniformly sampled in [1 - scale, 1 + scale]
shear (int): shear degree, shear_x and shear_y are uniformly sampled in [-shear, shear]
perspective (float): perspective_x and perspective_y are uniformly sampled in [-perspective, perspective]
area_thr (float): the area threshold of bbox to be kept after transformation, default 0.25
border_value (tuple): value used in case of a constant border, default (114, 114, 114)
"""
def
__init__
(
self
,
degree
=
10
,
translate
=
0.1
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录