WEBVTT

00:00.080 --> 00:01.120
Welcome back.

00:01.160 --> 00:09.040
We created the setup interpreter function inside the Object Detector Helper class.

00:09.040 --> 00:13.160
Now under this function let's create another function.

00:13.320 --> 00:15.800
Name it as detect.

00:15.920 --> 00:22.280
Taking to the parameters a bitmap object and a rotation of type integer.

00:22.400 --> 00:23.360
Start with.

00:23.520 --> 00:30.440
If interpreter equals to null, then set up interpreter.

00:30.440 --> 00:33.040
Call the function set up interpreter.

00:33.080 --> 00:36.600
If not, if the interpreter is already found.

00:36.800 --> 00:43.120
Start with processing the image to match model input requirements.

00:43.400 --> 00:53.600
So preprocess val image processor equals to image processor dot builder dot.

00:53.640 --> 00:56.360
Here we have an error image processor.

00:56.480 --> 01:02.760
Let me go up and remove this import because we don't need it anymore.

01:02.960 --> 01:07.480
Let me scroll down and import the correct package.

01:07.520 --> 01:08.640
Alt+ enter.

01:08.680 --> 01:15.360
Not the Android X camera core I need from the TensorFlow Lite support image processor.

01:15.360 --> 01:16.960
And here we solve there.

01:17.000 --> 01:20.240
Okay, let me add some parameters here.

01:20.400 --> 01:21.680
Resize up.

01:21.680 --> 01:22.240
Don't worry.

01:22.240 --> 01:24.320
We're going to clarify everything.

01:24.560 --> 01:36.120
And the input the resize operation takes three parameters the width the height and the resize method

01:36.120 --> 01:38.000
which is bilinear.

01:38.000 --> 01:48.800
And here use add normalize op zero f and 255F based on your model's requirement.

01:48.800 --> 01:52.360
Build and let me clarify everything.

01:52.400 --> 01:53.840
Remove this image.

01:53.840 --> 01:57.240
Pre-process or processor dot builder.

01:57.440 --> 02:02.200
This creates a sequence of image transformation.

02:02.480 --> 02:06.200
This comes from TensorFlow Lite support library.

02:06.440 --> 02:15.920
You use it to preprocess images, resize, normalize, rotate before passing them into the model.

02:16.040 --> 02:26.360
So whenever we uh we say pre-processing we mean that we resize, normalize, rotate the image before

02:26.400 --> 02:28.960
passing them into the model.

02:29.000 --> 02:36.600
The first add function adds a resize operation to the preprocessing pipeline.

02:36.760 --> 02:43.800
It resizes the input image to match your model's required input size.

02:43.840 --> 02:52.160
As we said before, for our application and for our model, it would be by default to two.

02:52.200 --> 02:52.640
Four.

02:52.680 --> 03:01.320
Okay, so here we are setting it to to the default input height and default input width.

03:01.640 --> 03:05.400
And as I told you, it's by default to 24.

03:05.440 --> 03:15.320
If the input width and input height are not available, but they are available here in the input width,

03:15.600 --> 03:26.360
which is the global variable that we used to set here, the input width and height resize OP means it

03:26.360 --> 03:34.360
uses bilinear interpolation as smooth high quality method for resizing images.

03:34.360 --> 03:45.880
If your camera frame, for example, is 640 by 480, but your model expects 224 by two two for this

03:45.880 --> 03:47.240
step, resize it.

03:47.240 --> 03:49.440
It automatically again.

03:49.440 --> 03:56.960
Guys, this is the image pre-processing and processing step.

03:57.080 --> 04:00.320
And it's a very very important.

04:00.440 --> 04:10.880
Then we used another add function adds a normalization step normalize up mean zero and standard deviation

04:10.880 --> 04:15.320
255F applies the formula to each pixel.

04:15.600 --> 04:18.920
So here let me write this node.

04:18.960 --> 04:25.200
Output equals to input minus mean over standard deviation.

04:25.440 --> 04:38.360
So with zero f mean each pixel from 0 to 255 becomes pixel over 255, scaled into the range 0 to 1.

04:38.600 --> 04:53.080
Again guys for example, with 0F0 mean zero f gives us pixel over 255, which is the standard deviation.

04:53.200 --> 05:01.480
Most neural networks expect input values between 0 and 1 and not 0 to 2 five five.

05:01.720 --> 05:11.680
So for this, we need to use this important step to range and make the neural networks expect input

05:11.680 --> 05:14.200
values between 0 and 1.

05:14.200 --> 05:23.720
And the build function finalizes and creates the image processor object which can later use and it creates

05:23.720 --> 05:26.480
the final processor pipeline.

05:26.520 --> 05:34.600
Again guys what we did here image processor build start building pre-processing steps.

05:34.840 --> 05:39.920
The first add function resize image to the model's input size.

05:39.920 --> 05:43.920
So here resizing the image to the model's input size.

05:44.120 --> 05:50.240
And the second step normalizing the pixels value.

05:50.280 --> 05:58.360
Normalizing means converting 0 to 2 five five into another range from 0 to 1.
