【问题标题】:How to send ndarray response from flask server to python client? [duplicate]如何将 ndarray 响应从烧瓶服务器发送到 python 客户端? [复制]
【发布时间】:2019-10-17 13:08:06
【问题描述】:

我正在尝试将形状为 (1536,1536,3) 的 ndarray (predictionsIm) 从烧瓶服务器发送到 python 客户端。 我阅读了将 predictionsIm (ndarray) 转换为列表然后返回 json,所以我做了如下:

return {'predictions' : predictionsIm.tolist()}

但我不知道如何在客户端幻灯片上处理它,有人可以帮忙吗?

或建议更好的方法?

以下是我的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 flask numpy-ndarray


    【解决方案1】:

    我想你忘记了 json 步骤

    return jsonify({'predictions' : predictionsIm.tolist()})
    

    【讨论】:

      猜你喜欢
      • 2017-12-21
      • 2017-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      • 2013-05-23
      • 2019-11-23
      相关资源
      最近更新 更多