Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
324f4196
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看板
提交
324f4196
编写于
8月 02, 2021
作者:
H
HexToString
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update doc
上级
ef889659
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
6 deletion
+16
-6
doc/HTTP_SERVICE_CN.md
doc/HTTP_SERVICE_CN.md
+1
-1
java/examples/src/main/java/PaddleServingClientExample.java
java/examples/src/main/java/PaddleServingClientExample.java
+8
-2
java/src/main/java/io/paddle/serving/client/HttpClient.java
java/src/main/java/io/paddle/serving/client/HttpClient.java
+7
-3
未找到文件。
doc/HTTP_SERVICE_CN.md
浏览文件 @
324f4196
...
...
@@ -37,7 +37,7 @@ python3.6 -m paddle_serving_server.serve --model uci_housing_model --thread 10 -
### 客户端使用curl访问
```
shell
curl
-XPOST
http://
127.0.0.1:9393/GeneralModelService/inference
-d
' {"tensor":[{"float_data":[0.0137,-0.1136,0.2553,-0.0692,0.0582,-0.0727,-0.1583,-0.0584,0.6283,0.4919,0.1856,0.0795,-0.0332],"elem_type":1
,"shape":[1,13]}],"fetch_var_names":["price"],"log_id":0}'
curl
-XPOST
http://
0.0.0.0:9393/GeneralModelService/inference
-d
' {"tensor":[{"float_data":[0.0137,-0.1136,0.2553,-0.0692,0.0582,-0.0727,-0.1583,-0.0584,0.6283,0.4919,0.1856,0.0795,-0.0332],"elem_type":1,"name":"x","alias_name":"x"
,"shape":[1,13]}],"fetch_var_names":["price"],"log_id":0}'
```
其中
`127.0.0.1:9393`
为IP和Port,根据您服务端启动的IP和Port自行设定。
...
...
java/examples/src/main/java/PaddleServingClientExample.java
浏览文件 @
324f4196
...
...
@@ -25,7 +25,8 @@ public class PaddleServingClientExample {
List
<
String
>
fetch
=
Arrays
.
asList
(
"price"
);
HttpClient
client
=
new
HttpClient
();
client
.
setIP
(
"172.17.0.2"
);
client
.
setPort
(
"9393"
);
String
result
=
client
.
predict
(
feed_data
,
fetch
,
true
,
0
);
System
.
out
.
println
(
result
);
...
...
@@ -73,6 +74,8 @@ public class PaddleServingClientExample {
}};
List
<
String
>
fetch
=
Arrays
.
asList
(
"save_infer_model/scale_0.tmp_0"
);
HttpClient
client
=
new
HttpClient
();
client
.
setIP
(
"172.17.0.2"
);
client
.
setPort
(
"9393"
);
String
result
=
client
.
predict
(
feed_data
,
fetch
,
true
,
0
);
System
.
out
.
println
(
result
);
return
true
;
...
...
@@ -91,8 +94,9 @@ public class PaddleServingClientExample {
put
(
"segment_ids"
,
Nd4j
.
createFromArray
(
segment_ids
));
}};
List
<
String
>
fetch
=
Arrays
.
asList
(
"pooled_output"
);
HttpClient
client
=
new
HttpClient
();
client
.
setIP
(
"172.17.0.2"
);
client
.
setPort
(
"9393"
);
String
result
=
client
.
predict
(
feed_data
,
fetch
,
true
,
0
);
System
.
out
.
println
(
result
);
return
true
;
...
...
@@ -160,6 +164,8 @@ public class PaddleServingClientExample {
}};
List
<
String
>
fetch
=
Arrays
.
asList
(
"prob"
);
HttpClient
client
=
new
HttpClient
();
client
.
setIP
(
"172.17.0.2"
);
client
.
setPort
(
"9393"
);
String
result
=
client
.
predict
(
feed_data
,
fetch
,
true
,
0
);
System
.
out
.
println
(
result
);
return
true
;
...
...
java/src/main/java/io/paddle/serving/client/HttpClient.java
浏览文件 @
324f4196
...
...
@@ -109,7 +109,7 @@ public class HttpClient {
feedTensorLen_
=
null
;
feedNameToIndex_
=
null
;
httpTimeoutS_
=
200000
;
ip
=
"
127.0.0.1
"
;
ip
=
"
0.0.0.0
"
;
port
=
"9393"
;
serverPort
=
"9393"
;
serviceName
=
"/GeneralModelService/inference"
;
...
...
@@ -151,10 +151,13 @@ public class HttpClient {
public
void
loadClientConfig
(
String
model_config_path
)
{
GeneralModelConfig
.
Builder
model_conf_builder
=
GeneralModelConfig
.
newBuilder
();
try
{
String
model_config_str
=
Files
.
readString
(
Paths
.
get
(
model_config_path
));
byte
[]
data
=
Files
.
readAllBytes
(
Paths
.
get
(
model_config_path
));
String
model_config_str
=
new
String
(
data
,
"utf-8"
);
com
.
google
.
protobuf
.
TextFormat
.
getParser
().
merge
(
model_config_str
,
model_conf_builder
);
}
catch
(
com
.
google
.
protobuf
.
TextFormat
.
ParseException
e
)
{
System
.
out
.
format
(
"Parse client config failed: %s\n"
,
e
.
toString
());
}
catch
(
Exception
e
)
{
System
.
out
.
format
(
"Open client config failed: %s\n"
,
e
.
toString
());
}
GeneralModelConfig
model_conf
=
model_conf_builder
.
build
();
...
...
@@ -202,7 +205,8 @@ public class HttpClient {
String
key_str
=
null
;
String
encrypt_url
=
"http://"
+
this
.
ip
+
":"
+
this
.
port
;
try
{
key_str
=
Files
.
readString
(
Paths
.
get
(
keyFilePath
));
byte
[]
data
=
Files
.
readAllBytes
(
Paths
.
get
(
keyFilePath
));
key_str
=
new
String
(
data
,
"utf-8"
);
}
catch
(
Exception
e
)
{
System
.
out
.
format
(
"Open key file failed: %s\n"
,
e
.
toString
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录