{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d329ae72-b7ab-47cc-b698-3c62d72233c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import onnxruntime\n",
    "import numpy as np\n",
    "from PIL import Image\n",
    "\n",
    "\n",
    "# 加载ONNX模型  2分\n",
    "ort_session = __________________\n",
    "\n",
    "\n",
    "# 加载图像 2分\n",
    "image = __________________('L')  # 转为灰度图\n",
    "\n",
    "\n",
    "#图像预处理 \n",
    "image = __________________((28, 28))  # 调整大小为MNIST模型的输入尺寸2分\n",
    "image_array = __________________(__________________, dtype=np.float32)  # 转为numpy数组2分\n",
    "image_array = __________________(__________________, axis=0)  # 添加batch维度2分\n",
    "image_array = __________________(__________________, axis=0)  # 添加通道维度2分\n",
    "\n",
    "\n",
    "#返回模型输入列表 2分\n",
    "ort_inputs = {__________________()[0].name: image_array}\n",
    "# 执行预测 2分\n",
    "ort_outs = __________________(None, ort_inputs)\n",
    "\n",
    "\n",
    "# 获取预测结果 2分\n",
    "predicted_class = __________________\n",
    "\n",
    "\n",
    "# 输出预测结果\n",
    "print(f\"Predicted class: {predicted_class}\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
