Lesson nine project for people counting with ultrasonic sensor, specifically for model training and
development as compared to fully connected layers, convolutional layers save a lot of time and money.
However, when the amount of data grows.
For example, when we do inference on a high resolution image or longer time series data training,
a deep convolutional network still takes a lot of computing power.
Another problem with models that only use convolutional layers is that during training, the model also
learns the location of features, which is not what we want.
A cat is still a cat.
No matter where it is in the image, we can apply downsampling during model training to solve both problems
at once, which will reduce the number of connections and the size of the model and let the model learn
the features regardless of where they are in the data.
We can add pooling layers between convolutional layers, max pooling, mean pooling and average cooling.
Pooling is the process of choosing pooling operation, which is like a filter for feature maps because
the pooling operations and filters are smaller than the feature map.
They are almost 22 pixels applied with a strike of two pixels, which is about the same size as the
feature map.
So basically, this means that the pooling layer is going to cut the size of each feature map by a factor
of two.
For example, the number of pixels or values will be cut in half for each feature map.
The result of applying a layer called bullying to a feature map of four by four or 16 pixels will be
pulled feature map with two by two steel 16 pixels as the result of four pixels.
See how the average bullying operation works on four by four.
Matrix When using convolutional layers in edge impulse, iMac's pooling layer is automatically applied
after convolutional layer.
You can delete it or change its parameters if switching to expect nodes.
When training a model, think for expansion, but make sure you have lifeI libraries installed in Arkadelphia
trim.
Where is the latest version of Real Terminal?
You also need to download the following libraries from the GitHub.
The following links are here and the slides you may just copy.
Paste them or click on that.
Then make sure to install the file libraries using Arduino Library Manager for Pub Sub Client and message
back.
Now for Practice Mode When you're done with data collection, create your impulse set window length
to one thousand five hundred millisecond and window size increase to 500 milliseconds.
1500 millisecond is more than enough time for a person to walk in or out of a door unless they move
very slowly.
During this type, we only have two blocks to play with real data or spectral analysis, both of which
we can try.
Flatten blocks will remove all of the time domain information from the data, so we won't use it to
figure out where we are going.
Applying a fast for your transformed data samples The spectral analysis block moves from signal from
the time domain into the frequency domain.
With me use the FFO, we don't have to worry about the frequency of the signal.
We can't tell if a person is coming in or leaving the room based on the frequency of the signal.
You can see this in the data visualization after the spectral analysis block.
It's hard to tell in and out data samples from each other actually changing the process.
Napoli spectrogram doesn't really help.
The best we could get was seventy nine point six, but there was a lot of confusion between in and out.
In this case, the winner is raw data based on scale, plus one the convolutional network again as before.
You will need to switch to expert mode and change all one strikes to one and pulsates to four.
This will help you get ninety two percent of the time, right?
Do you think ninety two percent accuracy is already good enough?
If not, what can be done to improve it?
Ninety two percent is fairly good as proof of concept or prototype, but horrible as a production model
for production, mileage may vary.
If your application is critical in somehow using an automated control and decision making, you don't
really want to have anything below 98 to 99 percent, right?
And even that might be low.
Think about something like a face recognition system for payment or authentication.
Do you think there are ways to improve that?
You see of this system, ultrasonic sensor is cheap and ubiquitous sensor, but it is relatively slow
and not very precise.
We can get better idea by using the Grilles ATF mini lidar module, get more data and possibly at least
a sensor lower at normal human waste level to make sure it can detect shorter than normal height people
and children.
Two are better than one.
Having two sensors taking measurements at slightly different places will not add too much data.
We only have one data point in each sample, but might increase the accuracy to explore more interesting
ideas.
A built in light sensor can be used if we are terminal is appropriately located.
Now, once the model is trained, we can perform life classification with data from device here.
We found that with the size increase of 500 millisecond actually doesn't work that well and produces
more false positives.
So the next step when deploying to the device, it is better to increase the value to 750 millisecond
and to deploy the model to real terminal.
Make sure to go to a deployment tab.
Choose the Arduino Library downloaded, extract the archive and put it inside of your Adrenals Libraries
folder.
The next this time, we will be using continuous inference example to make sure we are not using any
important data.
If you remember in the first lesson the course for the inference we would collect all the data points
in the sample, right?
Perform the inference and then go back to sampling.
That means when feeding the data to a neural network, we will post a data collection and lose some
of the data.
Now that is not optimal, we can use either dMY the direct memory, access, threading or multiprocessing
to fix this issue.
In this case, we will use the free Artiols and threads because the real terminal MCU or the cortex
and 4-F core has only one core.
People who use the free artless are going to stop friends for a short time, get the data sample and
then go back to inference again, which is what is going to happen this way.
The real inference will take a little longer, but difference isn't that big for the use case.
Every 500 millisecond we do in stress, so every 500 milliseconds slice off the time we know we'll be
done in France on three times.
This is how it works.
We look at three inferences and we choose the one with the most confidence.
For example, if we have the most confidence in a label that reads out, we'll use that label to make
the testing easier.
We will add the lines that turn on the real terminal screen when someone comes into the room and turn
it off when someone lives.
Now, open examples search for name of your project and then look for nano underscore.
B 33 underscore a sense underscore accelerometer, underscore continuous sketch and replace everything,
including the run inference background, which is the function declaration now above setup function,
which is the following code block, as you can see on the side of the screen.
And then in setup function, make sure to initialize the LCD screen and delete all the lines that are
related to accelerometer, then in place of interference underscore threat, that story based the following
code block.
The reason we need to replace this line is because threat initialization is done differently and arguing
obviously 33 cents and real terminology.
That's why.
So here so you can see we have already changed the following code on this slide.
OK, now proceeding to the next line.
Run interference, continuous function is largely unchanged.
The only two things that needs to be change here are these following codes, so make sure you can copy
them.
Now the line above controls averaging or smoothing parameters that we apply to output of the model.
You can experiment with the values to see what values allow for best performance in terms of true positives
or false positives.
Three.
Well, in the original code, the data collection happens in loop function, or we determine all the
free ideal exploit.
It is better to implement data collection in a thread and leave the loop function empty.
Delete the loop function in original code and replace it with the following code block.
A sensor called an ultrasonic sensor is used to measure the distance between two objects.
The sensor then copies the data to a buffer that can be used for free.
Take note that because there are so many threads, taking too long to read here doesn't affect the whole
system.
It just temporarily pauses each thread until it's time to start another one.
The free artioles can run other tasks, while the data collection thread is it running?
No expansion task.
Now the model works, but again, all in by itself, it's not suitable for actually applying it in the
real world.
Now, let's add two elements to make it into a full fledged application, which are a simple job.
I need to upload the cloud with pretty graphs.
We will use the LG G L Library for creating graphical interface and Microsoft Azure IoT Central Service
for sending data to and visualization.
Now, the resulting sketch is 693 lines long and has three concurrent threads run in our.
Here is a quick recap of the steps you need to make it work with iOttie John.
First is that you need to find a project in the course materials under the name Rio Terminal as the
Central Dot is not, and then open it in Arduino IDG after the sketches uploaded and their configuration
mode by pressing three buttons on top of the wheel terminal and resetting the device in configuration
mode will be displayed on device screen.
Connect to device with serial monitor with a board rate of 150 200 carriage return and set Wi-Fi Assist,
ID password and Asura with essential credentials in the following format of this light.
You can see here and then right after following this format.
Follow this next steps Go to this website and then if you don't have a Microsoft account yet, make
sure to register one.
Go to Bill, look for a custom app and then enter the app name and unique.
You are l choose free plan after an app is created.
Go to the device templates.
Make a new template of iottie device type, then choose a custom model.
Add three capabilities as a below screenshot and two interfaces.
Make sure to press and use that.
Look for visualizing the device after finishing that and making sure everything is correct.
You can now publish the template.
Create a new device from template by going to devices, pressing the new remember to choose the template
you just created and published.
Get the ideas, quotes from administration and then proceed to device connection.
Primary key from administration.
Then look for device connection after that.
Look for SAS IoT devices and device ideas from Devices tab where you just created your device on Step
five.
Here is the following result when following the steps that was mentioned earlier and then after configuration
is successful, restart your terminal and it will start connecting to Azure IoT, etc..
You can watch the detailed progress feedback on the serial terminal.
You will then be able to see a device that was on dashboard that is changed to provision telemetry data
from accelerometer sensor in device that received the raw data.
Now when we finish, we add the parts that makes the edge impulse model ready and send telemetry functions
work.
We also change the descent telemetry function to send the number of people who came in left and a total
of number of people in the room.
We also add a simple UI with three buttons and a text field that shows information changes.
You can see the sketch by opening Real Terminal and people counting as their central LV guide.
That includes some other course materials.
But don't forget the understudies, OK?
The hardest part was making sure that.
Work normally in each separate thread and did not affect other things, which I believe is a lot of
work.
The sacrifices had to be made so that the court didn't get too complicated.
For example, the Alvin G l Dash app, the expulsion was put right after interface updates and not run
every time.