python - 无法存储numpy.ndarray'对象没有属性 'save'

标签 python arrays python-3.x numpy

我将预测数据存储在一个更大的 NumPy 数组中并将其发送到服务器。我尝试了 Zlib 压缩,但它影响了应用程序性能。

def forward_data(frame,count):
   global m1, m2, model_split_arg
   source = cv2.imdecode(np.fromstring(base64.b64decode(frame), dtype=np.uint8), 1)
   image = img_to_array(source)
   image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))
   preds = m1.predict(preprocess_input(image))
   preds.save()
   buf = io.BytesIO()  
   np.savez_compressed(buf, preds)

错误: preds.save() AttributeError:'numpy.ndarray'对象没有属性'save'

最佳答案

尝试使用

cv2.imwrite(path,img_to_save)

保存

关于python - 无法存储numpy.ndarray'对象没有属性 'save',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65700942/

相关文章:

python-3.x - 将日期时间四舍五入到最接近的小时

java - [Java]数组和集合测试,意外的结果?

c - 生成数组中的随机数并计算平均值、最大值、最小值、总和

python - 扭曲的 : How to print message at the server?

用于在生产/部署之间切换 Urls/变量的 Javascript 构建工具

javascript - 如何在嵌套数组中提取数组的属性

python - python操作数据库报错

python - 将行拆分为多列,仅从行中选择某些值并删除其余值

python - 没有数据库的 Django DRF

python - 单击模态更新按钮后如何显示弹出窗口 "Success"或 "Error"