WEBVTT

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

00:01.080 --> 00:03.520
We finished the object detector class.

00:03.520 --> 00:06.680
Now let's create the view model.

00:06.680 --> 00:14.400
Inside this package, create a new package called View Model and inside it create a new Kotlin class.

00:14.400 --> 00:18.200
Name it as Detection View model.

00:18.240 --> 00:25.880
If you remember, we added Hilt Dependency Injection library to our Gradle file.

00:26.120 --> 00:30.440
So we're going to use here to do the dependency injection.

00:30.440 --> 00:37.080
And as we learned before the view model will be marked as hilt view model.

00:37.120 --> 00:44.000
Please go back to the dependency injection section in order to learn more about the hilt view model.

00:44.040 --> 00:54.720
Also we need to inject the constructor with inject annotation and here we need the private val context

00:54.720 --> 01:03.560
context and this dependency can be provided by hilt by using another annotation called Application Context,

01:03.560 --> 01:10.280
and to tell Android Studio that this class will act as a ViewModel, we need to extend from ViewModel.

01:10.320 --> 01:19.040
Now let's create a companion object, which is which is containing the constants that we need to use

01:19.040 --> 01:20.600
companion object.

01:20.600 --> 01:27.240
And here let me start with the constant val tag equals to tag.

01:27.440 --> 01:28.480
This is for luck.

01:28.520 --> 01:33.520
Also we need to add the model file name and label file name.

01:33.560 --> 01:44.200
Let's start with constant val model file name and the constant val label file name.

01:44.200 --> 01:52.400
Let's add the model that we, uh, we downloaded from SSD MobileNet and from Kaggle website.

01:52.440 --> 01:54.080
To add it, it's very simple.

01:54.080 --> 02:00.280
Inside this app, create a new other TensorFlow Lite model.

02:00.400 --> 02:03.670
Click on it, Locate your model.

02:03.990 --> 02:06.590
Select the flight automatically.

02:06.630 --> 02:09.590
Add build feature and dependencies to build your Gradle.

02:09.630 --> 02:12.430
Keep it like this and click finish.

02:12.470 --> 02:17.430
Wait for Android Studio to add the model to the ML file and folder.

02:17.430 --> 02:18.830
And this is our model.

02:19.030 --> 02:28.630
If you notice that we have an int array of one 300 303, data type is unsigned integer eight.

02:28.870 --> 02:29.430
Okay.

02:29.470 --> 02:32.590
We talked about the shape of our model.

02:32.790 --> 02:36.630
And this is just a confirmation of the inputs shapes.

02:36.670 --> 02:37.070
Okay.

02:37.110 --> 02:38.390
So this is our model.

02:38.430 --> 02:43.750
Add it inside the ML package that is created by Android Studio.

02:43.830 --> 02:46.870
The second step is the label file.

02:47.070 --> 02:52.830
Go to Google search for download Coco dataset labels version one dot txt.

02:52.910 --> 02:55.150
Here we have the annotations.

02:55.150 --> 02:57.830
The train 2017.

02:57.870 --> 02:58.710
It's similar.

02:59.070 --> 03:07.550
You can go to Coco dataset to download the whole data sets, but there are a lot of libraries that provide

03:07.550 --> 03:08.750
you with the labels.

03:08.750 --> 03:10.150
You can go to GitHub.

03:10.190 --> 03:13.430
Me leave labels.

03:13.470 --> 03:22.590
I clicked on this repository and you can download the Coco labels 2014 2017.

03:22.630 --> 03:24.150
Those are the labels.

03:24.270 --> 03:30.310
Copy them or you can download them as a row like this copy.

03:30.550 --> 03:33.910
And here we need to create the text file.

03:33.910 --> 03:36.390
Create a new text document.

03:36.430 --> 03:44.230
Name it as Coco data, set labels, open it and paste those labels.

03:44.230 --> 03:45.510
Click save.

03:45.630 --> 03:46.790
And here we go.

03:46.830 --> 03:49.030
This is the Coco data set labels.

03:49.030 --> 03:54.510
Let's go to Android Studio and copy this file into the folder.

03:54.590 --> 03:56.430
Paste and click okay.

03:56.550 --> 04:02.740
Those are the labels starting from person and ending with tooth brush.

04:02.780 --> 04:06.540
Okay, now let's add the model file name.

04:06.540 --> 04:15.140
Here we have, uh, the Coco data set labels and mobile as the SSD MobileNet version one Tflite.

04:15.180 --> 04:19.620
Please pay attention for the name so it's case sensitive.

04:19.860 --> 04:25.780
It's called SSD underscore MobileNet underscore version one TF Lite.

04:25.820 --> 04:29.380
Make sure that it is um highlighted by green.

04:29.380 --> 04:31.860
So you hit the correct file.

04:31.860 --> 04:35.060
Then use the label file name.

04:35.220 --> 04:37.700
The label file name is Coco.

04:37.740 --> 04:40.380
This is the name Coco.

04:40.420 --> 04:46.180
Underscore data set underscore labels dot txt okay.

04:46.380 --> 04:52.420
It's highlighted by green and it's hitting the correct file okay.

04:52.460 --> 05:00.060
In this way we added the SSD mobile version one tflite file and the Coco dataset labels.
