Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
2dbdae61
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看板
未验证
提交
2dbdae61
编写于
6月 01, 2022
作者:
X
xiaoting
提交者:
GitHub
6月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Cherry pick] update python serving for v3 (#6467)
* update pipeline to v3 * update pipeline to v3
上级
d75b1229
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
6 deletion
+6
-6
deploy/pdserving/ocr_reader.py
deploy/pdserving/ocr_reader.py
+3
-3
deploy/pdserving/web_service.py
deploy/pdserving/web_service.py
+3
-3
未找到文件。
deploy/pdserving/ocr_reader.py
浏览文件 @
2dbdae61
...
@@ -339,7 +339,7 @@ class CharacterOps(object):
...
@@ -339,7 +339,7 @@ class CharacterOps(object):
class
OCRReader
(
object
):
class
OCRReader
(
object
):
def
__init__
(
self
,
def
__init__
(
self
,
algorithm
=
"CRNN"
,
algorithm
=
"CRNN"
,
image_shape
=
[
3
,
32
,
320
],
image_shape
=
[
3
,
48
,
320
],
char_type
=
"ch"
,
char_type
=
"ch"
,
batch_num
=
1
,
batch_num
=
1
,
char_dict_path
=
"./ppocr_keys_v1.txt"
):
char_dict_path
=
"./ppocr_keys_v1.txt"
):
...
@@ -356,7 +356,7 @@ class OCRReader(object):
...
@@ -356,7 +356,7 @@ class OCRReader(object):
def
resize_norm_img
(
self
,
img
,
max_wh_ratio
):
def
resize_norm_img
(
self
,
img
,
max_wh_ratio
):
imgC
,
imgH
,
imgW
=
self
.
rec_image_shape
imgC
,
imgH
,
imgW
=
self
.
rec_image_shape
if
self
.
character_type
==
"ch"
:
if
self
.
character_type
==
"ch"
:
imgW
=
int
(
32
*
max_wh_ratio
)
imgW
=
int
(
imgH
*
max_wh_ratio
)
h
=
img
.
shape
[
0
]
h
=
img
.
shape
[
0
]
w
=
img
.
shape
[
1
]
w
=
img
.
shape
[
1
]
ratio
=
w
/
float
(
h
)
ratio
=
w
/
float
(
h
)
...
@@ -377,7 +377,7 @@ class OCRReader(object):
...
@@ -377,7 +377,7 @@ class OCRReader(object):
def
preprocess
(
self
,
img_list
):
def
preprocess
(
self
,
img_list
):
img_num
=
len
(
img_list
)
img_num
=
len
(
img_list
)
norm_img_batch
=
[]
norm_img_batch
=
[]
max_wh_ratio
=
0
max_wh_ratio
=
320
/
48.
for
ino
in
range
(
img_num
):
for
ino
in
range
(
img_num
):
h
,
w
=
img_list
[
ino
].
shape
[
0
:
2
]
h
,
w
=
img_list
[
ino
].
shape
[
0
:
2
]
wh_ratio
=
w
*
1.0
/
h
wh_ratio
=
w
*
1.0
/
h
...
...
deploy/pdserving/web_service.py
浏览文件 @
2dbdae61
...
@@ -63,7 +63,6 @@ class DetOp(Op):
...
@@ -63,7 +63,6 @@ class DetOp(Op):
dt_boxes_list
=
self
.
post_func
(
det_out
,
[
ratio_list
])
dt_boxes_list
=
self
.
post_func
(
det_out
,
[
ratio_list
])
dt_boxes
=
self
.
filter_func
(
dt_boxes_list
[
0
],
[
self
.
ori_h
,
self
.
ori_w
])
dt_boxes
=
self
.
filter_func
(
dt_boxes_list
[
0
],
[
self
.
ori_h
,
self
.
ori_w
])
out_dict
=
{
"dt_boxes"
:
dt_boxes
,
"image"
:
self
.
raw_im
}
out_dict
=
{
"dt_boxes"
:
dt_boxes
,
"image"
:
self
.
raw_im
}
return
out_dict
,
None
,
""
return
out_dict
,
None
,
""
...
@@ -86,7 +85,7 @@ class RecOp(Op):
...
@@ -86,7 +85,7 @@ class RecOp(Op):
dt_boxes
=
copy
.
deepcopy
(
self
.
dt_list
)
dt_boxes
=
copy
.
deepcopy
(
self
.
dt_list
)
feed_list
=
[]
feed_list
=
[]
img_list
=
[]
img_list
=
[]
max_wh_ratio
=
0
max_wh_ratio
=
320
/
48.
## Many mini-batchs, the type of feed_data is list.
## Many mini-batchs, the type of feed_data is list.
max_batch_size
=
6
# len(dt_boxes)
max_batch_size
=
6
# len(dt_boxes)
...
@@ -150,7 +149,8 @@ class RecOp(Op):
...
@@ -150,7 +149,8 @@ class RecOp(Op):
for
i
in
range
(
dt_num
):
for
i
in
range
(
dt_num
):
text
=
rec_list
[
i
]
text
=
rec_list
[
i
]
dt_box
=
self
.
dt_list
[
i
]
dt_box
=
self
.
dt_list
[
i
]
result_list
.
append
([
text
,
dt_box
.
tolist
()])
if
text
[
1
]
>=
0.5
:
result_list
.
append
([
text
,
dt_box
.
tolist
()])
res
=
{
"result"
:
str
(
result_list
)}
res
=
{
"result"
:
str
(
result_list
)}
return
res
,
None
,
""
return
res
,
None
,
""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录