Welcome back.
We created those functions build analyzer load labels and load model.
Now let's make use of those functions.
Return back to the initialize function.
Here the model byte buffer equals to load model.
And we pass the model file name as a parameter.
Then labels equals to load labels and pass the label file name.
By the way those variables we create them in the first, uh, first video of this ViewModel class.
Okay.
Then we need the interpreter equals to the interpreter model byte buffer and pass null.
Here we need the byte buffer and the options null.
This is what we created before interpreter.
The interpreter equals to the class interpreter which is from TensorFlow Lite interpreter class.
And we pass the byte buffer that we created before state dot value equals to the response dot success.
Make it as success and return unit.
Pass the unit as parameter.
We are updating the state here at the first uh the first step we are loading the The response and make
the response as loading so the state equals to loading.
When the load is finished, set the state as success val input tensor equals to interpreter dot get
tensor.
Input tensor equals to zero.
Then we can make a log dot v to get the parameters and the shapes of the tensor.
So the input tensor shape and the input tensor data type okay.
This is good.
And this is healthy because you need to check always for the correct shapes of your model.
Close the try and catch by making the exception here and fail to initialize.
Set the state to failure.
So, um, this is what I'm gonna try to show you guys.
When you start loading the model, set the state to loading.
When you finished loading, set the state as success, and if you failed, go and set the state as failed.
Okay.
This is the initialize function of this.
If this data the view model.
And this is very important and we are following the clean architecture, the MVVM model architecture
model for this application.