Welcome back.
Maybe you are asking if we added the best Float16 model and the labels.
TXT file.
If we run the application may it will detect the objects directly.
Let's test and see.
Open the detection view model.
Just say that just update the model file name to best Float16 Tflite.
And you see it's highlighted in green.
So it detects the asset 6.18MB and labels dot txt.
Also it's being highlighted.
If we run the application now maybe it will run normally.
Let's test and see.
This is our app grant camera permissions while using.
And our application started but no detections.
If we put the battery no object is detected because we need to configure the shape of our model and
the tensors, the input and the output of our model.
Always remember that input here Float32 one 640 640 and three.
Also the output Float32 one five 8400.
Those are the parameters of the tensors that we're going to work on of our for our application and update
them in order to detect batteries.
Again guys, maybe if you have another object detection, maybe if you have two classes three, those
will be different.
So it's not mandatory to get one.
Five 8400.
So please pay attention to this note because every every model has its own sensors okay.
And tensors.
So inside this view model let me paste those nodes the input and the output in order to memorize them
well.
Okay.
Now scroll down here we need to the interpreter.
We have the state the parameters and the detection list.
Similar to what we've done before.
We created this initialize function for loading the model state labels.
Loads the labels and model Bytebuffer loads the model.
Then we need to pass.
We need to create an instance of the interpreter and pass the model buffer and the options null.
You can create options like single using single thread to reduce memory.
If we.
If we encounter memory leaks, we're going to use the single thread for the interpreter.
Okay.
Let me continue with the state.
And here the input tensor equals to interpreter dot.
Get input tensors that input shape and the input data type.
It's good for now.
Scroll down to the Loadmodel function, loading the model from assets and returning it as Bytebuffer.
Actually we don't need to do any any, any any update.
So I keep it the same.
Go to load labels similar to what we've done before.
It's used for reading a text file from the assets, and returns its content as a list of strings or
lines.
And since we have only one label, you can return not a list of detection.
It can be a string, but for later use.
Maybe your.
You are detecting custom objects like five, six, ten, 80 or 100, so keep it as a list.
Okay, we don't need to do anything with it.
Build analyzer.
Here we have the object detector as we lectured before about it.
We have four parameters the interpreter, the labels result view, and the listener set the list.
Also, the function that we created before to update a live data object with new object detection results
and the update parameters optional if you want to control the sensitivity and detection threshold of
the detector.
Okay, now let's move to the detection screen.
We need to check it.
By the way if you want to add more colors here for your list, you can add it.
If you detect more than 5 or 6 objects you can add them more colors.
Scroll down ViewModel initialize.
This is the the very important step.
Then the scaffold.
Inside the scaffold, we need to initialize the camera permission wrapper and then when state equals
to ViewModel dot initial state dot value.
If it is.
if it is success or if it is loading or it's a failure, go and do the following.
If it is loading, go and display circular progress indicator.
If the success, go and execute this code or if it's failed, go and execute this text.
Okay.
It's very very simple.
And we talked about this in the previous videos.
So there's no need to do anything or update any code here inside this detection screen.
Now let's move to the object detector.
This is the core of our application.
We need to change some some codes.
So whenever you change or get any different object shape or a different model shape input or output,
you should update this class.
This is the most important class to update.