'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?



Solution 1:[1]

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!

Solution 2:[2]

You can merge with new array

array_merge(request()->all(), ['cool' =>  request()->get('var1').request()->get('var2')]);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cristian Davide Conte
Solution 2 Recep Gümü?