首页 > 解决方案 > TFlite 和 Android Studio - 使用浮点模型进行推理

问题描述

我想将一个非量化的 TFlite 模型(数据类型为 float32)部署到 android studio,但我不知道如何定义 de bytebuffer 进行推理。当我在 Android Studio 中加载模型时,我得到以下建议:

val model = Model.newInstance(context)

// Creates inputs for reference.
val inputFeature0 = TensorBuffer.createFixedSize(intArrayOf(1, 256, 256, 3), DataType.FLOAT32)
inputFeature0.loadBuffer(byteBuffer)

// Runs model inference and gets result.
val outputs = model.process(inputFeature0)
val outputFeature0 = outputs.outputFeature0AsTensorBuffer

// Releases model resources if no longer used.
model.close()

但是,没有定义 bytebuffer,我也不知道怎么做。目前我只看到人们直接为 Int8 模型定义它。

非常感谢。

标签: androidtensorflow

解决方案


推荐阅读