Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
762204e9
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看板
提交
762204e9
编写于
12月 26, 2019
作者:
Y
Yang Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switch to "google" C++ style from customized "linux" style
上级
6f79f530
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
26 addition
and
55 deletion
+26
-55
src/binding.cc
src/binding.cc
+15
-30
src/nms.cc
src/nms.cc
+11
-25
未找到文件。
src/binding.cc
浏览文件 @
762204e9
...
@@ -4,36 +4,21 @@
...
@@ -4,36 +4,21 @@
#include <pybind11/numpy.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include <pybind11/stl.h>
namespace
nms
{
enum
class
Method
:
uint32_t
{
LINEAR
=
0
,
GAUSSIAN
,
HARD
};
namespace
nms
size_t
soft_nms
(
float
*
boxes
,
int32_t
*
index
,
size_t
count
,
Method
method
,
{
float
Nt
,
float
sigma
,
float
threshold
);
enum
class
Method
:
uint32_t
{
LINEAR
=
0
,
GAUSSIAN
,
HARD
};
size_t
soft_nms
(
float
*
boxes
,
int32_t
*
index
,
size_t
count
,
Method
method
,
float
Nt
,
float
sigma
,
float
threshold
);
}
// namespace nms
}
// namespace nms
namespace
binding
namespace
binding
{
{
namespace
py
=
pybind11
;
namespace
py
=
pybind11
;
using
namespace
pybind11
::
literals
;
using
namespace
pybind11
::
literals
;
py
::
tuple
py_soft_nms
(
py
::
array_t
<
float
,
py
::
array
::
c_style
>
boxes
,
py
::
tuple
py_soft_nms
(
py
::
array_t
<
float
,
py
::
array
::
c_style
>
boxes
,
nms
::
Method
method
=
nms
::
Method
::
GAUSSIAN
,
nms
::
Method
method
=
nms
::
Method
::
GAUSSIAN
,
float
Nt
=
0.3
,
float
Nt
=
0.3
,
float
sigma
=
0.5
,
float
sigma
=
0.5
,
float
threshold
=
0.001
)
{
float
threshold
=
0.001
)
{
assert
(
boxes
.
ndim
()
==
2
&&
"Input should be 2-D NumPy array"
);
assert
(
boxes
.
ndim
()
==
2
&&
"Input should be 2-D NumPy array"
);
assert
(
boxes
.
shape
()[
1
]
==
5
&&
"Input should have size [N,5]"
);
assert
(
boxes
.
shape
()[
1
]
==
5
&&
"Input should have size [N,5]"
);
...
@@ -68,7 +53,7 @@ PYBIND11_MODULE(nms, m) {
...
@@ -68,7 +53,7 @@ PYBIND11_MODULE(nms, m) {
.
value
(
"HARD"
,
nms
::
Method
::
HARD
)
.
value
(
"HARD"
,
nms
::
Method
::
HARD
)
.
export_values
();
.
export_values
();
m
.
def
(
"soft_nms"
,
&
py_soft_nms
,
"boxes"
_a
.
noconvert
(),
m
.
def
(
"soft_nms"
,
&
py_soft_nms
,
"boxes"
_a
.
noconvert
(),
"method"
_a
=
nms
::
Method
::
GAUSSIAN
,
"method"
_a
=
nms
::
Method
::
GAUSSIAN
,
"Nt"
_a
=
0.3
,
"sigma"
_a
=
0.5
,
"
Nt"
_a
=
0.3
,
"sigma"
_a
=
0.5
,
"
threshold"
_a
=
0.001
);
"threshold"
_a
=
0.001
);
}
}
}
/* namespace binding */
}
/* namespace binding */
src/nms.cc
浏览文件 @
762204e9
#include <cmath>
#include <cmath>
#include <algorithm>
#include <algorithm>
namespace
nms
namespace
nms
{
{
struct
proposal
{
struct
proposal
{
float
score
,
x1
,
y1
,
x2
,
y2
;
float
score
,
x1
,
y1
,
x2
,
y2
;
};
};
inline
static
bool
cmp
(
const
proposal
&
a
,
const
proposal
&
b
)
inline
static
bool
cmp
(
const
proposal
&
a
,
const
proposal
&
b
)
{
{
return
a
.
score
<
b
.
score
;
return
a
.
score
<
b
.
score
;
}
}
inline
static
float
iou
(
const
proposal
&
,
const
proposal
&
)
__attribute__
((
always_inline
));
inline
static
float
iou
(
const
proposal
&
,
const
proposal
&
)
__attribute__
((
always_inline
));
static
float
iou
(
const
proposal
&
a
,
const
proposal
&
b
)
static
float
iou
(
const
proposal
&
a
,
const
proposal
&
b
)
{
{
auto
overlap
=
0.
f
;
auto
overlap
=
0.
f
;
float
iw
=
std
::
min
(
b
.
x2
,
a
.
x2
)
-
std
::
max
(
b
.
x1
,
a
.
x1
)
+
1
;
float
iw
=
std
::
min
(
b
.
x2
,
a
.
x2
)
-
std
::
max
(
b
.
x1
,
a
.
x1
)
+
1
;
if
(
iw
>
0
)
{
if
(
iw
>
0
)
{
...
@@ -31,21 +28,10 @@ static float iou(const proposal& a, const proposal& b)
...
@@ -31,21 +28,10 @@ static float iou(const proposal& a, const proposal& b)
return
overlap
;
return
overlap
;
}
}
enum
class
Method
:
uint32_t
enum
class
Method
:
uint32_t
{
LINEAR
=
0
,
GAUSSIAN
,
HARD
};
{
LINEAR
=
0
,
GAUSSIAN
,
HARD
};
size_t
soft_nms
(
float
*
boxes
,
size_t
soft_nms
(
float
*
boxes
,
int32_t
*
index
,
size_t
count
,
Method
method
,
int32_t
*
index
,
float
Nt
,
float
sigma
,
float
threshold
)
{
size_t
count
,
Method
method
,
float
Nt
,
float
sigma
,
float
threshold
)
{
std
::
iota
(
index
,
index
+
count
,
0
);
// np.arange()
std
::
iota
(
index
,
index
+
count
,
0
);
// np.arange()
auto
p
=
reinterpret_cast
<
proposal
*>
(
boxes
);
auto
p
=
reinterpret_cast
<
proposal
*>
(
boxes
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录