During the next couple of months, I’ll be sharing some amazing experiences around AI. Some of these experiences includes IoT devices like a Raspberry Pi, and of course some Machine Learning.Net (ML.Net). Because ML.Net is built with .Net Core, it makes sense to share the 5 simple steps you need to do to install .Net Core in a Raspberry Pi.
my 1st try was to navigate to the official .Net page (see
references), which automatically detect my Linux distro and proposes a set of
completely sure that I’m working in a 32 bits environment, however I’ll double
check this with the following commands
sudo apt-get install lshw lshw
After installing lshw I confirm that I’m in a 32 bit environment
Bonus: lshw is a small tool to extract detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc. on DMI-capable x86 or IA-64 systems and on some PowerPC machines (PowerMac G4 is known to work).
Now I need to navigate to the download page to download the
specific Linux 32-bit version (see references).
Once I got the image downloaded its time to extract the file
on a specific folder. I’ve created a folder named “dotnet” with the following command
sudo mkdir -p dotnet
And to extract the image from the Downloads folder
sudo tar zxf dotnet-sdk-2.2.401-linux-arm.tar.gz -C
Let’s create a symbolic link to the extracted binaries
sudo ln -s /home/pi/dotnet/dotnet /usr/local/bin
And it’s done! Let’s invoke the .DotNet help command to test
Now we can follow the steps of [.NET Core on Raspberry Pi,
see references] to create a Console Application and to test the device.
To create a new console App
dotnet new console
And test the app
sudo dotnet run
We can publish the app for linux / raspberry pi
sudo dotnet publish -r linux-arm
And copy the generated folder to be used in another device
So next steps will be some other tests with Raspberry Pi and
.Net Core. And the following image is a big teaser of this
A couple of
days ago I wrote (a personal reminder post) about how to add automatic connect
to Wi-Fi and SSH enabled in a bootable Raspbian image in a SD card (see references).
I also explained that this was required for me because, by default Raspberry Pi
4 video ports were not starting with a 1920 x 1080p resolution.
Remember that now, the 2 video ports supports 4K !
I was digging and reading about this, and I found another quick fix to solve this problem. Once you had a Raspbian image in a SD card, you can edit the file [config.txt] for some amazing cool tweaks! (Also, see references)
For me, my main change was in the [hdmi_safe] parameter. Setting hdmi_safe to 1 will lead to “safe mode” settings being used to try to boot with maximum HDMI compatibility.
# uncomment if you get no picture on HDMI for a default "safe" mode hdmi_safe=1
the device will start automatically in a safe and standard mode. And, yes, it
will work with my old and crappy test monitor!
Now that I
have my amazing Raspberry Pi 4 with 4GB RAM, it’s time to see how serious the
device is. So, I decided to install and use some developers’ tools in the RPi. My
dev list will be something like this
Some ML and AI Python packages
Visual Studio Code
It’s been a while since I installed VSCode in the device. The last time I did this, I needed to download the code from GitHub and compile the tool in the Raspberry Pi. As far as I remember this was a +25 min process.
Lucky for us the process can now be much simpler, thanks to Headmelted
(see references). Now, we only need a single command to install VSCode:
Install process started! Or Maybe not because I found this
amazing GPG error
pi@rpidev3:~ $ curl -L https://code.headmelted.com/installers/apt.sh | sudo bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2349 0 2349 0 0 19739 0 --:--:-- --:--:-- --:--:-- 19906 Detecting architecture… Ensuring curl is installed Reading package lists… Done Building dependency tree Reading state information… Done curl is already the newest version (7.64.0-4). The following packages were automatically installed and are no longer required: python3-pyperclip python3-thonny rpi.gpio-common Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Architecture detected as armv7l… Retrieving GPG key headmelted… % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 gpg: no valid OpenPGP data found. Removing any previous entry to headmelted repository Installing [headmelted] repository… Updating APT cache… Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease Hit:2 http://archive.raspberrypi.org/debian buster InRelease Get:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease [23.4 kB] Err:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8 Reading package lists… W: GPG error: https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8 E: The repository 'https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease' is not signed. Done! Repository install complete. Installing Visual Studio Code from [stretch]… Reading package lists… Done E: The value 'stretch' is invalid for APT::Default-Release as such a release is not available in the sources Visual Studio Code install failed.
There a public GPG key used to verify the package and the SH
script somehow does not download it (I think the ARM RPI version is still not
defined). So, before the previous command, I need to run this command
But, yes another but, you may note that the tool open and
display a black window. Again, I need to go deeper on the details, but the
latest version does not work well. There is some context information on GitHub
(see references), and the proposed solution is to rollback to a previous
sudo apt-get install code-oss=1.29.0-1539702286
And we also need to disable the automatic updates on this
sudo apt-mark hold code-oss
And now, yes, we got a fully functional Visual Studio Code
in our Raspberry Pi!
to do some tests with the new Raspberry Pi 4 and the results are amazing. I’m
not a performance expert, so I decided to pick up some of the demos / apps I’ve
creating for the Raspberry Pi and run them in both models: Raspberry Pi 3 B+ and
Raspberry Pi 4.
I started with an amazing set of tutorials on how to perform Face Recognition from Adrian Rosebrock (see references). I’ve been using his Face Recognition python package for this scenarios and it’s an amazing one.
I added some code to a custom version of Adrian’s Face Recognition sample, and it looks great. The main idea was to track in real-time the current FPS (similar to the work I did with the Image AI and Hololens sample a couple of days ago, see references).
load a file with 15 trained faces and analyze frame by frame to
Detect faces in the frame.
If a face is detected, draw a frame around it.
For each detected frame analyze if the face is a trained face.
If the face is part of the trained dataset, the app will add the name of the person on top of the frame.
I display in real-time the FPS processed with a USB camera in a Raspberry Pi 3 B+. Doing a lot of tweaks and getting the best performance in the device I could never process 1FPS. The average processing data were between 0.6 and 0.9 FPS in a Raspberry Pi 3B+.
IMHO, these results are great for a small device like a Raspberry Pi 3B+. But now it was time to test it in the new Raspberry Pi 4. And an important note here is to remark that even if I did this tests in a Raspberry Pi 4 with 4GB of Rams, the performance results are similar to a RPI4 with just 1 GB of ram. We have more memory, however the processor improvements are quite significant in the new version.
I installed all the necessary software in the Raspberry Pi 4 and I got 3X better results. I’ve even tun this in a 1080p resolution to get a sense of the real processing time. The average processing data were between 2.3 and 2.4 FPS in a Raspberry Pi 4.
this scenario the Raspberry Pi 4 is almost 3 times faster than the Raspberry Pi
3. And again, these are amazing times for a 50USD device.
I’ll write this down, so I don’t forget in the near future. I’m not a Linux user, and that’s amazing. Every day I learn something new, mostly while I’m working with Python, Visual Studio Code and Raspberry Pi.
So, I received a couple of brand new Raspberry Pi 4, and now it’s time to test them. And of course, most of this job is via SSH / command line. I’m not an expert (yet) on Raspberry Pi user permissions, however I started to realize when I need to use “sudo” to get things done.
If you search for sudo definition, you may find something similar to this one:
Sudo stands for either “substitute user do” or “super user do” (depending upon how you want to look at it)
Today, I’ve learned the power of the “alias” command, and how it can be used to have a more polite conversation with my device. In example, I can create an alias for sudo, named “please” and then this happen.
This is a very polite way to display my Raspberry Pi4 CPU information
Or another polite way to display Disk information for the Raspberry Pi 4
After an amazing weekend, where I split my time supporting 2 different hackathons, today big news is the announcement of the new Raspberry Pi 4.
Did you check the news?
64-bit Quad-Core ARM Cortex-A72 processor, with a core clock speed of 1.5GHz
1GB, 2GB or 4GB of RAM
2 4K HDMI displays
starting price at $35
and much more !
I won’t get deep in details, I prefer to share some really good reviews, later i this post. Now is time to wait until the 4GB model is available in Canada and I’ll do some update on my Custom Vision docker and Machine Learning performance posts with the new device!