Swift TensorFlowLite Interpreter Error : Type 'Interpreter' has no member 'Options'
Swift TensorFlowLite Interpreter Error : Type 'Interpreter' has no member 'Options'
我从以下存储库中为 iOS 克隆了 TensorFlowLite 示例应用程序
https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/ios
已安装的 pod 文件包含
pod 'TensorFlowLiteSwift'
当我打开ImageClassification.xcworkspace
时,Xcode直接显示如下错误。
Type 'Interpreter' has no member 'Options'
我没有更改示例应用程序中的任何代码。
调用 InterpreterOptions()
时出现此错误
var options = Interpreter.Options()
我尝试使用其他解释器方法获取选项 属性,但无法获取。
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 对象。
Interpreter.Options()
应改回 InterpreterOptions()
所有 TensorFlow Lite 示例中的原始状态。
最近的一个提交破坏了构建:
https://github.com/tensorflow/examples/commit/751f4648e3917178b0e67454422477fe5d81d611
我更改了本地代码以使用 InterpreterOptions class。
// Specify the options for the `Interpreter`.
self.threadCount = threadCount
var options = InterpreterOptions()
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)
}
我从以下存储库中为 iOS 克隆了 TensorFlowLite 示例应用程序 https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/ios
已安装的 pod 文件包含
pod 'TensorFlowLiteSwift'
当我打开ImageClassification.xcworkspace
时,Xcode直接显示如下错误。
Type 'Interpreter' has no member 'Options'
我没有更改示例应用程序中的任何代码。
调用 InterpreterOptions()
时出现此错误
var options = Interpreter.Options()
我尝试使用其他解释器方法获取选项 属性,但无法获取。
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 对象。
Interpreter.Options()
应改回 InterpreterOptions()
所有 TensorFlow Lite 示例中的原始状态。
最近的一个提交破坏了构建: https://github.com/tensorflow/examples/commit/751f4648e3917178b0e67454422477fe5d81d611
我更改了本地代码以使用 InterpreterOptions class。
// Specify the options for the `Interpreter`.
self.threadCount = threadCount
var options = InterpreterOptions()
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)
}