Questions about using tflite

If look at TensorFlow GitHub, it seems to be coded as Kotlin, but I want to ask how to implement it in Java. If it was implemented in Java four to five years ago, it cannot be synchronized.

HI, welcome to the TF Forum

TF is implemented in Python (and C++ modules)
You can access it from Java or Kotlin because there are binders.

What exactly are you trying to do? run a model on an Android app? That information can help me give you a better answer

There’s finally a comment! What I want to do is to use tflite for Android applications.

I’m trying to implement it in Java, but if you look at the official site, it’s almost Kotlin, so it’s difficult. The implementation of Java was a few years ago. Ask for advice.

Got it! (sorry for the delay)

There’s one example (official) here for example: examples/lite/examples/image_classification/android_java at master · tensorflow/examples · GitHub

the API should be similar but as expected most examples are using Kotlin now

also it’s worth taking a look on the Task Library: https://www.tensorflow.org/lite/inference_with_metadata/task_library/overview

it makes much easier to run inference but it’s not available for possible kinds of models

1 Like

Hi goatlab!

So depending on what your end goal is, there’s a few ways to approach this.

If you’re looking to use the Interpreter API, then we have a recent coded example in Java with the new Google Play Services implementation here.

If you’re looking to use the Task Library, then we have a Java sample from a couple of months ago here.

Both of these examples use an Image Classification model, so you should be able to compare them that way. That said, we are moving the vast majority of our Android samples to Kotlin since that’s the official recommended approach from the Android team.

Let me know if you have any other questions and I’ll see if I can point you in the right direction :slight_smile:

1 Like