【问题标题】:Tensorflow-Lite unresolved reference for tfLite!!.setUseNNAPI in kotlin Android Appkotlin Android App 中 tfLite!!.setUseNNAPI 的 Tensorflow-Lite 未解决参考
【发布时间】:2020-10-22 06:49:10
【问题描述】:

我正在尝试运行this app,这是一个对象检测应用程序。该应用使用 Tensorflow-Lite。

尝试运行此应用时出现错误

Unresolved reference: setUseNNAPI

对于这些行

override fun setUseNNAPI(isChecked: Boolean) {
    if (tfLite != null) tfLite!!.setUseNNAPI(isChecked)
}

找不到tfLite!!.setUseNNAPI(isChecked) 的引用。这个函数应该以某种方式连接到Interpreter 选项,但这些是在create 方法中设置的:

    @Throws(IOException::class)
    fun create(
            assetManager: AssetManager,
            modelFilename: String,
            labelFilename: String,
            inputSize: Int,
            isQuantized: Boolean): Classifier {
        ...

        try {
            val options = Interpreter.Options()
            options.setNumThreads(4)
            options.setUseNNAPI(false)
            d.tfLite = Interpreter(loadModelFile(assetManager, modelFilename), options)
        } catch (e: Exception) {
            throw RuntimeException(e)
        }

有人知道发生了什么吗?

【问题讨论】:

    标签: android android-studio tensorflow kotlin tensorflow-lite


    【解决方案1】:

    请检查 app.gradle 文件。 如果您看到以下行或版本低于 2.3.0,请将其更新到最新版本

    实现 'org.tensorflow:tensorflow-lite:0.0.0-nightly'

    改成

    实现 'org.tensorflow:tensorflow-lite:2.3.0'

    它没有为安卓下载最新的 tensorflow-lite 版本。

    希望这能解决您的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-02
      • 2019-10-11
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 2018-10-25
      • 1970-01-01
      相关资源
      最近更新 更多