Welcome back.
Let's continue with the detect function.
And here under the image processor variable let me create another variable called tensor image.
Here we have the tensor image Float32 tensor image load and tensor image equals to image processor dot
process.
The first line creates an image container, a TensorFlow Lite image container that holds image data
in a format that model can can understand.
So that tensor image is part of the TensorFlow Lite support library, and data type means each pixel
will be stored as 32 bit floating point number.
This matches most models input type.
Essentially, it's an object wrapper that will hold your image data pixels in the model's expected tensor
Format and the tensor image here.
Tensor image dot load loads your Android's bitmap image into a tensor image.
Converts the bitmaps pixel data into 32 float Float32 tensor format inside the object.
Now the tensor image holds your row image but not yet preprocessed.
Still has original size and pixel value 0 to 25 255.
That tensor image equals to image pre-processor dot process.
This passes the loaded image through your previously defined image processor pipeline.
This will resize it to match your model's required input width and height, and normalizes the pixel
values from zero 25 to 255 to 0 to one.
Okay, so here I am, passing the image to the image processor to process and resize it and normalize
it to fit our demands, our model demands.
The result is a new processed image tensor image ready to be fed into your model.
Okay, so this is a very important thing.
We need to process the image, convert it into a tensor image to pass it and fed to your model.
Then let's continue with creating the input buffer by creating val input buffer.
And we talked about the input buffer in the previous videos.
Tensor image dot buffer.
Creating the output buffer.
Let's create the output buffer based on your model's output size and shape.
So val output buffer equals to tensor flow buffer.
Tensor buffer dot create fixed size.
We need to pass the parameters to parameters.
The first parameter is the shape.
It's an int array of one two and the data type float32 the output buffer.
Think about it as a container, an output container to store the model's prediction result.
That tensor buffer a class that holds a numeric tensor data used for input outputs in TensorFlow Lite
and that create fixed size, is a function defining the shape of the output tensor one two, which which
means that one sample with two output values, for example x and y coordinates for two prediction scores.
So here we are creating a Function, a function that returns the input array of one and two.
Defining the shape of the output tensor one sample with two output values.
Okay, so I want from you to understand what those arrays and numbers and elements mean.
One sample with two output values x and y are coordinates of two prediction scores and data type Float32
means the output.
The outputs are floating point numbers, so this line creates an empty result container with shape one,
two and float values ready to receive the model's output after your call.
This is how we define the output buffer and how to process the image.