Serving icon indicating copy to clipboard operation
Serving copied to clipboard

java调用远端预测模型,返回的一堆字符串我该如何进一步处理,如何转成图片

Open rubyangxg opened this issue 4 years ago • 4 comments

PaddleServingClientExample.java 我模仿了例子中的yolov4方法,预测一张图片, Client client = new Client(); client.setIP("127.0.0.1"); client.setPort("9292"); client.loadClientConfig(model_config_path); String result = client.predict(feed_data, fetch, true, 0); System.out.println(result); 我如何处理这里的result,目前我得到的是这样的数据,我如何转换成图片? outputs { tensor { int64_data: 0 int64_data: 0 int64_data: 0 int64_data: 0 int64_data: 0 ...... shape: 1 shape: 275 shape: 170 name: "depthwise_conv2d_11.tmp_0" alias_name: "argmax_0.tmp_0" } engine_name: "general_infer_0" } profile_time: 1645339861250398 profile_time: 1645339861346107 我看到有python的demo可以实现 img = seq(args.image_path) fetch_map = client.predict( feed={"x": img}, fetch=["argmax_0.tmp_0"])

result = fetch_map["argmax_0.tmp_0"]
color_img = get_pseudo_color_map(result[0])
color_img.save("./result.png")
print("The segmentation image is saved in ./result.png")

如果换成java,如何保存图片,能否把example代码补全

rubyangxg avatar Feb 20 '22 07:02 rubyangxg

Message that will be displayed on users' first issue

github-actions[bot] avatar Feb 20 '22 07:02 github-actions[bot]

示例为了方便演示,统一将结果转换为字符串形式打印输出。 如果需要自行后处理,可以直接去Java的Client 类中,自行修改输出即可。

HexToString avatar Feb 22 '22 06:02 HexToString

PaddleServingClientExample.java 我模仿了例子中的yolov4方法,预测一张图片, Client client = new Client(); client.setIP("127.0.0.1"); client.setPort("9292"); client.loadClientConfig(model_config_path); String result = client.predict(feed_data, fetch, true, 0); System.out.println(result); 我如何处理这里的result,目前我得到的是这样的数据,我如何转换成图片? outputs { tensor { int64_data: 0 int64_data: 0 int64_data: 0 int64_data: 0 int64_data: 0 ...... shape: 1 shape: 275 shape: 170 name: "depthwise_conv2d_11.tmp_0" alias_name: "argmax_0.tmp_0" } engine_name: "general_infer_0" } profile_time: 1645339861250398 profile_time: 1645339861346107 我看到有python的demo可以实现 img = seq(args.image_path) fetch_map = client.predict( feed={"x": img}, fetch=["argmax_0.tmp_0"])

result = fetch_map["argmax_0.tmp_0"]
color_img = get_pseudo_color_map(result[0])
color_img.save("./result.png")
print("The segmentation image is saved in ./result.png")

如果换成java,如何保存图片,能否把example代码补全

Hi, can you share your code? I can not succeed. Thank you very much.

lichengzhang19 avatar Mar 26 '22 09:03 lichengzhang19

这个问题解决了吗,一堆字符串怎么解析?

shiyun123456789 avatar Feb 16 '23 09:02 shiyun123456789