gpt4 book ai didi

Swift TensorFlowLite 解释器错误 : Type 'Interpreter' has no member 'Options'

转载 作者:搜寻专家 更新时间:2023-11-01 06:50:32 26 4
gpt4 key购买 nike

我从以下存储库中克隆了适用于 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'

我没有更改示例应用程序中的任何代码。

调用 Interpreter 的 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 对象。

最佳答案

Interpreter.Options() 应该改回 InterpreterOptions() 它最初在所有 TensorFlow Lite 示例中的样子。

最近的一个提交破坏了构建: https://github.com/tensorflow/examples/commit/751f4648e3917178b0e67454422477fe5d81d611

关于Swift TensorFlowLite 解释器错误 : Type 'Interpreter' has no member 'Options' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57653342/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com