WEBVTT

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

00:01.280 --> 00:08.280
Maybe you are asking if we added the best Float16 model and the labels.

00:08.320 --> 00:09.560
TXT file.

00:09.560 --> 00:14.560
If we run the application may it will detect the objects directly.

00:14.680 --> 00:16.360
Let's test and see.

00:16.600 --> 00:18.480
Open the detection view model.

00:18.480 --> 00:26.800
Just say that just update the model file name to best Float16 Tflite.

00:26.800 --> 00:28.640
And you see it's highlighted in green.

00:28.640 --> 00:37.480
So it detects the asset 6.18MB and labels dot txt.

00:37.560 --> 00:39.720
Also it's being highlighted.

00:39.720 --> 00:44.920
If we run the application now maybe it will run normally.

00:44.920 --> 00:46.280
Let's test and see.

00:46.280 --> 00:50.960
This is our app grant camera permissions while using.

00:51.200 --> 00:57.040
And our application started but no detections.

00:57.040 --> 01:09.040
If we put the battery no object is detected because we need to configure the shape of our model and

01:09.040 --> 01:13.720
the tensors, the input and the output of our model.

01:13.760 --> 01:22.760
Always remember that input here Float32 one 640 640 and three.

01:22.800 --> 01:28.480
Also the output Float32 one five 8400.

01:28.520 --> 01:38.160
Those are the parameters of the tensors that we're going to work on of our for our application and update

01:38.160 --> 01:41.280
them in order to detect batteries.

01:41.320 --> 01:50.680
Again guys, maybe if you have another object detection, maybe if you have two classes three, those

01:50.720 --> 01:52.080
will be different.

01:52.080 --> 01:55.000
So it's not mandatory to get one.

01:55.040 --> 01:56.640
Five 8400.

01:56.640 --> 02:03.240
So please pay attention to this note because every every model has its own sensors okay.

02:03.510 --> 02:04.430
And tensors.

02:04.550 --> 02:12.270
So inside this view model let me paste those nodes the input and the output in order to memorize them

02:12.270 --> 02:12.830
well.

02:12.870 --> 02:13.350
Okay.

02:13.670 --> 02:17.710
Now scroll down here we need to the interpreter.

02:17.710 --> 02:22.550
We have the state the parameters and the detection list.

02:22.550 --> 02:24.350
Similar to what we've done before.

02:24.350 --> 02:29.830
We created this initialize function for loading the model state labels.

02:29.870 --> 02:34.350
Loads the labels and model Bytebuffer loads the model.

02:34.350 --> 02:35.870
Then we need to pass.

02:36.310 --> 02:42.150
We need to create an instance of the interpreter and pass the model buffer and the options null.

02:42.150 --> 02:47.630
You can create options like single using single thread to reduce memory.

02:47.830 --> 02:48.470
If we.

02:48.750 --> 02:55.030
If we encounter memory leaks, we're going to use the single thread for the interpreter.

02:55.310 --> 02:55.910
Okay.

02:55.950 --> 02:58.590
Let me continue with the state.

02:58.590 --> 03:02.870
And here the input tensor equals to interpreter dot.

03:02.870 --> 03:08.110
Get input tensors that input shape and the input data type.

03:08.350 --> 03:09.670
It's good for now.

03:09.870 --> 03:18.030
Scroll down to the Loadmodel function, loading the model from assets and returning it as Bytebuffer.

03:18.190 --> 03:23.510
Actually we don't need to do any any, any any update.

03:23.750 --> 03:26.150
So I keep it the same.

03:26.310 --> 03:30.190
Go to load labels similar to what we've done before.

03:30.230 --> 03:38.390
It's used for reading a text file from the assets, and returns its content as a list of strings or

03:38.430 --> 03:39.030
lines.

03:39.150 --> 03:45.590
And since we have only one label, you can return not a list of detection.

03:45.630 --> 03:49.550
It can be a string, but for later use.

03:49.550 --> 03:50.710
Maybe your.

03:50.910 --> 03:59.670
You are detecting custom objects like five, six, ten, 80 or 100, so keep it as a list.

03:59.710 --> 04:02.390
Okay, we don't need to do anything with it.

04:02.430 --> 04:04.030
Build analyzer.

04:04.150 --> 04:09.220
Here we have the object detector as we lectured before about it.

04:09.260 --> 04:15.860
We have four parameters the interpreter, the labels result view, and the listener set the list.

04:15.860 --> 04:22.460
Also, the function that we created before to update a live data object with new object detection results

04:22.700 --> 04:29.100
and the update parameters optional if you want to control the sensitivity and detection threshold of

04:29.140 --> 04:30.340
the detector.

04:30.460 --> 04:34.700
Okay, now let's move to the detection screen.

04:34.700 --> 04:36.540
We need to check it.

04:36.540 --> 04:43.020
By the way if you want to add more colors here for your list, you can add it.

04:43.060 --> 04:48.740
If you detect more than 5 or 6 objects you can add them more colors.

04:48.740 --> 04:51.260
Scroll down ViewModel initialize.

04:51.300 --> 04:53.780
This is the the very important step.

04:53.940 --> 04:54.900
Then the scaffold.

04:54.900 --> 05:02.420
Inside the scaffold, we need to initialize the camera permission wrapper and then when state equals

05:02.420 --> 05:06.100
to ViewModel dot initial state dot value.

05:06.140 --> 05:06.980
If it is.

05:07.060 --> 05:13.380
if it is success or if it is loading or it's a failure, go and do the following.

05:13.420 --> 05:17.380
If it is loading, go and display circular progress indicator.

05:17.380 --> 05:25.020
If the success, go and execute this code or if it's failed, go and execute this text.

05:25.060 --> 05:25.540
Okay.

05:25.580 --> 05:27.340
It's very very simple.

05:27.340 --> 05:30.180
And we talked about this in the previous videos.

05:30.180 --> 05:36.860
So there's no need to do anything or update any code here inside this detection screen.

05:36.860 --> 05:39.900
Now let's move to the object detector.

05:39.900 --> 05:42.540
This is the core of our application.

05:42.740 --> 05:45.780
We need to change some some codes.

05:45.780 --> 05:56.340
So whenever you change or get any different object shape or a different model shape input or output,

05:56.340 --> 05:58.500
you should update this class.

05:58.500 --> 06:01.980
This is the most important class to update.
