【问题标题】:How to know what class the image belongs to?如何知道图像属于哪个类?
【发布时间】:2021-02-13 01:51:04
【问题描述】:

我正在尝试使用 Vision 和 CoreML。

代码:

extension CaptureImageView {
    private func loadImage() {
        guard let inputImage = image else { return }
        predictImage = inputImage
        performImageClassification()
    }
    
    private func performImageClassification() {
        let image = self.predictImage
        let resizedImage = image?.resizeTo(size: CGSize(width: 224, height: 224))
        let buffer = resizedImage?.toBuffer()
        let output = try? model.prediction(image: buffer!)
        if let output = output {
            breed = output.classLabel
        }
    }
}

我想:

  1. 看看这是不是照片中的狗
  2. 如果是狗,请显示品种
  3. 如果它不是狗,请表现出一些警惕。

问题: 目前这种识别可以识别一切 :) 但我只想识别狗。

如前所述,我正在使用 Apple 的 Vision、CoreML、MobileNetV2.mlmodel。

【问题讨论】:

    标签: ios swift coreml apple-vision


    【解决方案1】:

    此模型可检测 1000 类对象。其中大约 200 种是犬种。找出哪些类是狗,并且仅在检测到的类是狗类之一时才显示一些东西。

    如果要检测其他类型的狗,则必须训练自己的模型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-11
      • 2010-12-28
      • 1970-01-01
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      • 1970-01-01
      • 2014-08-05
      相关资源
      最近更新 更多