Welcome back.
I want from you to focus with me.
Now we need to connect our TensorFlow model with our house price screen.
Composable.
To do that, we need to create a new Kotlin class.
Name it as TF Lite Helper class.
This class takes into the parameters a private val context type context and let's start creating the
interpreter.
So private var interpreter.
It's of type interpreter.
What's the role of interpreter and why we use it.
The interpreter is the class that runs the model.
Interpreter is the TensorFlow Lite engine and nullable.
Because initialization is delayed, the model can't always be loaded immediately when the object is
created.
So we are using this line and nullable because you need a class level handle to the TensorFlow Lite
model interpreter, but you can't initialize it immediately at declaration time.
It also ensures that you can safely clean it up when the component lifecycle ends.
Okay, so the interpreter is the engine of TensorFlow Lite, the class that runs the model.
Okay, so this is the main function of TensorFlow interpreter.
Now inside the init block we need to import the model and use it.
So try val model buffer equals to load model file.
This is the class that we need to create the sorry the uh the function that we need to create okay.
Here specify the name of the model which is house price light.
Okay.
Please pay attention to the name of the model.
It's case sensitive, so make sure that it matches exactly the model's name.
Then we need to use interpreter and initialize it here.
So you can see guys here we are initializing the interpreter and passing the model buffer.
We can set a logcat look log dot v tag model loaded successfully.
In the catch.
You can use another log to see if there is any error failed to load the model okay, so here we passed
inside the interpreter constructor the model buffer which is the house price model tflite file.
Now let's create the load model file that returns the mapped byte.