【发布时间】:2018-06-16 22:35:12
【问题描述】:
我正在使用 Swift、Firebase 和 Tensorflow 构建图像识别模型。我有一个重新训练过的 MobileNet 模型,该模型将 [1,224,224,3] 的输入数组复制到我的 Xcode 包中,当我尝试从图像中添加数据作为输入时,我收到错误:Input 0 should have 602112 bytes, but found 627941 bytes. 我正在使用以下代码:
let input = ModelInputs()
do {
let newImage = image.resizeTo(size: CGSize(width: 224, height: 224))
let data = UIImagePNGRepresentation(newImage)
// Store input data in `data`
// ...
try input.addInput(data)
// Repeat as necessary for each input index
} catch let error as NSError {
print("Failed to add input: \(error.localizedDescription)")
}
interpreter.run(inputs: input, options: ioOptions) { outputs, error in
guard error == nil, let outputs = outputs else {
print(error!.localizedDescription)//ERROR BEING CALLED HERE
return }
// Process outputs
print(outputs)
// ...
}
如何将图像数据重新处理为 602112 字节?如果有人可以帮助我,我会很困惑,那就太好了:)
【问题讨论】:
-
您在使用 Firebase ML 套件吗?
-
@PannagSanketi 是的,我是。我在任何地方都找不到用于格式化输入数据以匹配 Swift 中的 MobileNet 规范的指南。只有 Obj-C
-
嘿@Ellek,链接由于某种原因被破坏了。你设法让它工作了吗?
标签: ios arrays firebase tensorflow tensorflow-lite