Welcome back.
I want from you to focus with me.
This is a very important step.
We need to understand the input and output of our model.
For that, let's go to a website called natron.
So natron dot app, upload your model.
And here we have a hierarchy for our model.
You are not um like forced to understand all of those.
We need to start with the first one and understand that it takes an image with 300 width and 300 height
times three.
This is the shape, this is the input shape.
So if we go to here click on this normalized input image tensor you get inputs and outputs.
The inputs normalized input image tensor.
We need to convert it to a unit eight unified integer.
You int eight with this array one 300 303.
So keep this in your mind.
The outputs would be for the TF light detection post process.
Its type is Float32.
Another output would be detection process, post process one Postprocess two, and post process three.
All of those are of type float32 so the input is unit eight and unit or you int eight.
With this shape this array one 300 303.
Now let's understand the input.
So this is the shape and data type of that data your model expects to receive.
Copy it And let me move back to Android Studio and write the notes here.
Okay.
I want from you to write them down because those are very important notes.
The input you want and it's not unified.
It's unsigned integer, unsigned integer, unsigned integer eight bit.
Those values are always positive.
So think about it as an number between 0 and 255 okay.
So this is a positive eight bit integer.
Eight bit means it uses eight bit one byte of memory per number, allowing to two to power eight equals
to 256.
Possible values is.
For this purpose we start from 0 to 255.
This data type is extremely common for image data, because the standard image pixel values range from
0 to 250, where zero typically represents the absence of color, which is black, and 250, which is
full intensity of a color white or a primary color.
In short, your model expects image pixel values as integer between 0 and 55 255.
Now let's take this array, copy it and paste it here.
The first dimension.
This is the batch size.
Deep learning models are often designed to process multiple inputs simultaneously for efficiency.
This dimension tells us how many images are in a single batch.
A one here means the model is set up to process one image at a time.
303 hundred.
The first 300 is the height, and the second is the width, which is more common in deep learning frameworks
like TensorFlow.
Those represents the height and width of the image in pixels.
And the last dimension is three.
This represents the color channels of the image.
It's a standard RGB image.
Red values channel one, green values, channel two B values and blue values channel three.
So for a single pixel, the model sees three numbers r, g, b.
So this number represents the r, g b color channels of the image.
A tensor.
The unsigned integer describes a batch containing a single 300 by 300 pixels color RGB image.
You can think of it as a stack of three mattresses, each 300 by 300.
One for each color channel red, blue and green, all wrapped up in a single container.
The batch.
So this is for image one.
This is a batch of one image one 300 pixel height.
The first row the RGB, RGB, RGB, and uh till till the end row number two the same.
This is a matrix and a matrix, which is an array of arrays, and this is repeated 300 times for width
till reaching row number 300.
Okay.
So when you want to use a model with this input specification you must pre-process your image to match
it exactly.
Resize your image to 300 by 300 pixels.
This is what we're going to do.
Ensures it is an RGB format, not BRG or BGR, which OpenCV sometimes uses, or grayscale.
Do not normalize the pixel values to 0 to 1 or -1 to 1.
Leave them as integers in 0 to 255.
Range because the data type is an unsigned integer eight.
Some models have a normalization step built in, but given this specific model, it expects the row
unsigned integer eight values.
This is a very important lesson.
You should pay attention to it when dealing with different models and different combinations, different
input and different output shapes.
The output is.
Float 300.
Float 32, which is the float 32 provides much higher numerical precision you than, uh, unsigned integer
eight.
So the result would be a 3 or 4 of those tflite detection postprocess, which are of type Float32.
Training and inference require fine grained values for accurate calculations.
Deep learning operations.
Metric metrics.
Multiplication activations work much better with floating point numbers.
Many models internally normalize pixel values to range from 0 to 1 or -1 to 1, but in this example,
we're not normalizing anything.
Okay.