Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
秋饼
PaddleOCR
提交
8d113f7d
P
PaddleOCR
项目概览
秋饼
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8d113f7d
编写于
12月 11, 2020
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update link
上级
913e11cb
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
66 addition
and
59 deletion
+66
-59
doc/doc_ch/whl.md
doc/doc_ch/whl.md
+1
-1
paddleocr.py
paddleocr.py
+65
-58
未找到文件。
doc/doc_ch/whl.md
浏览文件 @
8d113f7d
...
@@ -348,7 +348,7 @@ im_show.save('result.jpg')
...
@@ -348,7 +348,7 @@ im_show.save('result.jpg')
| cls_batch_num | 进行分类时,同时前向的图片数 |30 |
| cls_batch_num | 进行分类时,同时前向的图片数 |30 |
| enable_mkldnn | 是否启用mkldnn | FALSE |
| enable_mkldnn | 是否启用mkldnn | FALSE |
| use_zero_copy_run | 是否通过zero_copy_run的方式进行前向 | FALSE |
| use_zero_copy_run | 是否通过zero_copy_run的方式进行前向 | FALSE |
| lang | 模型语言类型,目前支持
中文(ch)和英文(en)
| ch |
| lang | 模型语言类型,目前支持
目前支持中英文(ch)、英文(en)、法语(french)、德语(german)、韩语(korean)、日语(japan)
| ch |
| det | 前向时使用启动检测 | TRUE |
| det | 前向时使用启动检测 | TRUE |
| rec | 前向时是否启动识别 | TRUE |
| rec | 前向时是否启动识别 | TRUE |
| cls | 前向时是否启动分类 (命令行模式下使用use_angle_cls控制前向是否启动分类) | FALSE |
| cls | 前向时是否启动分类 (命令行模式下使用use_angle_cls控制前向是否启动分类) | FALSE |
paddleocr.py
浏览文件 @
8d113f7d
...
@@ -35,44 +35,45 @@ __all__ = ['PaddleOCR']
...
@@ -35,44 +35,45 @@ __all__ = ['PaddleOCR']
model_urls
=
{
model_urls
=
{
'det'
:
'det'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/det/ch_ppocr_mobile_v1.1
_det_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0
_det_infer.tar'
,
'rec'
:
{
'rec'
:
{
'ch'
:
{
'ch'
:
{
'url'
:
'url'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/rec/ch_ppocr_mobile_v1.1
_rec_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0
_rec_infer.tar'
,
'dict_path'
:
'./ppocr/utils/ppocr_keys_v1.txt'
'dict_path'
:
'./ppocr/utils/ppocr_keys_v1.txt'
},
},
'en'
:
{
'en'
:
{
'url'
:
'url'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/en/en_ppocr_mobile_v1.1
_rec_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/multilingual/en_number_mobile_v2.0
_rec_infer.tar'
,
'dict_path'
:
'./ppocr/utils/
ic15
_dict.txt'
'dict_path'
:
'./ppocr/utils/
dict/en
_dict.txt'
},
},
'french'
:
{
'french'
:
{
'url'
:
'url'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/fr/french_ppocr_mobile_v1.1
_rec_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/multilingual/french_mobile_v2.0
_rec_infer.tar'
,
'dict_path'
:
'./ppocr/utils/dict/french_dict.txt'
'dict_path'
:
'./ppocr/utils/dict/french_dict.txt'
},
},
'german'
:
{
'german'
:
{
'url'
:
'url'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/ge/german_ppocr_mobile_v1.1
_rec_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/multilingual/german_mobile_v2.0
_rec_infer.tar'
,
'dict_path'
:
'./ppocr/utils/dict/german_dict.txt'
'dict_path'
:
'./ppocr/utils/dict/german_dict.txt'
},
},
'korean'
:
{
'korean'
:
{
'url'
:
'url'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/kr/korean_ppocr_mobile_v1.1
_rec_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/multilingual/korean_mobile_v2.0
_rec_infer.tar'
,
'dict_path'
:
'./ppocr/utils/dict/korean_dict.txt'
'dict_path'
:
'./ppocr/utils/dict/korean_dict.txt'
},
},
'japan'
:
{
'japan'
:
{
'url'
:
'url'
:
'https://paddleocr.bj.bcebos.com/20-09-22/mobile/jp/japan_ppocr_mobile_v1.1
_rec_infer.tar'
,
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/multilingual/japan_mobile_v2.0
_rec_infer.tar'
,
'dict_path'
:
'./ppocr/utils/dict/japan_dict.txt'
'dict_path'
:
'./ppocr/utils/dict/japan_dict.txt'
}
}
},
},
'cls'
:
'cls'
:
'https://paddleocr.bj.bcebos.com/20-09-22/cls/ch_ppocr_mobile_v1.1
_cls_infer.tar'
'https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0
_cls_infer.tar'
}
}
SUPPORT_DET_MODEL
=
[
'DB'
]
SUPPORT_DET_MODEL
=
[
'DB'
]
VERSION
=
2.0
SUPPORT_REC_MODEL
=
[
'CRNN'
]
SUPPORT_REC_MODEL
=
[
'CRNN'
]
BASE_DIR
=
os
.
path
.
expanduser
(
"~/.paddleocr/"
)
BASE_DIR
=
os
.
path
.
expanduser
(
"~/.paddleocr/"
)
...
@@ -94,20 +95,24 @@ def download_with_progressbar(url, save_path):
...
@@ -94,20 +95,24 @@ def download_with_progressbar(url, save_path):
def
maybe_download
(
model_storage_directory
,
url
):
def
maybe_download
(
model_storage_directory
,
url
):
# using custom model
# using custom model
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
tar_file_name_list
=
[
model_storage_directory
,
'model'
))
or
not
os
.
path
.
exists
(
'inference.pdiparams'
,
'inference.pdiparams.info'
,
'inference.pdmodel'
os
.
path
.
join
(
model_storage_directory
,
'params'
)):
]
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
model_storage_directory
,
'inference.pdiparams'
)
)
or
not
os
.
path
.
exists
(
os
.
path
.
join
(
model_storage_directory
,
'inference.pdmodel'
)):
tmp_path
=
os
.
path
.
join
(
model_storage_directory
,
url
.
split
(
'/'
)[
-
1
])
tmp_path
=
os
.
path
.
join
(
model_storage_directory
,
url
.
split
(
'/'
)[
-
1
])
print
(
'download {} to {}'
.
format
(
url
,
tmp_path
))
print
(
'download {} to {}'
.
format
(
url
,
tmp_path
))
os
.
makedirs
(
model_storage_directory
,
exist_ok
=
True
)
os
.
makedirs
(
model_storage_directory
,
exist_ok
=
True
)
download_with_progressbar
(
url
,
tmp_path
)
download_with_progressbar
(
url
,
tmp_path
)
with
tarfile
.
open
(
tmp_path
,
'r'
)
as
tarObj
:
with
tarfile
.
open
(
tmp_path
,
'r'
)
as
tarObj
:
for
member
in
tarObj
.
getmembers
():
for
member
in
tarObj
.
getmembers
():
if
"model"
in
member
.
name
:
filename
=
None
filename
=
'model'
for
tar_file_name
in
tar_file_name_list
:
elif
"params"
in
member
.
name
:
if
tar_file_name
in
member
.
name
:
filename
=
'params'
filename
=
tar_file_name
els
e
:
if
filename
is
Non
e
:
continue
continue
file
=
tarObj
.
extractfile
(
member
)
file
=
tarObj
.
extractfile
(
member
)
with
open
(
with
open
(
...
@@ -176,7 +181,8 @@ def parse_args(mMain=True, add_help=True):
...
@@ -176,7 +181,8 @@ def parse_args(mMain=True, add_help=True):
parser
.
add_argument
(
"--use_angle_cls"
,
type
=
str2bool
,
default
=
False
)
parser
.
add_argument
(
"--use_angle_cls"
,
type
=
str2bool
,
default
=
False
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
else
:
else
:
return
argparse
.
Namespace
(
use_gpu
=
True
,
return
argparse
.
Namespace
(
use_gpu
=
True
,
ir_optim
=
True
,
ir_optim
=
True
,
use_tensorrt
=
False
,
use_tensorrt
=
False
,
gpu_mem
=
8000
,
gpu_mem
=
8000
,
...
@@ -211,8 +217,7 @@ def parse_args(mMain=True, add_help=True):
...
@@ -211,8 +217,7 @@ def parse_args(mMain=True, add_help=True):
lang
=
'ch'
,
lang
=
'ch'
,
det
=
True
,
det
=
True
,
rec
=
True
,
rec
=
True
,
use_angle_cls
=
False
use_angle_cls
=
False
)
)
class
PaddleOCR
(
predict_system
.
TextSystem
):
class
PaddleOCR
(
predict_system
.
TextSystem
):
...
@@ -235,12 +240,14 @@ class PaddleOCR(predict_system.TextSystem):
...
@@ -235,12 +240,14 @@ class PaddleOCR(predict_system.TextSystem):
# init model dir
# init model dir
if
postprocess_params
.
det_model_dir
is
None
:
if
postprocess_params
.
det_model_dir
is
None
:
postprocess_params
.
det_model_dir
=
os
.
path
.
join
(
BASE_DIR
,
'det'
)
postprocess_params
.
det_model_dir
=
os
.
path
.
join
(
BASE_DIR
,
'{}/det'
.
format
(
VERSION
))
if
postprocess_params
.
rec_model_dir
is
None
:
if
postprocess_params
.
rec_model_dir
is
None
:
postprocess_params
.
rec_model_dir
=
os
.
path
.
join
(
postprocess_params
.
rec_model_dir
=
os
.
path
.
join
(
BASE_DIR
,
'
rec/{}'
.
format
(
lang
))
BASE_DIR
,
'
{}/rec/{}'
.
format
(
VERSION
,
lang
))
if
postprocess_params
.
cls_model_dir
is
None
:
if
postprocess_params
.
cls_model_dir
is
None
:
postprocess_params
.
cls_model_dir
=
os
.
path
.
join
(
BASE_DIR
,
'cls'
)
postprocess_params
.
cls_model_dir
=
os
.
path
.
join
(
BASE_DIR
,
'{}/cls'
.
format
(
VERSION
))
print
(
postprocess_params
)
print
(
postprocess_params
)
# download model
# download model
maybe_download
(
postprocess_params
.
det_model_dir
,
model_urls
[
'det'
])
maybe_download
(
postprocess_params
.
det_model_dir
,
model_urls
[
'det'
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录