Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
c0bb5c5d
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
185
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c0bb5c5d
编写于
7月 11, 2020
作者:
W
wangjiawei04
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix codestyle
上级
95af9ad5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
9 deletion
+21
-9
python/examples/ocr/ocr_web_server.py
python/examples/ocr/ocr_web_server.py
+2
-1
python/paddle_serving_app/local_predict.py
python/paddle_serving_app/local_predict.py
+2
-1
python/paddle_serving_app/reader/image_reader.py
python/paddle_serving_app/reader/image_reader.py
+5
-1
python/paddle_serving_app/reader/ocr_reader.py
python/paddle_serving_app/reader/ocr_reader.py
+10
-5
python/paddle_serving_server_gpu/web_service.py
python/paddle_serving_server_gpu/web_service.py
+2
-1
未找到文件。
python/examples/ocr/ocr_web_server.py
浏览文件 @
c0bb5c5d
...
...
@@ -27,6 +27,7 @@ import time
import
re
import
base64
class
OCRService
(
WebService
):
def
init_det_client
(
self
,
det_port
,
det_client_config
):
self
.
det_preprocess
=
Sequential
([
...
...
@@ -46,7 +47,7 @@ class OCRService(WebService):
ori_h
,
ori_w
,
_
=
im
.
shape
det_img
=
self
.
det_preprocess
(
im
)
det_out
=
self
.
det_client
.
predict
(
feed
=
{
"image"
:
det_img
},
fetch
=
[
"concat_1.tmp_0"
])
feed
=
{
"image"
:
det_img
},
fetch
=
[
"concat_1.tmp_0"
])
_
,
new_h
,
new_w
=
det_img
.
shape
filter_func
=
FilterBoxes
(
10
,
10
)
post_func
=
DBPostProcess
({
...
...
python/paddle_serving_app/local_predict.py
浏览文件 @
c0bb5c5d
...
...
@@ -130,5 +130,6 @@ class Debugger(object):
fetch_map
[
name
]
=
outputs
[
self
.
fetch_names_to_idx_
[
name
]].
as_ndarray
()
if
len
(
outputs
[
self
.
fetch_names_to_idx_
[
name
]].
lod
)
>
0
:
fetch_map
[
name
+
".lod"
]
=
outputs
[
self
.
fetch_names_to_idx_
[
name
]].
lod
[
0
]
fetch_map
[
name
+
".lod"
]
=
outputs
[
self
.
fetch_names_to_idx_
[
name
]].
lod
[
0
]
return
fetch_map
python/paddle_serving_app/reader/image_reader.py
浏览文件 @
c0bb5c5d
...
...
@@ -781,10 +781,12 @@ class Transpose(object):
"({})"
.
format
(
self
.
transpose_target
)
return
format_string
class
SortedBoxes
(
object
):
"""
Sorted bounding boxes from Detection
"""
def
__init__
(
self
):
pass
...
...
@@ -798,12 +800,14 @@ class SortedBoxes(object):
tmp
=
_boxes
[
i
]
_boxes
[
i
]
=
_boxes
[
i
+
1
]
_boxes
[
i
+
1
]
=
tmp
return
_boxes
return
_boxes
class
GetRotateCropImage
(
object
):
"""
Rotate and Crop image from OCR Det output
"""
def
__init__
(
self
):
pass
...
...
python/paddle_serving_app/reader/ocr_reader.py
浏览文件 @
c0bb5c5d
...
...
@@ -120,7 +120,12 @@ class CharacterOps(object):
class
OCRReader
(
object
):
def
__init__
(
self
,
algorithm
=
"CRNN"
,
image_shape
=
[
3
,
32
,
320
],
char_type
=
"ch"
,
batch_num
=
1
,
char_dict_path
=
"./ppocr_keys_v1.txt"
):
def
__init__
(
self
,
algorithm
=
"CRNN"
,
image_shape
=
[
3
,
32
,
320
],
char_type
=
"ch"
,
batch_num
=
1
,
char_dict_path
=
"./ppocr_keys_v1.txt"
):
self
.
rec_image_shape
=
image_shape
self
.
character_type
=
char_type
self
.
rec_batch_num
=
batch_num
...
...
@@ -129,7 +134,7 @@ class OCRReader(object):
char_ops_params
[
"character_dict_path"
]
=
char_dict_path
char_ops_params
[
'loss_type'
]
=
'ctc'
self
.
char_ops
=
CharacterOps
(
char_ops_params
)
def
resize_norm_img
(
self
,
img
,
max_wh_ratio
):
imgC
,
imgH
,
imgW
=
self
.
rec_image_shape
if
self
.
character_type
==
"ch"
:
...
...
@@ -151,7 +156,6 @@ class OCRReader(object):
padding_im
[:,
:,
0
:
resized_w
]
=
resized_image
return
padding_im
def
preprocess
(
self
,
img_list
):
img_num
=
len
(
img_list
)
norm_img_batch
=
[]
...
...
@@ -180,14 +184,15 @@ class OCRReader(object):
end
=
rec_idx_lod
[
rno
+
1
]
if
isinstance
(
rec_idx_batch
,
list
):
rec_idx_tmp
=
[
x
[
0
]
for
x
in
rec_idx_batch
[
beg
:
end
]]
else
:
#nd array
else
:
#nd array
rec_idx_tmp
=
rec_idx_batch
[
beg
:
end
,
0
]
preds_text
=
self
.
char_ops
.
decode
(
rec_idx_tmp
)
if
with_score
:
beg
=
predict_lod
[
rno
]
end
=
predict_lod
[
rno
+
1
]
if
isinstance
(
outputs
[
"softmax_0.tmp_0"
],
list
):
outputs
[
"softmax_0.tmp_0"
]
=
np
.
array
(
outputs
[
"softmax_0.tmp_0"
]).
astype
(
np
.
float32
)
outputs
[
"softmax_0.tmp_0"
]
=
np
.
array
(
outputs
[
"softmax_0.tmp_0"
]).
astype
(
np
.
float32
)
probs
=
outputs
[
"softmax_0.tmp_0"
][
beg
:
end
,
:]
ind
=
np
.
argmax
(
probs
,
axis
=
1
)
blank
=
probs
.
shape
[
1
]
...
...
python/paddle_serving_server_gpu/web_service.py
浏览文件 @
c0bb5c5d
...
...
@@ -189,7 +189,8 @@ class WebService(object):
def
_launch_local_predictor
(
self
,
gpu
):
from
paddle_serving_app.local_predict
import
Debugger
self
.
client
=
Debugger
()
self
.
client
.
load_model_config
(
"{}"
.
format
(
self
.
model_config
),
gpu
=
gpu
,
profile
=
False
)
self
.
client
.
load_model_config
(
"{}"
.
format
(
self
.
model_config
),
gpu
=
gpu
,
profile
=
False
)
def
run_web_service
(
self
):
self
.
app_instance
.
run
(
host
=
"0.0.0.0"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录