WEBVTT

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

00:01.040 --> 00:03.440
Let's continue with the detect function.

00:03.440 --> 00:12.120
And here under the image processor variable let me create another variable called tensor image.

00:12.120 --> 00:20.360
Here we have the tensor image Float32 tensor image load and tensor image equals to image processor dot

00:20.400 --> 00:21.240
process.

00:21.280 --> 00:31.280
The first line creates an image container, a TensorFlow Lite image container that holds image data

00:31.280 --> 00:35.080
in a format that model can can understand.

00:35.080 --> 00:44.560
So that tensor image is part of the TensorFlow Lite support library, and data type means each pixel

00:44.560 --> 00:49.480
will be stored as 32 bit floating point number.

00:49.720 --> 00:54.040
This matches most models input type.

00:54.080 --> 01:03.120
Essentially, it's an object wrapper that will hold your image data pixels in the model's expected tensor

01:03.220 --> 01:06.820
Format and the tensor image here.

01:07.020 --> 01:14.860
Tensor image dot load loads your Android's bitmap image into a tensor image.

01:14.860 --> 01:23.780
Converts the bitmaps pixel data into 32 float Float32 tensor format inside the object.

01:23.820 --> 01:31.300
Now the tensor image holds your row image but not yet preprocessed.

01:31.300 --> 01:38.780
Still has original size and pixel value 0 to 25 255.

01:38.820 --> 01:45.260
That tensor image equals to image pre-processor dot process.

01:45.300 --> 01:54.180
This passes the loaded image through your previously defined image processor pipeline.

01:54.180 --> 02:02.460
This will resize it to match your model's required input width and height, and normalizes the pixel

02:02.460 --> 02:09.160
values from zero 25 to 255 to 0 to one.

02:09.160 --> 02:18.040
Okay, so here I am, passing the image to the image processor to process and resize it and normalize

02:18.040 --> 02:22.600
it to fit our demands, our model demands.

02:22.800 --> 02:31.200
The result is a new processed image tensor image ready to be fed into your model.

02:31.240 --> 02:34.880
Okay, so this is a very important thing.

02:35.040 --> 02:42.680
We need to process the image, convert it into a tensor image to pass it and fed to your model.

02:42.680 --> 02:49.600
Then let's continue with creating the input buffer by creating val input buffer.

02:49.600 --> 02:52.840
And we talked about the input buffer in the previous videos.

02:53.040 --> 02:55.240
Tensor image dot buffer.

02:55.400 --> 02:58.040
Creating the output buffer.

02:58.080 --> 03:04.040
Let's create the output buffer based on your model's output size and shape.

03:04.160 --> 03:11.310
So val output buffer equals to tensor flow buffer.

03:11.430 --> 03:16.110
Tensor buffer dot create fixed size.

03:16.430 --> 03:20.270
We need to pass the parameters to parameters.

03:20.390 --> 03:23.150
The first parameter is the shape.

03:23.150 --> 03:33.030
It's an int array of one two and the data type float32 the output buffer.

03:33.070 --> 03:40.710
Think about it as a container, an output container to store the model's prediction result.

03:40.830 --> 03:49.030
That tensor buffer a class that holds a numeric tensor data used for input outputs in TensorFlow Lite

03:49.030 --> 03:59.990
and that create fixed size, is a function defining the shape of the output tensor one two, which which

03:59.990 --> 04:08.310
means that one sample with two output values, for example x and y coordinates for two prediction scores.

04:08.550 --> 04:17.450
So here we are creating a Function, a function that returns the input array of one and two.

04:17.490 --> 04:25.210
Defining the shape of the output tensor one sample with two output values.

04:25.250 --> 04:32.970
Okay, so I want from you to understand what those arrays and numbers and elements mean.

04:32.970 --> 04:42.490
One sample with two output values x and y are coordinates of two prediction scores and data type Float32

04:42.530 --> 04:43.650
means the output.

04:43.690 --> 04:53.250
The outputs are floating point numbers, so this line creates an empty result container with shape one,

04:53.450 --> 05:00.370
two and float values ready to receive the model's output after your call.

05:00.850 --> 05:08.010
This is how we define the output buffer and how to process the image.
