WEBVTT

00:00.120 --> 00:00.880
Welcome back.

00:00.880 --> 00:07.480
We created those functions build analyzer load labels and load model.

00:07.680 --> 00:11.120
Now let's make use of those functions.

00:11.160 --> 00:13.600
Return back to the initialize function.

00:13.640 --> 00:17.320
Here the model byte buffer equals to load model.

00:17.320 --> 00:20.640
And we pass the model file name as a parameter.

00:20.760 --> 00:28.480
Then labels equals to load labels and pass the label file name.

00:28.520 --> 00:37.800
By the way those variables we create them in the first, uh, first video of this ViewModel class.

00:37.840 --> 00:38.400
Okay.

00:38.440 --> 00:46.160
Then we need the interpreter equals to the interpreter model byte buffer and pass null.

00:46.200 --> 00:52.040
Here we need the byte buffer and the options null.

00:52.080 --> 00:55.840
This is what we created before interpreter.

00:56.080 --> 01:03.680
The interpreter equals to the class interpreter which is from TensorFlow Lite interpreter class.

01:03.960 --> 01:13.600
And we pass the byte buffer that we created before state dot value equals to the response dot success.

01:13.640 --> 01:17.000
Make it as success and return unit.

01:17.160 --> 01:19.600
Pass the unit as parameter.

01:19.720 --> 01:28.580
We are updating the state here at the first uh the first step we are loading the The response and make

01:28.580 --> 01:31.980
the response as loading so the state equals to loading.

01:32.220 --> 01:43.820
When the load is finished, set the state as success val input tensor equals to interpreter dot get

01:43.940 --> 01:44.780
tensor.

01:44.980 --> 01:47.260
Input tensor equals to zero.

01:47.300 --> 01:55.660
Then we can make a log dot v to get the parameters and the shapes of the tensor.

01:55.660 --> 02:01.380
So the input tensor shape and the input tensor data type okay.

02:01.620 --> 02:02.620
This is good.

02:02.660 --> 02:09.540
And this is healthy because you need to check always for the correct shapes of your model.

02:09.580 --> 02:15.660
Close the try and catch by making the exception here and fail to initialize.

02:15.860 --> 02:18.580
Set the state to failure.

02:18.580 --> 02:22.980
So, um, this is what I'm gonna try to show you guys.

02:22.980 --> 02:26.820
When you start loading the model, set the state to loading.

02:26.820 --> 02:34.940
When you finished loading, set the state as success, and if you failed, go and set the state as failed.

02:34.940 --> 02:35.460
Okay.

02:35.700 --> 02:38.420
This is the initialize function of this.

02:38.540 --> 02:41.580
If this data the view model.

02:41.580 --> 02:49.660
And this is very important and we are following the clean architecture, the MVVM model architecture

02:49.660 --> 02:52.100
model for this application.
