Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
d64a4c3f
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d64a4c3f
编写于
9月 20, 2020
作者:
D
Double_V
提交者:
GitHub
9月 20, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #756 from LDOUBLEV/fixocr
advance db post_process
上级
edd4c33f
b6289d0e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
18 addition
and
12 deletion
+18
-12
deploy/cpp_infer/src/ocr_det.cpp
deploy/cpp_infer/src/ocr_det.cpp
+4
-2
deploy/cpp_infer/src/postprocess_op.cpp
deploy/cpp_infer/src/postprocess_op.cpp
+1
-1
deploy/cpp_infer/tools/config.txt
deploy/cpp_infer/tools/config.txt
+1
-1
deploy/lite/config.txt
deploy/lite/config.txt
+1
-1
deploy/lite/db_post_process.cc
deploy/lite/db_post_process.cc
+1
-1
deploy/lite/ocr_db_crnn.cc
deploy/lite/ocr_db_crnn.cc
+4
-2
ppocr/postprocess/db_postprocess.py
ppocr/postprocess/db_postprocess.py
+4
-2
tools/infer/utility.py
tools/infer/utility.py
+2
-2
未找到文件。
deploy/cpp_infer/src/ocr_det.cpp
浏览文件 @
d64a4c3f
...
...
@@ -108,9 +108,11 @@ void DBDetector::Run(cv::Mat &img,
const
double
maxvalue
=
255
;
cv
::
Mat
bit_map
;
cv
::
threshold
(
cbuf_map
,
bit_map
,
threshold
,
maxvalue
,
cv
::
THRESH_BINARY
);
cv
::
Mat
dilation_map
;
cv
::
Mat
dila_ele
=
cv
::
getStructuringElement
(
cv
::
MORPH_RECT
,
cv
::
Size
(
2
,
2
));
cv
::
dilate
(
bit_map
,
dilation_map
,
dila_ele
);
boxes
=
post_processor_
.
BoxesFromBitmap
(
pred_map
,
bit
_map
,
this
->
det_db_box_thresh_
,
this
->
det_db_unclip_ratio_
);
pred_map
,
dilation
_map
,
this
->
det_db_box_thresh_
,
this
->
det_db_unclip_ratio_
);
boxes
=
post_processor_
.
FilterTagDetRes
(
boxes
,
ratio_h
,
ratio_w
,
srcimg
);
...
...
deploy/cpp_infer/src/postprocess_op.cpp
浏览文件 @
d64a4c3f
...
...
@@ -294,7 +294,7 @@ PostProcessor::FilterTagDetRes(std::vector<std::vector<std::vector<int>>> boxes,
pow
(
boxes
[
n
][
0
][
1
]
-
boxes
[
n
][
1
][
1
],
2
)));
rect_height
=
int
(
sqrt
(
pow
(
boxes
[
n
][
0
][
0
]
-
boxes
[
n
][
3
][
0
],
2
)
+
pow
(
boxes
[
n
][
0
][
1
]
-
boxes
[
n
][
3
][
1
],
2
)));
if
(
rect_width
<=
10
||
rect_height
<=
10
)
if
(
rect_width
<=
4
||
rect_height
<=
4
)
continue
;
root_points
.
push_back
(
boxes
[
n
]);
}
...
...
deploy/cpp_infer/tools/config.txt
浏览文件 @
d64a4c3f
...
...
@@ -10,7 +10,7 @@ use_zero_copy_run 1
max_side_len 960
det_db_thresh 0.3
det_db_box_thresh 0.5
det_db_unclip_ratio
2.0
det_db_unclip_ratio
1.6
det_model_dir ./inference/det_db
# cls config
...
...
deploy/lite/config.txt
浏览文件 @
d64a4c3f
max_side_len 960
det_db_thresh 0.3
det_db_box_thresh 0.5
det_db_unclip_ratio 2.0
\ No newline at end of file
det_db_unclip_ratio 1.6
\ No newline at end of file
deploy/lite/db_post_process.cc
浏览文件 @
d64a4c3f
...
...
@@ -293,7 +293,7 @@ FilterTagDetRes(std::vector<std::vector<std::vector<int>>> boxes, float ratio_h,
rect_height
=
static_cast
<
int
>
(
sqrt
(
pow
(
boxes
[
n
][
0
][
0
]
-
boxes
[
n
][
3
][
0
],
2
)
+
pow
(
boxes
[
n
][
0
][
1
]
-
boxes
[
n
][
3
][
1
],
2
)));
if
(
rect_width
<=
10
||
rect_height
<=
10
)
if
(
rect_width
<=
4
||
rect_height
<=
4
)
continue
;
root_points
.
push_back
(
boxes
[
n
]);
}
...
...
deploy/lite/ocr_db_crnn.cc
浏览文件 @
d64a4c3f
...
...
@@ -289,8 +289,10 @@ RunDetModel(std::shared_ptr<PaddlePredictor> predictor, cv::Mat img,
const
double
maxvalue
=
255
;
cv
::
Mat
bit_map
;
cv
::
threshold
(
cbuf_map
,
bit_map
,
threshold
,
maxvalue
,
cv
::
THRESH_BINARY
);
auto
boxes
=
BoxesFromBitmap
(
pred_map
,
bit_map
,
Config
);
cv
::
Mat
dilation_map
;
cv
::
Mat
dila_ele
=
cv
::
getStructuringElement
(
cv
::
MORPH_RECT
,
cv
::
Size
(
2
,
2
));
cv
::
dilate
(
bit_map
,
dilation_map
,
dila_ele
);
auto
boxes
=
BoxesFromBitmap
(
pred_map
,
dilation_map
,
Config
);
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>>>
filter_boxes
=
FilterTagDetRes
(
boxes
,
ratio_hw
[
0
],
ratio_hw
[
1
],
srcimg
);
...
...
ppocr/postprocess/db_postprocess.py
浏览文件 @
d64a4c3f
...
...
@@ -37,6 +37,7 @@ class DBPostProcess(object):
self
.
max_candidates
=
params
[
'max_candidates'
]
self
.
unclip_ratio
=
params
[
'unclip_ratio'
]
self
.
min_size
=
3
self
.
dilation_kernel
=
np
.
array
([[
1
,
1
],
[
1
,
1
]])
def
boxes_from_bitmap
(
self
,
pred
,
_bitmap
,
dest_width
,
dest_height
):
'''
...
...
@@ -140,8 +141,9 @@ class DBPostProcess(object):
boxes_batch
=
[]
for
batch_index
in
range
(
pred
.
shape
[
0
]):
height
,
width
=
pred
.
shape
[
-
2
:]
tmp_boxes
,
tmp_scores
=
self
.
boxes_from_bitmap
(
pred
[
batch_index
],
segmentation
[
batch_index
],
width
,
height
)
mask
=
cv2
.
dilate
(
np
.
array
(
segmentation
[
batch_index
]).
astype
(
np
.
uint8
),
self
.
dilation_kernel
)
tmp_boxes
,
tmp_scores
=
self
.
boxes_from_bitmap
(
pred
[
batch_index
],
mask
,
width
,
height
)
boxes
=
[]
for
k
in
range
(
len
(
tmp_boxes
)):
...
...
tools/infer/utility.py
浏览文件 @
d64a4c3f
...
...
@@ -47,7 +47,7 @@ def parse_args():
# DB parmas
parser
.
add_argument
(
"--det_db_thresh"
,
type
=
float
,
default
=
0.3
)
parser
.
add_argument
(
"--det_db_box_thresh"
,
type
=
float
,
default
=
0.5
)
parser
.
add_argument
(
"--det_db_unclip_ratio"
,
type
=
float
,
default
=
2.0
)
parser
.
add_argument
(
"--det_db_unclip_ratio"
,
type
=
float
,
default
=
1.6
)
# EAST parmas
parser
.
add_argument
(
"--det_east_score_thresh"
,
type
=
float
,
default
=
0.8
)
...
...
@@ -64,7 +64,7 @@ def parse_args():
parser
.
add_argument
(
"--rec_model_dir"
,
type
=
str
)
parser
.
add_argument
(
"--rec_image_shape"
,
type
=
str
,
default
=
"3, 32, 320"
)
parser
.
add_argument
(
"--rec_char_type"
,
type
=
str
,
default
=
'ch'
)
parser
.
add_argument
(
"--rec_batch_num"
,
type
=
int
,
default
=
30
)
parser
.
add_argument
(
"--rec_batch_num"
,
type
=
int
,
default
=
6
)
parser
.
add_argument
(
"--max_text_length"
,
type
=
int
,
default
=
25
)
parser
.
add_argument
(
"--rec_char_dict_path"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录