Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
10b62145
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看板
未验证
提交
10b62145
编写于
4月 07, 2022
作者:
W
wangguanzhong
提交者:
GitHub
4月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix centernet deploy
上级
d2304597
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
3 deletion
+76
-3
configs/centernet/_base_/centernet_reader.yml
configs/centernet/_base_/centernet_reader.yml
+1
-1
deploy/cpp/include/preprocess_op.h
deploy/cpp/include/preprocess_op.h
+21
-1
deploy/cpp/src/preprocess_op.cc
deploy/cpp/src/preprocess_op.cc
+53
-0
ppdet/modeling/post_process.py
ppdet/modeling/post_process.py
+1
-1
未找到文件。
configs/centernet/_base_/centernet_reader.yml
浏览文件 @
10b62145
...
@@ -30,6 +30,6 @@ TestReader:
...
@@ -30,6 +30,6 @@ TestReader:
sample_transforms
:
sample_transforms
:
-
Decode
:
{}
-
Decode
:
{}
-
WarpAffine
:
{
keep_res
:
True
,
input_h
:
512
,
input_w
:
512
}
-
WarpAffine
:
{
keep_res
:
True
,
input_h
:
512
,
input_w
:
512
}
-
NormalizeImage
:
{
mean
:
[
0.40789655
,
0.44719303
,
0.47026116
],
std
:
[
0.2886383
,
0.27408165
,
0.27809834
]}
-
NormalizeImage
:
{
mean
:
[
0.40789655
,
0.44719303
,
0.47026116
],
std
:
[
0.2886383
,
0.27408165
,
0.27809834
]
,
is_scale
:
True
}
-
Permute
:
{}
-
Permute
:
{}
batch_size
:
1
batch_size
:
1
deploy/cpp/include/preprocess_op.h
浏览文件 @
10b62145
...
@@ -74,7 +74,7 @@ class NormalizeImage : public PreprocessOp {
...
@@ -74,7 +74,7 @@ class NormalizeImage : public PreprocessOp {
// CHW or HWC
// CHW or HWC
std
::
vector
<
float
>
mean_
;
std
::
vector
<
float
>
mean_
;
std
::
vector
<
float
>
scale_
;
std
::
vector
<
float
>
scale_
;
bool
is_scale_
;
bool
is_scale_
=
true
;
};
};
class
Permute
:
public
PreprocessOp
{
class
Permute
:
public
PreprocessOp
{
...
@@ -143,6 +143,24 @@ class TopDownEvalAffine : public PreprocessOp {
...
@@ -143,6 +143,24 @@ class TopDownEvalAffine : public PreprocessOp {
std
::
vector
<
int
>
trainsize_
;
std
::
vector
<
int
>
trainsize_
;
};
};
class
WarpAffine
:
public
PreprocessOp
{
public:
virtual
void
Init
(
const
YAML
::
Node
&
item
)
{
input_h_
=
item
[
"input_h"
].
as
<
int
>
();
input_w_
=
item
[
"input_w"
].
as
<
int
>
();
keep_res_
=
item
[
"keep_res"
].
as
<
bool
>
();
}
virtual
void
Run
(
cv
::
Mat
*
im
,
ImageBlob
*
data
);
private:
int
input_h_
;
int
input_w_
;
int
interp_
=
1
;
bool
keep_res_
=
true
;
int
pad_
=
31
;
};
void
CropImg
(
cv
::
Mat
&
img
,
void
CropImg
(
cv
::
Mat
&
img
,
cv
::
Mat
&
crop_img
,
cv
::
Mat
&
crop_img
,
std
::
vector
<
int
>&
area
,
std
::
vector
<
int
>&
area
,
...
@@ -183,6 +201,8 @@ class Preprocessor {
...
@@ -183,6 +201,8 @@ class Preprocessor {
return
std
::
make_shared
<
PadStride
>
();
return
std
::
make_shared
<
PadStride
>
();
}
else
if
(
name
==
"TopDownEvalAffine"
)
{
}
else
if
(
name
==
"TopDownEvalAffine"
)
{
return
std
::
make_shared
<
TopDownEvalAffine
>
();
return
std
::
make_shared
<
TopDownEvalAffine
>
();
}
else
if
(
name
==
"WarpAffine"
)
{
return
std
::
make_shared
<
WarpAffine
>
();
}
}
std
::
cerr
<<
"can not find function of OP: "
<<
name
std
::
cerr
<<
"can not find function of OP: "
<<
name
<<
" and return: nullptr"
<<
std
::
endl
;
<<
" and return: nullptr"
<<
std
::
endl
;
...
...
deploy/cpp/src/preprocess_op.cc
浏览文件 @
10b62145
...
@@ -177,11 +177,64 @@ void TopDownEvalAffine::Run(cv::Mat* im, ImageBlob* data) {
...
@@ -177,11 +177,64 @@ void TopDownEvalAffine::Run(cv::Mat* im, ImageBlob* data) {
};
};
}
}
void
GetAffineTrans
(
const
cv
::
Point2f
center
,
const
cv
::
Point2f
input_size
,
const
cv
::
Point2f
output_size
,
cv
::
Mat
*
trans
)
{
cv
::
Point2f
srcTri
[
3
];
cv
::
Point2f
dstTri
[
3
];
float
src_w
=
input_size
.
x
;
float
dst_w
=
output_size
.
x
;
float
dst_h
=
output_size
.
y
;
cv
::
Point2f
src_dir
(
0
,
-
0.5
*
src_w
);
cv
::
Point2f
dst_dir
(
0
,
-
0.5
*
dst_w
);
srcTri
[
0
]
=
center
;
srcTri
[
1
]
=
center
+
src_dir
;
cv
::
Point2f
src_d
=
srcTri
[
0
]
-
srcTri
[
1
];
srcTri
[
2
]
=
srcTri
[
1
]
+
cv
::
Point2f
(
-
src_d
.
y
,
src_d
.
x
);
dstTri
[
0
]
=
cv
::
Point2f
(
dst_w
*
0.5
,
dst_h
*
0.5
);
dstTri
[
1
]
=
cv
::
Point2f
(
dst_w
*
0.5
,
dst_h
*
0.5
)
+
dst_dir
;
cv
::
Point2f
dst_d
=
dstTri
[
0
]
-
dstTri
[
1
];
dstTri
[
2
]
=
dstTri
[
1
]
+
cv
::
Point2f
(
-
dst_d
.
y
,
dst_d
.
x
);
*
trans
=
cv
::
getAffineTransform
(
srcTri
,
dstTri
);
}
void
WarpAffine
::
Run
(
cv
::
Mat
*
im
,
ImageBlob
*
data
)
{
cv
::
cvtColor
(
*
im
,
*
im
,
cv
::
COLOR_RGB2BGR
);
cv
::
Mat
trans
(
2
,
3
,
CV_32FC1
);
cv
::
Point2f
center
;
cv
::
Point2f
input_size
;
int
h
=
im
->
rows
;
int
w
=
im
->
cols
;
if
(
keep_res_
)
{
input_h_
=
(
h
|
pad_
)
+
1
;
input_w_
=
(
w
+
pad_
)
+
1
;
input_size
=
cv
::
Point2f
(
input_w_
,
input_h_
);
center
=
cv
::
Point2f
(
w
/
2
,
h
/
2
);
}
else
{
float
s
=
std
::
max
(
h
,
w
)
*
1.0
;
input_size
=
cv
::
Point2f
(
s
,
s
);
center
=
cv
::
Point2f
(
w
/
2.
,
h
/
2.
);
}
cv
::
Point2f
output_size
(
input_w_
,
input_h_
);
GetAffineTrans
(
center
,
input_size
,
output_size
,
&
trans
);
cv
::
warpAffine
(
*
im
,
*
im
,
trans
,
cv
::
Size
(
input_w_
,
input_h_
));
data
->
in_net_shape_
=
{
static_cast
<
float
>
(
input_h_
),
static_cast
<
float
>
(
input_w_
),
};
}
// Preprocessor op running order
// Preprocessor op running order
const
std
::
vector
<
std
::
string
>
Preprocessor
::
RUN_ORDER
=
{
"InitInfo"
,
const
std
::
vector
<
std
::
string
>
Preprocessor
::
RUN_ORDER
=
{
"InitInfo"
,
"TopDownEvalAffine"
,
"TopDownEvalAffine"
,
"Resize"
,
"Resize"
,
"LetterBoxResize"
,
"LetterBoxResize"
,
"WarpAffine"
,
"NormalizeImage"
,
"NormalizeImage"
,
"PadStride"
,
"PadStride"
,
"Permute"
};
"Permute"
};
...
...
ppdet/modeling/post_process.py
浏览文件 @
10b62145
...
@@ -524,7 +524,7 @@ class CenterNetPostProcess(TTFBox):
...
@@ -524,7 +524,7 @@ class CenterNetPostProcess(TTFBox):
x2
=
xs
+
wh
[:,
0
:
1
]
/
2
x2
=
xs
+
wh
[:,
0
:
1
]
/
2
y2
=
ys
+
wh
[:,
1
:
2
]
/
2
y2
=
ys
+
wh
[:,
1
:
2
]
/
2
n
,
c
,
feat_h
,
feat_w
=
hm
.
shape
[:]
n
,
c
,
feat_h
,
feat_w
=
paddle
.
shape
(
hm
)
padw
=
(
feat_w
*
self
.
down_ratio
-
im_shape
[
0
,
1
])
/
2
padw
=
(
feat_w
*
self
.
down_ratio
-
im_shape
[
0
,
1
])
/
2
padh
=
(
feat_h
*
self
.
down_ratio
-
im_shape
[
0
,
0
])
/
2
padh
=
(
feat_h
*
self
.
down_ratio
-
im_shape
[
0
,
0
])
/
2
x1
=
x1
*
self
.
down_ratio
x1
=
x1
*
self
.
down_ratio
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录