我将预测数据存储在一个更大的 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/