Welcome back.
We talked about the input shape that returns for example, an array of four elements.
The first element returns the batch size.
The second element returns the image width, the third element returns the image height, and the fourth
element returns the number of colors and the color channels RGB channels.
Okay, now we created before the input width and height.
So let me update those variables by using the elements of the input shape.
Using input width equals to input shape dot.
Get the second element number one.
If not, go and put it by default to two for and similar to the input width, we need to update the
input height by using input shape.
Get two and 2 to 4.
You can also make a logcat to determine if there is um, for example, uh any more, any errors.
So log dot v verbose.
Name the key tag and here the model input shape.
Set the input shape like this.
Content dot.
You can use join to string.
It's better.
Okay, here we are getting the model input shape.
The third step as we said the first step is loading the model.
The second step the input shape.
The third step is the output shape.
Output shape val.
Output shape the interpreter dot.
Get output tensor and zero.
Passing the output index dot shape.
Also log v.
Let me create the log and then we'll lecture about the output.
So here model output shape output shape dot to join to string okay.
So this is our output shape.
In the same way we use the interpreter to get the output tensor and accessing the first output tensor
at index zero from your TensorFlow Lite model, a model can have multiple outputs, but most object
detection or classification models use just one.
The shape function returns an array of integers that describes the dimensions of the model's output.
This tells you what kind of data and how much data the model produces per inference.
For example, a classification model might output shape um, for example, uh one and 1001.
So probabilities for 1001 classes.
Another example is um that ten bounding boxes 110 for the an object detection model might output like
this array the ten boxes, ten bounding boxes, each with four coordinates.
Some models output multiple arrays boxes, labels, scores, but this reads the first one.
Now let me take a look at here.
So this is the look at that.
The output shape would be printed.
And look at the fourth step is to load the labels.
So here loading the labels.
Did you remember the text file that we we've added before with the ML.
It's called labels dot txt.
So labels file dot load labels.
Whenever we need to access the assets we use labels file util load labels and context and labels dot
txt okay this is our function set up interpreter.
Here we need to close it with a catch block and e exception listener dot on error.
And if we need to print this message we can use log dot v.
Set up interpreter and pass the message okay.
Remove those extra curly braces.
And this is our set up interpreter function.