Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
16752dd7
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看板
提交
16752dd7
编写于
5月 09, 2022
作者:
T
tink2123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modified default shape
上级
8f7518cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
7 deletion
+14
-7
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+9
-5
tools/infer/predict_system.py
tools/infer/predict_system.py
+4
-1
tools/infer/utility.py
tools/infer/utility.py
+1
-1
未找到文件。
tools/infer/predict_rec.py
浏览文件 @
16752dd7
...
...
@@ -131,7 +131,7 @@ class TextRecognizer(object):
padding_im
=
np
.
zeros
((
imgC
,
imgH
,
imgW
),
dtype
=
np
.
float32
)
padding_im
[:,
:,
0
:
resized_w
]
=
resized_image
return
padding_im
def
resize_norm_img_svtr
(
self
,
img
,
image_shape
):
imgC
,
imgH
,
imgW
=
image_shape
...
...
@@ -274,7 +274,7 @@ class TextRecognizer(object):
wh_ratio
=
w
*
1.0
/
h
max_wh_ratio
=
max
(
max_wh_ratio
,
wh_ratio
)
for
ino
in
range
(
beg_img_no
,
end_img_no
):
if
self
.
rec_algorithm
==
"SAR"
:
norm_img
,
_
,
_
,
valid_ratio
=
self
.
resize_norm_img_sar
(
img_list
[
indices
[
ino
]],
self
.
rec_image_shape
)
...
...
@@ -296,8 +296,8 @@ class TextRecognizer(object):
gsrm_slf_attn_bias2_list
.
append
(
norm_img
[
4
])
norm_img_batch
.
append
(
norm_img
[
0
])
elif
self
.
rec_algorithm
==
"SVTR"
:
norm_img
=
self
.
resize_norm_img_svtr
(
img_list
[
indices
[
ino
]],
self
.
rec_image_shape
)
norm_img
=
self
.
resize_norm_img_svtr
(
img_list
[
indices
[
ino
]],
self
.
rec_image_shape
)
norm_img
=
norm_img
[
np
.
newaxis
,
:]
norm_img_batch
.
append
(
norm_img
)
else
:
...
...
@@ -405,9 +405,13 @@ def main(args):
valid_image_file_list
=
[]
img_list
=
[]
logger
.
info
(
"In PP-OCRv3, rec_image_shape parameter defaults to '3, 48, 320', "
"if you are using an older PP-OCR, please set --rec_image_shape='3,32,320'"
)
# warmup 2 times
if
args
.
warmup
:
img
=
np
.
random
.
uniform
(
0
,
255
,
[
32
,
320
,
3
]).
astype
(
np
.
uint8
)
img
=
np
.
random
.
uniform
(
0
,
255
,
[
48
,
320
,
3
]).
astype
(
np
.
uint8
)
for
i
in
range
(
2
):
res
=
text_recognizer
([
img
]
*
int
(
args
.
rec_batch_num
))
...
...
tools/infer/predict_system.py
浏览文件 @
16752dd7
...
...
@@ -59,7 +59,7 @@ class TextSystem(object):
for
bno
in
range
(
bbox_num
):
cv2
.
imwrite
(
os
.
path
.
join
(
output_dir
,
f
"mg_crop_
{
bno
+
self
.
crop_image_res_index
}
.jpg"
),
f
"mg_crop_
{
bno
+
self
.
crop_image_res_index
}
.jpg
"
),
img_crop_list
[
bno
])
logger
.
debug
(
f
"
{
bno
}
,
{
rec_res
[
bno
]
}
"
)
self
.
crop_image_res_index
+=
bbox_num
...
...
@@ -133,6 +133,9 @@ def main(args):
os
.
makedirs
(
draw_img_save_dir
,
exist_ok
=
True
)
save_results
=
[]
logger
.
info
(
"In PP-OCRv3, rec_image_shape parameter defaults to '3, 48, 320', "
"if you are using an older PP-OCR, please set --rec_image_shape='3,32,320'"
)
# warm up 10 times
if
args
.
warmup
:
img
=
np
.
random
.
uniform
(
0
,
255
,
[
640
,
640
,
3
]).
astype
(
np
.
uint8
)
...
...
tools/infer/utility.py
浏览文件 @
16752dd7
...
...
@@ -81,7 +81,7 @@ def init_args():
# params for text recognizer
parser
.
add_argument
(
"--rec_algorithm"
,
type
=
str
,
default
=
'CRNN'
)
parser
.
add_argument
(
"--rec_model_dir"
,
type
=
str
)
parser
.
add_argument
(
"--rec_image_shape"
,
type
=
str
,
default
=
"3,
32
, 320"
)
parser
.
add_argument
(
"--rec_image_shape"
,
type
=
str
,
default
=
"3,
48
, 320"
)
parser
.
add_argument
(
"--rec_batch_num"
,
type
=
int
,
default
=
6
)
parser
.
add_argument
(
"--max_text_length"
,
type
=
int
,
default
=
25
)
parser
.
add_argument
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录