Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
a6fb87a6
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看板
未验证
提交
a6fb87a6
编写于
2月 08, 2021
作者:
T
TeslaZhao
提交者:
GitHub
2月 08, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20 from PaddlePaddle/develop
Develop
上级
7d68f1dc
391135cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
9 deletion
+22
-9
java/README.md
java/README.md
+2
-2
java/README_CN.md
java/README_CN.md
+2
-2
java/examples/src/main/java/PaddleServingClientExample.java
java/examples/src/main/java/PaddleServingClientExample.java
+10
-4
java/src/main/java/io/paddle/serving/client/Client.java
java/src/main/java/io/paddle/serving/client/Client.java
+8
-1
未找到文件。
java/README.md
浏览文件 @
a6fb87a6
...
...
@@ -7,8 +7,8 @@
In order to facilitate users to use java for development, we provide the compiled Serving project to be placed in the java mirror. The way to get the mirror and enter the development environment is
```
docker pull hub.baidubce.com/paddlepaddle/serving:0.4.
0
-java
docker run --rm -dit --name java_serving hub.baidubce.com/paddlepaddle/serving:0.4.
0
-java
docker pull hub.baidubce.com/paddlepaddle/serving:0.4.
1
-java
docker run --rm -dit --name java_serving hub.baidubce.com/paddlepaddle/serving:0.4.
1
-java
docker exec -it java_serving bash
cd Serving/java
```
...
...
java/README_CN.md
浏览文件 @
a6fb87a6
...
...
@@ -7,8 +7,8 @@
为了方便用户使用java进行开发,我们提供了编译好的Serving工程放置在java镜像当中,获取镜像并进入开发环境的方式是
```
docker pull hub.baidubce.com/paddlepaddle/serving:0.4.
0
-java
docker run --rm -dit --name java_serving hub.baidubce.com/paddlepaddle/serving:0.4.
0
-java
docker pull hub.baidubce.com/paddlepaddle/serving:0.4.
1
-java
docker run --rm -dit --name java_serving hub.baidubce.com/paddlepaddle/serving:0.4.
1
-java
docker exec -it java_serving bash
cd Serving/java
```
...
...
java/examples/src/main/java/PaddleServingClientExample.java
浏览文件 @
a6fb87a6
...
...
@@ -16,9 +16,11 @@ public class PaddleServingClientExample {
0.0582f
,
-
0.0727f
,
-
0.1583f
,
-
0.0584f
,
0.6283f
,
0.4919f
,
0.1856f
,
0.0795f
,
-
0.0332f
};
INDArray
npdata
=
Nd4j
.
createFromArray
(
data
);
long
[]
batch_shape
=
{
1
,
13
};
INDArray
batch_npdata
=
npdata
.
reshape
(
batch_shape
);
HashMap
<
String
,
INDArray
>
feed_data
=
new
HashMap
<
String
,
INDArray
>()
{{
put
(
"x"
,
npdata
);
put
(
"x"
,
batch_
npdata
);
}};
List
<
String
>
fetch
=
Arrays
.
asList
(
"price"
);
...
...
@@ -69,12 +71,16 @@ public class PaddleServingClientExample {
// Div(255.0)
INDArray
image
=
RGBimage
.
divi
(
255.0
);
long
[]
batch_shape
=
{
1
,
image
.
shape
()[
0
],
image
.
shape
()[
1
],
image
.
shape
()[
2
]};
INDArray
batch_image
=
image
.
reshape
(
batch_shape
);
INDArray
im_size
=
Nd4j
.
createFromArray
(
new
int
[]{
height
,
width
});
long
[]
batch_size_shape
=
{
1
,
2
};
INDArray
batch_im_size
=
im_size
.
reshape
(
batch_size_shape
);
HashMap
<
String
,
INDArray
>
feed_data
=
new
HashMap
<
String
,
INDArray
>()
{{
put
(
"image"
,
image
);
put
(
"im_size"
,
im_size
);
put
(
"image"
,
batch_
image
);
put
(
"im_size"
,
batch_
im_size
);
}};
List
<
String
>
fetch
=
Arrays
.
asList
(
"save_infer_model/scale_0.tmp_0"
);
...
...
java/src/main/java/io/paddle/serving/client/Client.java
浏览文件 @
a6fb87a6
...
...
@@ -4,6 +4,9 @@ import java.util.*;
import
java.util.function.Function
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.RuntimeMXBean
;
import
java.util.stream.Collectors
;
import
java.util.List
;
import
java.util.ArrayList
;
import
io.grpc.ManagedChannel
;
import
io.grpc.ManagedChannelBuilder
;
...
...
@@ -238,7 +241,11 @@ public class Client {
}
else
{
throw
new
IllegalArgumentException
(
"error tensor value type."
);
}
tensor_builder
.
addAllShape
(
feedShapes_
.
get
(
name
));
long
[]
longArray
=
variable
.
shape
();
int
[]
intArray
=
Arrays
.
stream
(
longArray
).
mapToInt
(
i
->
(
int
)
i
).
toArray
();
List
<
Integer
>
indarrayShapeList
=
Arrays
.
stream
(
intArray
).
boxed
().
collect
(
Collectors
.
toList
());
//tensor_builder.addAllShape(feedShapes_.get(name));
tensor_builder
.
addAllShape
(
indarrayShapeList
);
inst_builder
.
addTensorArray
(
tensor_builder
.
build
());
}
req_builder
.
addInsts
(
inst_builder
.
build
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录