Python 3.x 输出预测图像Tensorflow Lite

Python 3.x 输出预测图像Tensorflow Lite,python-3.x,tensorflow2.0,tensorflow-lite,Python 3.x,Tensorflow2.0,Tensorflow Lite,我正在尝试找出如何从tensorflow模型中保存预测的掩码(输出),该模型已在我的PC上转换为tf.lite模型。关于如何将其可视化或将预测的掩码保存为.png图像的任何提示或想法。我尝试使用tensorflow Lite干涉仪,但没有成功 现在的输出如下: [ 1 512 512 3] [[[[9.7955531e-01 2.0444747e-02] [9.9987805e-01 1.2197520e-04] [9.9978799e-01 2.1196880e-04]

我正在尝试找出如何从tensorflow模型中保存预测的掩码(输出),该模型已在我的PC上转换为tf.lite模型。关于如何将其可视化或将预测的掩码保存为.png图像的任何提示或想法。我尝试使用tensorflow Lite干涉仪,但没有成功

现在的输出如下:

[  1 512 512   3]
[[[[9.7955531e-01 2.0444747e-02]
   [9.9987805e-01 1.2197520e-04]
   [9.9978799e-01 2.1196880e-04]
   .......
   .......
   [9.9997246e-01 2.7536058e-05]
   [9.9997437e-01 2.5645388e-05]
   [1.9125430e-03 9.9808747e-01]]]]
非常感谢您的帮助。 非常感谢

## Load the TFLite model and allocate tensors. 
interpreter = tf.lite.Interpreter(model_path="tflite_model.tflite")
print(interpreter.get_input_details())
print(interpreter.get_output_details())
print(interpreter.get_tensor_details())
interpreter.allocate_tensors()

## Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

## Test the model on input data.
input_shape = input_details[0]['shape']
print(input_shape)

## Use same image as Keras model
input_data = np.array(Xall, dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)

interpreter.invoke()

## The function `get_tensor()` returns a copy of the tensor data.
## Use `tensor()` in order to get a pointer to the tensor.
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
output_data.shape

这取决于模型输出的含义。然后,使用像
cv2
PIL
这样的图像库来绘制遮罩

例如,第一行:

  9.7955531e-01 2.0444747e-02

你需要弄清楚它们对应的是什么。由于信息有限,很难从上下文中猜出来。

谢谢,我对这一点还不熟悉,只是对行的解释让它更清楚了。再次感谢!