Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
d0d84ae9
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d0d84ae9
编写于
11月 04, 2019
作者:
S
shenyuhan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.add 'print predict error',2.modify simnet_bow handle func
上级
03efd82b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
10 deletion
+29
-10
paddlehub/commands/serving.py
paddlehub/commands/serving.py
+2
-4
paddlehub/serving/app.py
paddlehub/serving/app.py
+1
-1
paddlehub/serving/app_single.py
paddlehub/serving/app_single.py
+25
-4
paddlehub/serving/templates/serving_config.json
paddlehub/serving/templates/serving_config.json
+1
-1
未找到文件。
paddlehub/commands/serving.py
浏览文件 @
d0d84ae9
...
...
@@ -18,8 +18,6 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
import
subprocess
import
shlex
import
os
import
socket
import
json
...
...
@@ -50,7 +48,7 @@ class ServingCommand(BaseCommand):
"--use_multiprocess"
,
action
=
"store_true"
,
default
=
False
)
self
.
parser
.
add_argument
(
"--modules"
,
"-m"
,
nargs
=
"+"
)
self
.
parser
.
add_argument
(
"--config"
,
"-c"
,
nargs
=
"+"
)
self
.
parser
.
add_argument
(
"--port"
,
"-p"
,
nargs
=
"+"
,
default
=
[
88
88
])
self
.
parser
.
add_argument
(
"--port"
,
"-p"
,
nargs
=
"+"
,
default
=
[
88
66
])
@
staticmethod
def
port_is_open
(
ip
,
port
):
...
...
@@ -106,7 +104,7 @@ class ServingCommand(BaseCommand):
with
open
(
config_file
,
"r"
)
as
fp
:
configs
=
json
.
load
(
fp
)
use_gpu
=
configs
.
get
(
"use_gpu"
,
False
)
port
=
configs
.
get
(
"port"
,
88
88
)
port
=
configs
.
get
(
"port"
,
88
66
)
if
ServingCommand
.
port_is_open
(
"127.0.0.1"
,
port
)
is
True
:
print
(
"Port %s is occupied, please change it."
%
(
port
))
return
False
...
...
paddlehub/serving/app.py
浏览文件 @
d0d84ae9
...
...
@@ -337,7 +337,7 @@ def config_with_file(configs):
queue_name_list
.
append
(
item
[
"module"
])
def
run
(
is_use_gpu
=
False
,
configs
=
None
,
port
=
88
88
,
timeout
=
60
):
def
run
(
is_use_gpu
=
False
,
configs
=
None
,
port
=
88
66
,
timeout
=
60
):
global
use_gpu
,
time_out
time_out
=
timeout
use_gpu
=
is_use_gpu
...
...
paddlehub/serving/app_single.py
浏览文件 @
d0d84ae9
...
...
@@ -28,10 +28,12 @@ def predict_sentiment_analysis(module, input_text, extra=None):
method_name
=
module
.
desc
.
attr
.
map
.
data
[
'default_signature'
].
s
predict_method
=
getattr
(
module
,
method_name
)
try
:
data
=
eval
(
input_text
[
0
])
data
.
update
(
eval
(
input_text
[
1
])
)
data
=
input_text
[
0
]
data
.
update
(
input_text
[
1
]
)
results
=
predict_method
(
data
=
data
,
use_gpu
=
use_gpu
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
return
results
...
...
@@ -44,6 +46,8 @@ def predict_pretrained_model(module, input_text, extra=None):
data
=
{
"text"
:
input_text
}
results
=
predict_method
(
data
=
data
,
use_gpu
=
use_gpu
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
return
results
...
...
@@ -60,7 +64,11 @@ def predict_lexical_analysis(module, input_text, extra=[]):
user_dict
=
extra
[
0
]
results
=
predict_method
(
data
=
data
,
user_dict
=
user_dict
,
use_gpu
=
use_gpu
)
for
path
in
extra
:
os
.
remove
(
path
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
return
results
...
...
@@ -73,6 +81,8 @@ def predict_classification(module, input_img):
input_img
=
{
"image"
:
input_img
}
results
=
predict_method
(
data
=
input_img
,
use_gpu
=
use_gpu
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
return
results
...
...
@@ -87,6 +97,8 @@ def predict_gan(module, input_img, extra={}):
input_img
=
{
"image"
:
input_img
}
results
=
predict_method
(
data
=
input_img
,
use_gpu
=
use_gpu
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
base64_list
=
[]
results_pack
=
[]
...
...
@@ -118,6 +130,8 @@ def predict_object_detection(module, input_img):
input_img
=
{
"image"
:
input_img
}
results
=
predict_method
(
data
=
input_img
,
use_gpu
=
use_gpu
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
base64_list
=
[]
results_pack
=
[]
...
...
@@ -147,6 +161,8 @@ def predict_semantic_segmentation(module, input_img):
input_img
=
{
"image"
:
input_img
}
results
=
predict_method
(
data
=
input_img
,
use_gpu
=
use_gpu
)
except
Exception
as
err
:
curr
=
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
,
time
.
localtime
(
time
.
time
()))
print
(
curr
,
" - "
,
err
)
return
{
"result"
:
"Please check data format!"
}
base64_list
=
[]
results_pack
=
[]
...
...
@@ -235,7 +251,12 @@ def create_app():
def
predict_text
(
module_name
):
req_id
=
request
.
data
.
get
(
"id"
)
global
use_gpu
data
=
request
.
form
.
getlist
(
"input_text"
)
if
module_name
==
"simnet_bow"
:
text_1
=
request
.
form
.
getlist
(
"text_1"
)
text_2
=
request
.
form
.
getlist
(
"text_2"
)
data
=
[{
"text_1"
:
text_1
},
{
"text_2"
:
text_2
}]
else
:
data
=
request
.
form
.
getlist
(
"text"
)
file
=
request
.
files
.
getlist
(
"user_dict"
)
module
=
TextModelService
.
get_module
(
module_name
)
module_type
=
module
.
type
.
split
(
"/"
)[
-
1
].
replace
(
"-"
,
"_"
).
lower
()
...
...
@@ -263,7 +284,7 @@ def config_with_file(configs):
nlp_module
.
append
(
item
[
"module"
])
def
run
(
is_use_gpu
=
False
,
configs
=
None
,
port
=
88
88
,
timeout
=
60
):
def
run
(
is_use_gpu
=
False
,
configs
=
None
,
port
=
88
66
,
timeout
=
60
):
global
use_gpu
,
time_out
time_out
=
timeout
use_gpu
=
is_use_gpu
...
...
paddlehub/serving/templates/serving_config.json
浏览文件 @
d0d84ae9
...
...
@@ -26,5 +26,5 @@
}
],
"use_gpu"
:
false
,
"port"
:
88
88
"port"
:
88
66
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录