Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
8930b445
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8930b445
编写于
7月 14, 2020
作者:
D
dyning
提交者:
GitHub
7月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #326 from littletomatodonkey/fix_png
fix cpp infer png
上级
3b96d482
963dde7a
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
28 addition
and
25 deletion
+28
-25
deploy/cpp_infer/include/config.h
deploy/cpp_infer/include/config.h
+4
-0
deploy/cpp_infer/include/ocr_det.h
deploy/cpp_infer/include/ocr_det.h
+4
-1
deploy/cpp_infer/include/ocr_rec.h
deploy/cpp_infer/include/ocr_rec.h
+3
-1
deploy/cpp_infer/readme.md
deploy/cpp_infer/readme.md
+5
-0
deploy/cpp_infer/src/main.cpp
deploy/cpp_infer/src/main.cpp
+2
-2
deploy/cpp_infer/src/ocr_det.cpp
deploy/cpp_infer/src/ocr_det.cpp
+3
-2
deploy/cpp_infer/src/ocr_rec.cpp
deploy/cpp_infer/src/ocr_rec.cpp
+3
-16
deploy/cpp_infer/tools/config.txt
deploy/cpp_infer/tools/config.txt
+3
-2
deploy/cpp_infer/tools/run.sh
deploy/cpp_infer/tools/run.sh
+1
-1
deploy/imgs/cpp_infer_pred_12.png
deploy/imgs/cpp_infer_pred_12.png
+0
-0
未找到文件。
deploy/cpp_infer/include/config.h
浏览文件 @
8930b445
...
...
@@ -39,6 +39,8 @@ public:
this
->
cpu_math_library_num_threads
=
stoi
(
config_map_
[
"cpu_math_library_num_threads"
]);
this
->
use_mkldnn
=
bool
(
stoi
(
config_map_
[
"use_mkldnn"
]));
this
->
max_side_len
=
stoi
(
config_map_
[
"max_side_len"
]);
this
->
det_db_thresh
=
stod
(
config_map_
[
"det_db_thresh"
]);
...
...
@@ -64,6 +66,8 @@ public:
int
cpu_math_library_num_threads
=
1
;
bool
use_mkldnn
=
false
;
int
max_side_len
=
960
;
double
det_db_thresh
=
0.3
;
...
...
deploy/cpp_infer/include/ocr_det.h
浏览文件 @
8930b445
...
...
@@ -39,7 +39,8 @@ public:
explicit
DBDetector
(
const
std
::
string
&
model_dir
,
const
bool
&
use_gpu
,
const
int
&
gpu_id
,
const
int
&
gpu_mem
,
const
int
&
cpu_math_library_num_threads
,
const
int
&
max_side_len
,
const
double
&
det_db_thresh
,
const
bool
&
use_mkldnn
,
const
int
&
max_side_len
,
const
double
&
det_db_thresh
,
const
double
&
det_db_box_thresh
,
const
double
&
det_db_unclip_ratio
,
const
bool
&
visualize
)
{
...
...
@@ -47,6 +48,7 @@ public:
this
->
gpu_id_
=
gpu_id
;
this
->
gpu_mem_
=
gpu_mem
;
this
->
cpu_math_library_num_threads_
=
cpu_math_library_num_threads
;
this
->
use_mkldnn_
=
use_mkldnn
;
this
->
max_side_len_
=
max_side_len
;
...
...
@@ -72,6 +74,7 @@ private:
int
gpu_id_
=
0
;
int
gpu_mem_
=
4000
;
int
cpu_math_library_num_threads_
=
4
;
bool
use_mkldnn_
=
false
;
int
max_side_len_
=
960
;
...
...
deploy/cpp_infer/include/ocr_rec.h
浏览文件 @
8930b445
...
...
@@ -38,11 +38,12 @@ public:
explicit
CRNNRecognizer
(
const
std
::
string
&
model_dir
,
const
bool
&
use_gpu
,
const
int
&
gpu_id
,
const
int
&
gpu_mem
,
const
int
&
cpu_math_library_num_threads
,
const
string
&
label_path
)
{
const
bool
&
use_mkldnn
,
const
string
&
label_path
)
{
this
->
use_gpu_
=
use_gpu
;
this
->
gpu_id_
=
gpu_id
;
this
->
gpu_mem_
=
gpu_mem
;
this
->
cpu_math_library_num_threads_
=
cpu_math_library_num_threads
;
this
->
use_mkldnn_
=
use_mkldnn
;
this
->
label_list_
=
Utility
::
ReadDict
(
label_path
);
...
...
@@ -61,6 +62,7 @@ private:
int
gpu_id_
=
0
;
int
gpu_mem_
=
4000
;
int
cpu_math_library_num_threads_
=
4
;
bool
use_mkldnn_
=
false
;
std
::
vector
<
std
::
string
>
label_list_
;
...
...
deploy/cpp_infer/readme.md
浏览文件 @
8930b445
...
...
@@ -195,3 +195,8 @@ sh tools/run.sh
<div
align=
"center"
>
<img
src=
"../imgs/cpp_infer_pred_12.png"
width=
"600"
>
</div>
### 2.3 注意
*
C++预测默认未开启MKLDNN(
`tools/config.txt`
中的
`use_mkldnn`
设置为0),如果需要使用MKLDNN进行预测加速,则需要将
`use_mkldnn`
修改为1,同时使用最新版本的Paddle源码编译预测库。在使用MKLDNN进行CPU预测时,如果同时预测多张图像,则会出现内存泄露的问题(不打开MKLDNN则没有该问题),目前该问题正在修复中,临时解决方案为:预测多张图片时,每隔30张图片左右对识别(
`CRNNRecognizer`
)和检测类(
`DBDetector`
)重新初始化一次。
deploy/cpp_infer/src/main.cpp
浏览文件 @
8930b445
...
...
@@ -50,12 +50,12 @@ int main(int argc, char **argv) {
DBDetector
det
(
config
.
det_model_dir
,
config
.
use_gpu
,
config
.
gpu_id
,
config
.
gpu_mem
,
config
.
cpu_math_library_num_threads
,
config
.
max_side_len
,
config
.
det_db_thresh
,
config
.
use_mkldnn
,
config
.
max_side_len
,
config
.
det_db_thresh
,
config
.
det_db_box_thresh
,
config
.
det_db_unclip_ratio
,
config
.
visualize
);
CRNNRecognizer
rec
(
config
.
rec_model_dir
,
config
.
use_gpu
,
config
.
gpu_id
,
config
.
gpu_mem
,
config
.
cpu_math_library_num_threads
,
config
.
char_list_file
);
config
.
use_mkldnn
,
config
.
char_list_file
);
auto
start
=
std
::
chrono
::
system_clock
::
now
();
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>>>
boxes
;
...
...
deploy/cpp_infer/src/ocr_det.cpp
浏览文件 @
8930b445
...
...
@@ -13,7 +13,6 @@
// limitations under the License.
#include <include/ocr_det.h>
#include <stdlib.h>
namespace
PaddleOCR
{
...
...
@@ -25,7 +24,9 @@ void DBDetector::LoadModel(const std::string &model_dir) {
config
.
EnableUseGpu
(
this
->
gpu_mem_
,
this
->
gpu_id_
);
}
else
{
config
.
DisableGpu
();
// config.EnableMKLDNN(); // not sugesteed to use for now
if
(
this
->
use_mkldnn_
)
{
config
.
EnableMKLDNN
();
}
config
.
SetCpuMathLibraryNumThreads
(
this
->
cpu_math_library_num_threads_
);
}
...
...
deploy/cpp_infer/src/ocr_rec.cpp
浏览文件 @
8930b445
...
...
@@ -12,21 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "paddle_api.h"
#include "paddle_inference_api.h"
#include <chrono>
#include <iomanip>
#include <iostream>
#include <ostream>
#include <vector>
#include <cstring>
#include <fstream>
#include <numeric>
#include <include/ocr_rec.h>
namespace
PaddleOCR
{
...
...
@@ -128,7 +113,9 @@ void CRNNRecognizer::LoadModel(const std::string &model_dir) {
config
.
EnableUseGpu
(
this
->
gpu_mem_
,
this
->
gpu_id_
);
}
else
{
config
.
DisableGpu
();
// config.EnableMKLDNN(); // not sugesteed to use for now
if
(
this
->
use_mkldnn_
)
{
config
.
EnableMKLDNN
();
}
config
.
SetCpuMathLibraryNumThreads
(
this
->
cpu_math_library_num_threads_
);
}
...
...
deploy/cpp_infer/tools/config.txt
浏览文件 @
8930b445
...
...
@@ -2,7 +2,8 @@
use_gpu 0
gpu_id 0
gpu_mem 4000
cpu_math_library_num_threads 1
cpu_math_library_num_threads 10
use_mkldnn 0
# det config
max_side_len 960
...
...
@@ -17,5 +18,5 @@ char_list_file ../../ppocr/utils/ppocr_keys_v1.txt
img_path ../../doc/imgs/11.jpg
# show the detection results
visualize
1
visualize
0
deploy/cpp_infer/tools/run.sh
浏览文件 @
8930b445
./build/ocr_system ./tools/config.txt ../../doc/imgs/
6
.jpg
./build/ocr_system ./tools/config.txt ../../doc/imgs/
12
.jpg
deploy/imgs/cpp_infer_pred_12.png
查看替换文件 @
3b96d482
浏览文件 @
8930b445
78.4 KB
|
W:
|
H:
26.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录