3.2.2 MNIST手写数字识别

请根据题目要求,在下方空白处填入正确的代码(点击 💡 按钮查看提示)

代码填空
import onnxruntime
import numpy as np
from PIL import Image
# 加载ONNX模型  2分
ort_session = 
# 加载图像 2分
image = ('L')  # 转为灰度图
#图像预处理 
image = ((28, 28))  # 调整大小为MNIST模型的输入尺寸2分
image_array = (, dtype=np.float32)  # 转为numpy数组2分
image_array = (, axis=0)  # 添加batch维度2分
image_array = (, axis=0)  # 添加通道维度2分
#返回模型输入列表 2分
ort_inputs = {()[0].name: image_array}
# 执行预测 2分
ort_outs = (None, ort_inputs)
# 获取预测结果 2分
predicted_class = 
# 输出预测结果
print(f"Predicted class: {predicted_class}")
提示: