Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
d6901933
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
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看板
提交
d6901933
编写于
8月 30, 2021
作者:
J
Jiawei Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix web service config
上级
ec6fa1ad
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
4 deletion
+53
-4
python/examples/pipeline/ocr/web_service.py
python/examples/pipeline/ocr/web_service.py
+51
-2
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+2
-2
未找到文件。
python/examples/pipeline/ocr/web_service.py
浏览文件 @
d6901933
...
...
@@ -22,7 +22,55 @@ from paddle_serving_app.reader import Div, Normalize, Transpose
from
paddle_serving_app.reader
import
DBPostProcess
,
FilterBoxes
,
GetRotateCropImage
,
SortedBoxes
_LOGGER
=
logging
.
getLogger
()
import
yaml
from
argparse
import
ArgumentParser
,
RawDescriptionHelpFormatter
class
ArgsParser
(
ArgumentParser
):
def
__init__
(
self
):
super
(
ArgsParser
,
self
).
__init__
(
formatter_class
=
RawDescriptionHelpFormatter
)
self
.
add_argument
(
"-c"
,
"--config"
,
help
=
"configuration file to use"
)
self
.
add_argument
(
"-o"
,
"--opt"
,
nargs
=
'+'
,
help
=
"set configuration options"
)
def
parse_args
(
self
,
argv
=
None
):
args
=
super
(
ArgsParser
,
self
).
parse_args
(
argv
)
assert
args
.
config
is
not
None
,
\
"Please specify --config=configure_file_path."
args
.
conf_dict
=
self
.
_parse_opt
(
args
.
opt
,
args
.
config
)
return
args
def
_parse_helper
(
self
,
v
):
if
v
.
isnumeric
():
if
"."
in
v
:
v
=
float
(
v
)
else
:
v
=
int
(
v
)
elif
v
==
"True"
or
v
==
"False"
:
v
=
(
v
==
"True"
)
return
v
def
_parse_opt
(
self
,
opts
,
conf_path
):
f
=
open
(
conf_path
)
config
=
yaml
.
load
(
f
,
Loader
=
yaml
.
Loader
)
if
not
opts
:
return
config
for
s
in
opts
:
s
=
s
.
strip
()
k
,
v
=
s
.
split
(
'='
)
v
=
self
.
_parse_helper
(
v
)
print
(
k
,
v
,
type
(
v
))
cur
=
config
parent
=
cur
for
kk
in
k
.
split
(
"."
):
if
kk
not
in
cur
:
cur
[
kk
]
=
{}
parent
=
cur
cur
=
cur
[
kk
]
else
:
parent
=
cur
cur
=
cur
[
kk
]
parent
[
k
.
split
(
"."
)[
-
1
]]
=
v
return
config
class
DetOp
(
Op
):
def
init_op
(
self
):
...
...
@@ -176,5 +224,6 @@ class OcrService(WebService):
ocr_service
=
OcrService
(
name
=
"ocr"
)
ocr_service
.
prepare_pipeline_config
(
"config.yml"
)
FLAGS
=
ArgsParser
().
parse_args
()
ocr_service
.
prepare_pipeline_config
(
yml_dict
=
FLAGS
.
conf_dict
)
ocr_service
.
run_service
()
python/paddle_serving_server/web_service.py
浏览文件 @
d6901933
...
...
@@ -50,7 +50,7 @@ class WebService(object):
def
get_pipeline_response
(
self
,
read_op
):
return
None
def
prepare_pipeline_config
(
self
,
y
aml_fil
e
):
def
prepare_pipeline_config
(
self
,
y
ml_file
=
None
,
yml_dict
=
Non
e
):
# build dag
read_op
=
pipeline
.
RequestOp
()
last_op
=
self
.
get_pipeline_response
(
read_op
)
...
...
@@ -60,7 +60,7 @@ class WebService(object):
"`get_pipeline_response`."
)
response_op
=
pipeline
.
ResponseOp
(
input_ops
=
[
last_op
])
self
.
_server
.
set_response_op
(
response_op
)
self
.
_server
.
prepare_server
(
y
aml_file
)
self
.
_server
.
prepare_server
(
y
ml_file
=
yml_file
,
yml_dict
=
yml_dict
)
def
run_service
(
self
):
self
.
_server
.
run_server
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录