【问题标题】:The model does not have a valid input feature of type image -> Create ML该模型没有图像类型的有效输入特征 -> 创建 ML
【发布时间】:2020-04-17 00:57:58
【问题描述】:

我使用 Create ML 创建了一个 ML 模型,这是关于情感识别的。

作为输入文件,我上传了一个 CSV 文件。数据由 48x48 像素的人脸灰度图像组成。面部已自动注册,因此面部或多或少居中并在每张图像中占据大约相同的空间。任务是根据面部表情中显示的情绪将每张脸分为七类之一(0 = 愤怒、1 = 厌恶、2 = 恐惧、3 = 快乐、4 = 悲伤、5 = 惊讶、6 = 中性) .

我得到的模型有超过 87% 的准确率,但是当我在我的 Xcode 项目中使用它时,我得到了以下错误:

  func setup() {
    do {
      // Gender request
      requests.append(VNCoreMLRequest(
        model: try VNCoreMLModel(for: GenderNet().model),
        completionHandler: handleGenderClassification
      ))
      // Age request
      requests.append(VNCoreMLRequest(
        model: try VNCoreMLModel(for: AgeNet().model),
        completionHandler: handleAgeClassification
      ))
      // Emotions request
      requests.append(VNCoreMLRequest(
        model: try VNCoreMLModel(for: test().model),
        completionHandler: handleEmotionClassification
      ))
    } catch {
      assertionFailure("Can't load Vision ML model: \(error)")
    }
  }
      Fatal error: Can't load Vision ML model: Error Domain=com.apple.vis Code=15 
    "The model does not have a valid input feature of type image"
    UserInfo={NSLocalizedDescription=The model does not have a valid input feature of type image}:
    file /Users/ivandimitrov/Desktop/Faces/Faces/ClassificationService.swift, line 38

您对如何解决这个问题有任何想法吗?

【问题讨论】:

    标签: swift createml


    【解决方案1】:

    您的输入未被识别为图像,您可以通过在 Xcode 中单击您的模型来验证这一点: 我的输入是 Image 类型,但你的可能是另一种类型。

    运行转换脚本时,例如coremltools.converters.tensorflow.convert(model, ...),您需要提供参数image_input_names,该参数应与输入层的名称匹配。

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-22
      • 2019-01-15
      • 1970-01-01
      相关资源
      最近更新 更多