swift - 如何不基于图像分类快速运行tflite模型

标签 swift xcode tensorflow audio tensorflow-lite

我看过一些有关如何运行tflite模型进行图像分类的教程,但不知道如何为其他任何应用程序使用它。例如,我有一个模型,该模型以( 16000,1)数组。如何将这个数组传递给tflite模型?

最佳答案

Tflite使用字节缓冲区。
您必须将所有输入转换为字节缓冲区,例如

let len = 16000
var audio = [Float](repeating: Float(1.0), count: len)
let audioBuffer = Data(bytes: &audio, count: audio.count * MemoryLayout<Float>.stride)
try interpreter.copy(audioBuffer, toInputAt: 0)

关于swift - 如何不基于图像分类快速运行tflite模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61529235/

相关文章:

ios - 使用触摸滚动 SpriteNode

iphone - 使用 xcode 中的 validate 验证应用程序 - 发现错误 - 提供图像

ios - 如何将应用程序图像添加到 iPad 和 iPad Pro 的 Assets 目录中?

swift - sqlite3_open 在 swift Playground 而不是 swift 应用程序中工作

swift - CMPedometer 步数不可用。为什么?

ios - 如何将 array.indexOf 与协议(protocol)一起使用?

ios - 突出显示时 UIButton 周围不需要的不可见检测区域

macos - 找不到-ltensorflow

tensorflow - 自定义损失函数中的张量索引

python - 仅使用 Tensorflow 进行目标检测的区域提案网络训练