【发布时间】:2019-08-26 07:16:55
【问题描述】:
我从以下存储库克隆了适用于 iOS 的 TensorFlowLite 示例应用 https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/ios
安装的 pod 文件包含
pod 'TensorFlowLiteSwift'
当我打开ImageClassification.xcworkspace 时,Xcode 直接显示以下错误。
类型“解释器”没有成员“选项”
我没有更改示例应用程序中的任何代码。
调用解释器的Options()时出现此错误
var options = Interpreter.Options()
我尝试使用 Interpreter 的其他方法获取 Option 属性,但无法获取。
init?(modelFileInfo: FileInfo, labelsFileInfo: FileInfo, threadCount: Int = 1) {
let modelFilename = modelFileInfo.name
// Construct the path to the model file.
guard let modelPath = Bundle.main.path(
forResource: modelFilename,
ofType: modelFileInfo.extension
) else {
print("Failed to load the model file with name: \(modelFilename).")
return nil
}
// Specify the options for the `Interpreter`.
self.threadCount = threadCount
var options = Interpreter.Options() // Here the issue is *Type 'Interpreter' has no member 'Options*
options.threadCount = threadCount
do {
// Create the `Interpreter`.
interpreter = try Interpreter(modelPath: modelPath, options: options)
// Allocate memory for the model's input `Tensor`s.
try interpreter.allocateTensors()
} catch let error {
print("Failed to create the interpreter with error: \(error.localizedDescription)")
return nil
}
// Load the classes listed in the labels file.
loadLabels(fileInfo: labelsFileInfo)
}
这个init() 预计会初始化并提供 ModelDataHandler 对象。
【问题讨论】:
标签: swift deep-learning tensorflow-lite