Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
c910bf8d
P
PaddleOCR
项目概览
s920243400
/
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看板
未验证
提交
c910bf8d
编写于
1月 10, 2022
作者:
Z
zhoujun
提交者:
GitHub
1月 10, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5222 from WenmuZhou/update_whl_dygraph
rm model type check
上级
5a537bbc
c0ce890f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
8 deletion
+10
-8
paddleocr.py
paddleocr.py
+10
-8
未找到文件。
paddleocr.py
浏览文件 @
c910bf8d
...
...
@@ -47,7 +47,9 @@ SUPPORT_REC_MODEL = ['CRNN']
BASE_DIR
=
os
.
path
.
expanduser
(
"~/.paddleocr/"
)
DEFAULT_OCR_MODEL_VERSION
=
'PP-OCR'
SUPPORT_OCR_MODEL_VERSION
=
[
'PP-OCR'
,
'PP-OCRv2'
]
DEFAULT_STRUCTURE_MODEL_VERSION
=
'STRUCTURE'
SUPPORT_STRUCTURE_MODEL_VERSION
=
[
'STRUCTURE'
]
MODEL_URLS
=
{
'OCR'
:
{
'PP-OCRv2'
:
{
...
...
@@ -190,6 +192,7 @@ def parse_args(mMain=True):
parser
.
add_argument
(
"--ocr_version"
,
type
=
str
,
choices
=
SUPPORT_OCR_MODEL_VERSION
,
default
=
'PP-OCRv2'
,
help
=
'OCR Model version, the current model support list is as follows: '
'1. PP-OCRv2 Support Chinese detection and recognition model. '
...
...
@@ -198,6 +201,7 @@ def parse_args(mMain=True):
parser
.
add_argument
(
"--structure_version"
,
type
=
str
,
choices
=
SUPPORT_STRUCTURE_MODEL_VERSION
,
default
=
'STRUCTURE'
,
help
=
'Model version, the current model support list is as follows:'
' 1. STRUCTURE Support en table structure model.'
)
...
...
@@ -257,26 +261,20 @@ def get_model_config(type, version, model_type, lang):
DEFAULT_MODEL_VERSION
=
DEFAULT_STRUCTURE_MODEL_VERSION
else
:
raise
NotImplementedError
model_urls
=
MODEL_URLS
[
type
]
if
version
not
in
model_urls
:
logger
.
warning
(
'version {} not in {}, auto switch to version {}'
.
format
(
version
,
model_urls
.
keys
(),
DEFAULT_MODEL_VERSION
))
version
=
DEFAULT_MODEL_VERSION
if
model_type
not
in
model_urls
[
version
]:
if
model_type
in
model_urls
[
DEFAULT_MODEL_VERSION
]:
logger
.
warning
(
'version {} not support {} models, auto switch to version {}'
.
format
(
version
,
model_type
,
DEFAULT_MODEL_VERSION
))
version
=
DEFAULT_MODEL_VERSION
else
:
logger
.
error
(
'{} models is not support, we only support {}'
.
format
(
model_type
,
model_urls
[
DEFAULT_MODEL_VERSION
].
keys
()))
sys
.
exit
(
-
1
)
if
lang
not
in
model_urls
[
version
][
model_type
]:
if
lang
in
model_urls
[
DEFAULT_MODEL_VERSION
][
model_type
]:
logger
.
warning
(
'lang {} is not support in {}, auto switch to version {}'
.
format
(
lang
,
version
,
DEFAULT_MODEL_VERSION
))
version
=
DEFAULT_MODEL_VERSION
else
:
logger
.
error
(
...
...
@@ -296,6 +294,8 @@ class PaddleOCR(predict_system.TextSystem):
"""
params
=
parse_args
(
mMain
=
False
)
params
.
__dict__
.
update
(
**
kwargs
)
assert
params
.
ocr_version
in
SUPPORT_OCR_MODEL_VERSION
,
"ocr_version must in {}, but get {}"
.
format
(
SUPPORT_OCR_MODEL_VERSION
,
params
.
ocr_version
)
params
.
use_gpu
=
check_gpu
(
params
.
use_gpu
)
if
not
params
.
show_log
:
...
...
@@ -398,6 +398,8 @@ class PPStructure(OCRSystem):
def
__init__
(
self
,
**
kwargs
):
params
=
parse_args
(
mMain
=
False
)
params
.
__dict__
.
update
(
**
kwargs
)
assert
params
.
structure_version
in
SUPPORT_STRUCTURE_MODEL_VERSION
,
"structure_version must in {}, but get {}"
.
format
(
SUPPORT_STRUCTURE_MODEL_VERSION
,
params
.
structure_version
)
params
.
use_gpu
=
check_gpu
(
params
.
use_gpu
)
if
not
params
.
show_log
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录