Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
d465b2fe
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,发现更多精彩内容 >>
提交
d465b2fe
编写于
2月 05, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add imdb code
上级
b4ae7bad
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
50 addition
and
20 deletion
+50
-20
core/configure/CMakeLists.txt
core/configure/CMakeLists.txt
+8
-6
python/examples/imdb/get_data.sh
python/examples/imdb/get_data.sh
+3
-1
python/examples/imdb/local_train.py
python/examples/imdb/local_train.py
+13
-7
python/examples/imdb/test_client.py
python/examples/imdb/test_client.py
+5
-4
python/examples/imdb/test_client_batch.py
python/examples/imdb/test_client_batch.py
+1
-1
python/examples/imdb/test_client_multithread.py
python/examples/imdb/test_client_multithread.py
+1
-1
python/examples/imdb/test_server.py
python/examples/imdb/test_server.py
+19
-0
未找到文件。
core/configure/CMakeLists.txt
浏览文件 @
d465b2fe
...
...
@@ -29,22 +29,24 @@ FILE(GLOB inc ${CMAKE_CURRENT_BINARY_DIR}/*.pb.h)
install
(
FILES
${
inc
}
DESTINATION
${
PADDLE_SERVING_INSTALL_DIR
}
/include/configure
)
if
(
CLIENT_ONLY
)
py_proto_compile
(
sdk_configure_py_proto SRCS proto/sdk_configure.proto
)
add_custom_target
(
sdk_configure_py_proto_init ALL COMMAND
${
CMAKE_COMMAND
}
-E touch __init__.py
)
add_dependencies
(
sdk_configure_py_proto sdk_configure_py_proto_init
)
add_custom_command
(
TARGET sdk_configure_py_proto POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving/proto
COMMAND cp *.py
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving/proto
COMMENT
"Copy generated python proto into directory paddle_serving/proto."
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving
_client
/proto
COMMAND cp *.py
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving
_client
/proto
COMMENT
"Copy generated python proto into directory paddle_serving
_client
/proto."
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
endif
()
if
(
NOT CLIENT_ONLY
)
py_proto_compile
(
server_config_py_proto SRCS proto/server_configure.proto
)
add_custom_target
(
server_config_py_proto_init ALL COMMAND
${
CMAKE_COMMAND
}
-E touch __init__.py
)
add_dependencies
(
server_config_py_proto server_config_py_proto_init
)
add_custom_command
(
TARGET server_config_py_proto POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving/proto
COMMAND cp *.py
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving/proto
COMMENT
"Copy generated python proto into directory paddle_serving/proto."
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving
_server
/proto
COMMAND cp *.py
${
PADDLE_SERVING_BINARY_DIR
}
/python/paddle_serving
_server
/proto
COMMENT
"Copy generated python proto into directory paddle_serving
_server
/proto."
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINRARY_DIR
}
)
endif
()
python/examples/imdb/get_data.sh
浏览文件 @
d465b2fe
wget https://fleet.bj.bcebos.com/text_classification_data.tar.gz
wget
--no-check-certificate
https://fleet.bj.bcebos.com/text_classification_data.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
python/examples/imdb/local_train.py
浏览文件 @
d465b2fe
...
...
@@ -16,7 +16,6 @@ import sys
import
paddle
import
logging
import
paddle.fluid
as
fluid
import
paddle_serving
as
serving
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logger
=
logging
.
getLogger
(
"fluid"
)
...
...
@@ -42,7 +41,7 @@ if __name__ == "__main__":
dataset
=
fluid
.
DatasetFactory
().
create_dataset
()
filelist
=
[
"train_data/%s"
%
x
for
x
in
os
.
listdir
(
"train_data"
)]
dataset
.
set_use_var
([
data
,
label
])
pipe_command
=
"python imdb_reader.py"
pipe_command
=
"
/home/users/dongdaxiang/paddle_whls/custom_op/paddle_release_home/python/bin/
python imdb_reader.py"
dataset
.
set_pipe_command
(
pipe_command
)
dataset
.
set_batch_size
(
4
)
dataset
.
set_filelist
(
filelist
)
...
...
@@ -57,12 +56,19 @@ if __name__ == "__main__":
epochs
=
30
save_dirname
=
"cnn_model"
import
paddle_serving_client.io
as
serving_io
for
i
in
range
(
epochs
):
exe
.
train_from_dataset
(
program
=
fluid
.
default_main_program
(),
dataset
=
dataset
,
debug
=
False
)
logger
.
info
(
"TRAIN --> pass: {}"
.
format
(
i
))
fluid
.
io
.
save_inference_model
(
"%s/epoch%d.model"
%
(
save_dirname
,
i
),
[
data
.
name
,
label
.
name
],
[
acc
],
exe
)
serving
.
save_model
(
"%s/epoch%d.model"
%
(
save_dirname
,
i
),
"client_config{}"
.
format
(
i
)
,
if
i
==
20
:
serving_io
.
save_model
(
"serving_server_model"
,
"serving_client_conf"
,
{
"words"
:
data
,
"label"
:
label
},
{
"acc"
:
acc
,
"cost"
:
avg_cost
,
"prediction"
:
prediction
})
{
"cost"
:
avg_cost
,
"acc"
:
acc
,
"prediction"
:
prediction
},
fluid
.
default_main_program
())
python/examples/imdb/test_client.py
浏览文件 @
d465b2fe
from
paddle_serving
.serving
_client
import
Client
from
paddle_serving_client
import
Client
import
sys
client
=
Client
()
...
...
@@ -7,10 +7,11 @@ client.connect(["127.0.0.1:9292"])
for
line
in
sys
.
stdin
:
group
=
line
.
strip
().
split
()
words
=
[
int
(
x
)
for
x
in
group
[
1
:
int
(
group
[
0
])]]
words
=
[
int
(
x
)
for
x
in
group
[
1
:
int
(
group
[
0
])
+
1
]]
label
=
[
int
(
group
[
-
1
])]
feed
=
{
"words"
:
words
,
"label"
:
label
}
fetch
=
[
"
acc"
,
"cost
"
,
"prediction"
]
fetch
=
[
"
cost"
,
"acc
"
,
"prediction"
]
fetch_map
=
client
.
predict
(
feed
=
feed
,
fetch
=
fetch
)
print
(
"{} {}"
.
format
(
fetch_map
[
"prediction"
][
1
],
label
[
0
]))
print
(
fetch_map
)
#print("{} {}".format(fetch_map["prediction"][1], label[0]))
python/examples/imdb/test_client_batch.py
浏览文件 @
d465b2fe
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle_serving
.serving
_client
import
Client
from
paddle_serving_client
import
Client
import
sys
import
subprocess
from
multiprocessing
import
Pool
...
...
python/examples/imdb/test_client_multithread.py
浏览文件 @
d465b2fe
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle_serving
import
Client
from
paddle_serving
_client
import
Client
import
sys
import
subprocess
from
multiprocessing
import
Pool
...
...
python/examples/imdb/test_server.py
0 → 100644
浏览文件 @
d465b2fe
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'
)
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
.
load_model_config
(
sys
.
argv
[
1
])
server
.
prepare_server
(
workdir
=
"work_dir1"
,
port
=
9292
,
device
=
"cpu"
)
server
.
run_server
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录