简体   繁体   中英

Build fail when using Tensorflow lite metadata in Android Studio 4.1

guys, I am new to Stackoverflow

A question about using Tensorflow lite in AS4.1

As I "new" -> "other" -> "tensorflow lite model" and import a new.tflite file

The project automatically generate a PosenetMobilenetFloat0751Metadata1.java file

Then "build" -> "Make project", it shows error:

package org.tensorflow.lite.support.metadata does not exist import org.tensorflow.lite.support.metadata.MetadataExtractor;

The error happens in PosenetMobilenetFloat0751Metadata1.java:

import org.tensorflow.lite.support.metadata.MetadataExtractor;

This error seems come from I don't have this dependency,

following is my dependencies in build.gradle

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation project(":posenet")
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  implementation 'androidx.appcompat:appcompat:1.1.0'
  implementation 'androidx.core:core-ktx:1.1.0'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  implementation 'org.tensorflow:tensorflow-lite:1.12.0'
  implementation 'org.tensorflow:tensorflow-lite-gpu:2.2.0'
  implementation 'org.tensorflow:tensorflow-lite-support:0.0.0-nightly'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test:runner:1.2.0'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Can Someone help me how to go next?

I think you need to use implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2' .

Please try to add this

configurations {

    libMetadata
}


dependencies {

    libMetadata 'org.tensorflow:tensorflow-lite-support:0.0.0-experimental-metadata-monolithic'
}


task downloadLibs(type: Sync) {

    from configurations.libMetadata

    into "$buildDir/libs"

    rename 'tensorflow-lite-support-0.0.0-experimental-metadata-monolithic.jar', "tensorflow-lite-support-metadata.jar"
}

Careful when adjust another version, this very sensitive as BUILD!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM