Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
5c4985a0
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看板
提交
5c4985a0
编写于
3月 06, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine imdb benchmark scripts and text_classify_service
上级
4cdf6dd5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
17 addition
and
81 deletion
+17
-81
python/examples/imdb/get_data.sh
python/examples/imdb/get_data.sh
+2
-2
python/examples/imdb/imdb_reader.py
python/examples/imdb/imdb_reader.py
+8
-0
python/examples/imdb/imdb_web_service_demo.sh
python/examples/imdb/imdb_web_service_demo.sh
+1
-1
python/examples/imdb/local_train.py
python/examples/imdb/local_train.py
+5
-3
python/examples/imdb/test_gpu_server.py
python/examples/imdb/test_gpu_server.py
+0
-35
python/examples/imdb/test_server.py
python/examples/imdb/test_server.py
+0
-38
python/examples/imdb/text_classify_service.py
python/examples/imdb/text_classify_service.py
+1
-2
未找到文件。
python/examples/imdb/get_data.sh
浏览文件 @
5c4985a0
wget
--no-check-certificate
https://fleet.bj.bcebos.com/text_classification_data.tar.gz
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz
tar
-zxvf
text_classification_data.tar.gz
#wget --no-check-certificate https://paddle-serving.bj.bcebos.com/imdb-demo%2Fimdb.tar.gz
#tar -xzf imdb-demo%2Fimdb.tar.gz
tar
-zxvf
imdb_model.tar.gz
python/examples/imdb/imdb_reader.py
浏览文件 @
5c4985a0
...
...
@@ -30,6 +30,14 @@ class IMDBDataset(dg.MultiSlotDataGenerator):
self
.
_pattern
=
re
.
compile
(
r
'(;|,|\.|\?|!|\s|\(|\))'
)
self
.
return_value
=
(
"words"
,
[
1
,
2
,
3
,
4
,
5
,
6
]),
(
"label"
,
[
0
])
def
get_words_only
(
self
,
line
):
sent
=
line
.
lower
().
replace
(
"<br />"
,
" "
).
strip
()
words
=
[
x
for
x
in
self
.
_pattern
.
split
(
sent
)
if
x
and
x
!=
" "
]
feas
=
[
self
.
_vocab
[
x
]
if
x
in
self
.
_vocab
else
self
.
_unk_id
for
x
in
words
]
return
feas
def
get_words_and_label
(
self
,
line
):
send
=
'|'
.
join
(
line
.
split
(
'|'
)[:
-
1
]).
lower
().
replace
(
"<br />"
,
" "
).
strip
()
...
...
python/examples/imdb/imdb_web_service_demo.sh
浏览文件 @
5c4985a0
wget https://paddle-serving.bj.bcebos.com/imdb-demo
%2F
imdb_service.tar.gz
wget https://paddle-serving.bj.bcebos.com/imdb-demo
/
imdb_service.tar.gz
tar
-xzf
imdb_service.tar.gz
wget
--no-check-certificate
https://fleet.bj.bcebos.com/text_classification_data.tar.gz
tar
-zxvf
text_classification_data.tar.gz
...
...
python/examples/imdb/local_train.py
浏览文件 @
5c4985a0
...
...
@@ -49,8 +49,9 @@ if __name__ == "__main__":
dataset
.
set_batch_size
(
128
)
dataset
.
set_filelist
(
filelist
)
dataset
.
set_thread
(
10
)
from
nets
import
bow_net
avg_cost
,
acc
,
prediction
=
bow_net
(
data
,
label
,
dict_dim
)
from
nets
import
lstm_net
model_name
=
"imdb_lstm"
avg_cost
,
acc
,
prediction
=
lstm_net
(
data
,
label
,
dict_dim
)
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.01
)
optimizer
.
minimize
(
avg_cost
)
...
...
@@ -65,6 +66,7 @@ if __name__ == "__main__":
program
=
fluid
.
default_main_program
(),
dataset
=
dataset
,
debug
=
False
)
logger
.
info
(
"TRAIN --> pass: {}"
.
format
(
i
))
if
i
==
5
:
serving_io
.
save_model
(
"imdb_model"
,
"imdb_client_conf"
,
serving_io
.
save_model
(
"{}_model"
.
format
(
model_name
),
"{}_client_conf"
.
format
(
model_name
),
{
"words"
:
data
},
{
"prediction"
:
prediction
},
fluid
.
default_main_program
())
python/examples/imdb/test_gpu_server.py
已删除
100644 → 0
浏览文件 @
4cdf6dd5
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
sys
from
paddle_serving_server_gpu
import
OpMaker
from
paddle_serving_server_gpu
import
OpSeqMaker
from
paddle_serving_server_gpu
import
Server
op_maker
=
OpMaker
()
read_op
=
op_maker
.
create
(
'general_reader'
)
general_infer_op
=
op_maker
.
create
(
'general_infer'
)
op_seq_maker
=
OpSeqMaker
()
op_seq_maker
.
add_op
(
read_op
)
op_seq_maker
.
add_op
(
general_infer_op
)
server
=
Server
()
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
set_num_threads
(
12
)
server
.
load_model_config
(
sys
.
argv
[
1
])
port
=
int
(
sys
.
argv
[
2
])
server
.
prepare_server
(
workdir
=
"work_dir1"
,
port
=
port
,
device
=
"gpu"
)
server
.
run_server
()
python/examples/imdb/test_server.py
已删除
100644 → 0
浏览文件 @
4cdf6dd5
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
sys
from
paddle_serving_server
import
OpMaker
from
paddle_serving_server
import
OpSeqMaker
from
paddle_serving_server
import
Server
op_maker
=
OpMaker
()
read_op
=
op_maker
.
create
(
'general_reader'
)
general_infer_op
=
op_maker
.
create
(
'general_infer'
)
general_response_op
=
op_maker
.
create
(
'general_response'
)
op_seq_maker
=
OpSeqMaker
()
op_seq_maker
.
add_op
(
read_op
)
op_seq_maker
.
add_op
(
general_infer_op
)
op_seq_maker
.
add_op
(
general_response_op
)
server
=
Server
()
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
set_num_threads
(
4
)
server
.
load_model_config
(
sys
.
argv
[
1
])
port
=
int
(
sys
.
argv
[
2
])
server
.
prepare_server
(
workdir
=
"work_dir1"
,
port
=
port
,
device
=
"cpu"
)
server
.
run_server
()
python/examples/imdb/text_classify_service.py
浏览文件 @
5c4985a0
...
...
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!flask/bin/python
from
paddle_serving_server.web_service
import
WebService
from
imdb_reader
import
IMDBDataset
import
sys
...
...
@@ -27,7 +26,7 @@ class IMDBService(WebService):
if
"words"
not
in
feed
:
exit
(
-
1
)
res_feed
=
{}
res_feed
[
"words"
]
=
self
.
dataset
.
get_words_
and_label
(
feed
[
"words"
])[
0
]
res_feed
[
"words"
]
=
self
.
dataset
.
get_words_
only
(
feed
[
"words"
])[
0
]
return
res_feed
,
fetch
imdb_service
=
IMDBService
(
name
=
"imdb"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录