如何将 ndarray 响应从 Flask 服务器发送到 python 客户端? [英] How to send ndarray response from flask server to python client?
本文介绍了如何将 ndarray 响应从 Flask 服务器发送到 python 客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将形状为 (1536,1536,3) 的 ndarray (predictionsIm) 从 Flask 服务器发送到 python 客户端.我阅读了将predictionsIm(ndarray)转换为list然后返回json,所以我做了如下:
I am trying to send ndarray (predictionsIm) of shape (1536,1536,3) from flask server to the python client. I read around for converting predictionsIm (ndarray) to list and then return the json, so I did as below:
return {'predictions' : predictionsIm.tolist()}
但我不知道如何在客户端幻灯片上处理它,有人可以帮忙吗?
but I don't know how to handle it on client slide, can someone help in this approach?
或建议更好的方法?
以下是我的 request.py:
Following is my request.py:
import requests
sample_input = "/mnt/d/work/MASKRCNN/data_example/img0001.png"
resp = requests.post("http://localhost:5000/predict",
files={"file": open(sample_input,'rb')})
print(resp.content)
推荐答案
我想你忘记了 json 步骤
I think you forgot the json step
return jsonify({'predictions' : predictionsIm.tolist()})
这篇关于如何将 ndarray 响应从 Flask 服务器发送到 python 客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文