在 iOS 版 Swift 中使用 TensorFlow 模型 [英] Use TensorFlow model with Swift for iOS

查看:61
本文介绍了在 iOS 版 Swift 中使用 TensorFlow 模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正尝试在我们的 iOS 应用中使用 TensorFlow Face Mesh 模型.型号详情:https://drive.google.com/file/d/1VFC_wIpw4O7xBOiTgUldl79d-LsnA/视图.

We are trying to use TensorFlow Face Mesh model within our iOS app. Model details: https://drive.google.com/file/d/1VFC_wIpw4O7xBOiTgUldl79d9LA-LsnA/view.

我按照 TS 官方教程设置模型:https://firebase.google.com/docs/ml-kit/ios/use-custom-models 并且还使用教程中的 Python 脚本打印了模型 Input-Output 并得到了这个:

I followed TS official tutorial for setting up the model: https://firebase.google.com/docs/ml-kit/ios/use-custom-models and also printed the model Input-Output using the Python script in the tutorial and got this:

INPUT
[  1 192 192   3]
<class 'numpy.float32'>
OUTPUT
[   1    1    1 1404]
<class 'numpy.float32'> 

在这一点上,我很难理解这些数字的含义,以及如何使用模型 Interpreter 传递输入图像并获取输出面网格点.到目前为止,这是我的 Swift 代码:

At this point, I'm pretty lost trying to understand what those numbers mean, and how do I pass the input image and get the output face mesh points using the model Interpreter. Here's my Swift code so far:

let coreMLDelegate = CoreMLDelegate()
var interpreter: Interpreter
// Core ML delegate will only be created for devices with Neural Engine
if coreMLDelegate != nil {
  interpreter = try Interpreter(modelPath: modelPath,
                                delegates: [coreMLDelegate!])
} else {
  interpreter = try Interpreter(modelPath: modelPath)
}

任何帮助将不胜感激!

推荐答案

这些数字的含义完全取决于您使用的模型.它与 TensorFlow 和 Core ML 都无关.

What those numbers mean completely depends on the model you're using. It's unrelated to both TensorFlow and Core ML.

输出是一个 1x1x1x1404 张量,这基本上意味着你得到一个 1404 个数字的列表.如何解释这些数字取决于模型的设计目的.

The output is a 1x1x1x1404 tensor, which basically means you get a list of 1404 numbers. How to interpret those numbers depends on what the model was designed to do.

如果模型不是您自己设计的,则必须查找相关文档.

If you didn't design the model yourself, you'll have to find documentation for it.

这篇关于在 iOS 版 Swift 中使用 TensorFlow 模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆