{
  "schemaVersion": 1,
  "id": "3.2.4",
  "title": "花朵智能识别系统交互流程设计",
  "durationMinutes": 20,
  "category": "代码实现与交互设计",
  "scenario": "花朵智能识别系统在现代城市绿化管理中起着越来越重要的作用，其利用先进的计算机视觉技术，如花朵检测与识别，实现了对花朵种类的实时监控与管理。本系统要求开发一个基于已训练模型的花朵检测与分类系统，能够准确识别出不同类别的花朵。\n\nAI模型说明：提供的模型“flower-detection.onnx”是使用 Pytorch 框架和基于深度卷积神经网络训练得到的，专门用于进行花朵识别。对应的标签文件为“labels.txt”。 该模型的使用交互流程为：\n\n1)加载模型“flower-detection.onnx”和加载类别标签“labels.txt”；\n\n2)加载一张本地花朵图片“flower_test.png”，并预处理图像；\n\n3)使用flower-detection模型对花朵图片进行识别；\n\n4)输出花朵的预测类型和识别的准确率。\n\n你作为一名人工智能训练师，请完成以下工作任务：\n\n（1）补全该模型的使用交互流程对应的Python代码（3.2.4.ipynb），实现本地测试图片“flower _test.png”的识别，将其识别结果截图保存为jpg格式文件，命名为3.2.4-1.jpg。\n\n（2）在上面的使用交互流程基础上，给出在花朵智能识别系统中使用“flower-detection.onnx”模型的一种人机交互的最优流程，将其保存为docx文件，命名为3.2.4.docx。",
  "skillRequirements": "（1）能够确保模型在单一场景下稳定运行；\n\n（2）能通过分析，设计单一场景下人工和智能交互的最优流程。",
  "qualityIndicators": "（1）模型运行稳定，使用正常；\n\n（2）单一场景下人工和智能交互的最优流程切实可行。",
  "tasks": [
    {
      "id": "code-fill",
      "type": "code-fill",
      "title": "补全代码任务",
      "instructions": "依据公开题面和附件补全代码空位；仅检查完成度与提交格式，不公开标准内容。",
      "codeBlocks": [
        "import onnxruntime as ort\nimport numpy as np\nimport scipy.special\nfrom PIL import Image\n\n\n# 预处理图像\ndef preprocess_image(image, resize_size=256, crop_size=224, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]):\n    image = image.resize((resize_size, resize_size), Image.BILINEAR)\n    w, h = image.size\n    left = (w - crop_size) / 2\n    top = (h - crop_size) / 2\n    image = image.crop((left, top, left + crop_size, top + crop_size))\n    image = np.array(image).astype(np.float32)\n    image = image / 255.0\n    image = (image - mean) / std\n    image = np.transpose(image, (2, 0, 1))\n    image = image.reshape((1,) + image.shape)\n    return image\n\n\n# 加载模型  2分\nsession = _________________\n\n\n# 加载类别标签 2分\nwith _________________ as f:\n    labels = [line.strip() for line in f.readlines()]\n\n\n# 获取模型输入和输出的名称\ninput_name = session.get_inputs()[0].name\noutput_name = session.get_outputs()[0].name\n\n\n# 加载图片  2分\nimage = _________________('RGB')\n\n\n# 预处理图片  2分\nprocessed_image = _________________\n\n\n# 确保输入数据是 float32 类型\nprocessed_image = processed_image.astype(np.float32)\n\n\n# 进行图片识别  2分\noutput = _________________([output_name], {input_name: processed_image})[0]\n\n\n# 应用 softmax 函数获取识别分类后的准确率  2分\naccuracy = _________________(output, axis=-1)\n\n\n# 获取预测的类别索引\npredicted_idx =  __________\n\n\n# 获取预测的准确值（转换为百分比）\nprob_percentage =  __________\n\n\n# 获取预测的类别标签\npredicted_label = __________\n\n\n# 输出预测结果，包含百分比形式的概率\nprint(f\"Predicted class: {predicted_label}, Accuracy: {prob_percentage:.2f}%\")\n"
      ],
      "blanks": [
        {
          "id": "blank-1",
          "block": 1,
          "placeholder": "_________________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-2",
          "block": 1,
          "placeholder": "_________________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-3",
          "block": 1,
          "placeholder": "_________________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-4",
          "block": 1,
          "placeholder": "_________________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-5",
          "block": 1,
          "placeholder": "_________________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-6",
          "block": 1,
          "placeholder": "_________________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-7",
          "block": 1,
          "placeholder": "__________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-8",
          "block": 1,
          "placeholder": "__________",
          "gradingMode": "completion-and-format-only"
        },
        {
          "id": "blank-9",
          "block": 1,
          "placeholder": "__________",
          "gradingMode": "completion-and-format-only"
        }
      ]
    },
    {
      "id": "3-2-response",
      "type": "rubric-response",
      "title": "交互方案设计",
      "instructions": "说明代码功能对应的人机交互流程。",
      "sections": [
        {
          "id": "response",
          "label": "作答内容"
        }
      ],
      "rubric": [
        {
          "id": "criterion-1",
          "label": "输入与格式校验清晰",
          "weight": 25
        },
        {
          "id": "criterion-2",
          "label": "执行进度和状态反馈完整",
          "weight": 25
        },
        {
          "id": "criterion-3",
          "label": "结果展示可理解",
          "weight": 25
        },
        {
          "id": "criterion-4",
          "label": "包含异常处理与人工确认",
          "weight": 25
        }
      ]
    },
    {
      "id": "artifact-submission",
      "type": "artifact-submission",
      "title": "选择结果文件",
      "instructions": "文件仅在本机选择并校验，不上传，也不持久化文件内容。",
      "items": [
        {
          "id": "artifact-1",
          "label": "提交文件：3.2.4-1.jpg",
          "filename": "3.2.4-1.jpg",
          "extensions": [
            ".jpg"
          ],
          "minCount": 1,
          "maxCount": 1,
          "maxSize": 104857600
        },
        {
          "id": "artifact-2",
          "label": "提交文件：3.2.4.docx",
          "filename": "3.2.4.docx",
          "extensions": [
            ".docx"
          ],
          "minCount": 1,
          "maxCount": 1,
          "maxSize": 104857600
        }
      ]
    }
  ],
  "attachments": [
    {
      "name": "3.2.4.docx",
      "url": "assets/3.2.4/3.2.4.docx",
      "size": 14608,
      "sha256": "fb715b1b3ed963d0a3bec49e4cb6d0738087891c515287d08ad6397d69396512",
      "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
    },
    {
      "name": "3.2.4.ipynb",
      "url": "assets/3.2.4/3.2.4.ipynb",
      "size": 2957,
      "sha256": "9ebcc32ad169ad1d6526c139b8932273b70684087d6b24b6ec98f613acaeffa6",
      "mime": "application/x-ipynb+json"
    },
    {
      "name": "3.2.4.md",
      "url": "assets/3.2.4/3.2.4.md",
      "size": 2071,
      "sha256": "81e430a52043e3749db1366aba96e43c64e54a23bbb5afafa5f0448ecc82eb8a",
      "mime": "text/markdown"
    },
    {
      "name": "flower-detection.onnx",
      "url": "assets/3.2.4/flower-detection.onnx",
      "size": 102583340,
      "sha256": "af16a04a6ec48ac494065d4439fe9dea590d337b9ca6dc328160ccf04a217b9c",
      "mime": "application/octet-stream"
    },
    {
      "name": "flower_test.png",
      "url": "assets/3.2.4/flower_test.png",
      "size": 100699,
      "sha256": "0fa1f4d5aad2121e4f4bc74a7f38d290f3094eeb1082d4daae1daa65b4b0cdf5",
      "mime": "image/png"
    },
    {
      "name": "labels.txt",
      "url": "assets/3.2.4/labels.txt",
      "size": 10472,
      "sha256": "1f386e0d1cb6e28b9c2dac651c3dea6801e98ad1b41a14ce6bb1a093d72069f5",
      "mime": "text/plain"
    }
  ],
  "grading": {
    "mode": "completion-and-format-only"
  },
  "review": {
    "status": "approved",
    "notice": "由公开题面通用生成，未使用答案树。",
    "conflicts": []
  },
  "contentVersion": "cf49a13c9ed9e7dd"
}
