Object detection on Raspberry PI using customvision.ai/.NET 5 - ml.net

We have written a x-plat worker service using .NET 5 that is running on a Raspberry PI 4 (Raspberry Pi OS). We have trained a custom vision object detection model on customvision.ai, exported it to ONNX and it all works well on Windows.
We are now struggling to get it running on the Pi. The ML.NET bits does not seem to work on the Pi. We're getting (with target runtime "linux-arm"):
Microsoft.ML currently supports 'x64' and 'x86' processor architectures. Please ensure your application is targeting 'x64' or 'x86'
We've searched hi and low for any working examples. We've also tried to export to Tensorflow format and explore Tensorflow.NET without any success.
Can anyone point to an example that is consuming a customvision.ai generated model in .NET Core/5 on a Raspberry PI? We are extending an existing prototype and would like to avoid rewriting it all in Python/C++ or create out of process calls.
Versions: ML.NET 1.6, Microsoft.ML.OnnxRuntime 1.8.1
Many thanks,
Mansos

Just incase someone else lands here...
The release ML.Net NuGets (mid Dec 2021) now have support for linux-aarch64, linux-arm, linux-arm64, Windows-x64 etc.
If you're still interested I have have a couple of blog posts about my "learning journey" getting a pretrained ONNX model working on RPI4B + Bullseye and ASUS PE100A + Ubuntu
#KiwiBryn

Are you running an Uno Platform app to capture a picture from the camera module (or usb webcam) in your Pi4 and running ML.Net too?

Related

How to program with C++ API library on Windows using Bazel?

What I want to do
First of all, my goal is using Tensorflow C++ API as a library on Windows, which is part of my project, instead of building my project inside Tensorflow.
Background
I had achieved this by building Tensorflow with CMake. However, from Tensorflow 1.10, building with CMake was deprecated and Bazel is recommended instead. But the official way to use C++ API is building project inside Tensorflow with Bazel. Thus, this way is not good for me.
What I have done
To use a newer version of Tensorflow, I have been trying to build Tensorflow with Bazel as a standalone library.
Some maintainer denoted that it is possible by substituting //tensorflow/tools/pip_package:build_pip_package to //tensorflow:libtensorflow_cc.so in the official tutorial. But in fact I encountered some problems and solved them by reading this tutorial. Now I have successfully built libtensorflow_cc.so.
What the problem is
However, I have no idea what should be done next to use the built result. And it is exactly what my problem is. There is no documentation of course. Only some incomplete ideas on it I have found, and I will show all of them, trying to give you more information:
There is somebody already successfully linking built *.so and having solved the problems he has encountered.
There is a repo doing the what I want to do on Ubuntu and Arch Linux. I have contacted with the maintainer and he told me that they have no plan for supporting Windows now.
A related issue: Building a .dll on Windows.
A related issue: Packaged TensorFlow C++ library for bazel-independent use.
A related issue: Feature request: provide a means to configure, build, and install that includes cc.
A related question: How to build and use Google TensorFlow C++ api. The scope of this question is a little larger without 'using bazel' and 'on Windows' restrictions.
A related pull request: C++ API
There must be someone struggling with similar problems like me. I hope this question can build a reservoir of ways to solve the problem.
It's over 2 years since this question was asked, and the news is not good: it seems there are insufficient people with Windows skills in a position to provide the support to integrate Tensorflow into Windows applications using the familiar headers + library model. And Tensorflow advances week by week, meaning that the Windows support falls further behind.
In my assessment, the path to building on Windows is currently blocked due to inadequate documentation. It's not so much that "There is no documentation of course" as the OP asserts, it's that the sparse documentation is distributed throughout dozens of separate posts, each of which dates rapidly with the continuing development of the Tensorflow along paths other than Windows C++.
I originally gave this answer to a similar question, but updated it with advice along the following lines yesterday:
Windows is a Microsoft product, so watch what Microsoft is doing
Hint: Microsoft is investing in the ONNX format
you can convert Tensorflow to ONNX, or Keras to ONNX
You can implement your (ONNX) model on Windows in C++ in at least 3 ways:
Windows ML (uses Onnx runtime)
Onnx runtime (supports DirectML as an execution provider)
DirectML (how Microsoft uses graphics cards to boost performance)
We don't have the latest or best hardware (e.g. we have Intel graphics cards), but have been able to get a solution based on Onnx runtime that classifies 224 x 224 RGB images in about 20 milliseconds for us. We found the Windows ML path much more difficult to work with legacy code, and also slower to run.

How can I use Amharic font in Qt user interface?

I am working on an academic project, as part of which I am developing an application that will run on Raspberry Pi (installed with Raspbian Jessy). I am using Qt to create UI for the application that will run on the Raspberry Pi.
I am trying to internationalize the application mentioned above. As part of the localization, Amharic is one of the languages I am working on. Unfortunately, Amharic is not fully supported in the internationalization process by Qt based on the following links below:
http://doc.qt.io/qt-4.8/internationalization.html
http://doc.qt.io/qt-5/internationalization.html
Considering this limitation how can I manage to find an alternative solution to use the Keyman AbysinicalSIL-R.ttf font in my application running on Raspberry pi?

TBB Intel Threading Building Blocks for Raspberry Pi 3

So I am trying to compile Intel's TBB C++ library which enables parallelisms in programs. I am particularly needing this to use C++ React, which is a library which provides reactive library (e.g. asynchronous loops) for a project I am doing.
I have figured out how to compile it for Raspberry Pi 2. But my problem is that the guides I have seen have only updated for the ARM-7a architecture.
Currently, when I try to make a build which uses TBB as a dependency, I get this error:
In file included from /home/pi/tbb43_20150611oss/include/tbb/tbb_machine.h:247:0,
from /home/pi/tbb43_20150611oss/include/tbb/task.h:25,
from /home/pi/tbb43_20150611oss/include/tbb/task_group.h:24,
from /home/pi/cpp.react-master/include/react/engine/PulsecountEngine.h:18,
from /home/pi/cpp.react-master/src/engine/PulsecountEngine.cpp:7:
/home/pi/tbb43_20150611oss/include/tbb/machine/gcc_armv7.h:31:2: error: #error compilation requires an ARMv7-a architecture.
#error compilation requires an ARMv7-a architecture.
I just want to know how I can port TBB to work on ARM-53 for the new Raspberry Pi.
An easy solution such as replacing _ARM_ARCH_7A_ in gcc_arm7.h would be nice, but how do people go about porting TBB for other architectures?
Thank you
If you want to contribute to TBB (e.g. to port it for some other architecture), you can go to "submit contribution" page on the open source site and send your patch.
To port TBB on ARMv8, you have at least several options:
If ARMv8 and ARMv7 are very similar, you can try to extend the check on line 30 in gcc_arm7.h to work with ARMv8;
If ARMv8 and ARMv7 are quite different, you can create gcc_arm8.h (or gcc_arm with support v7 and v8) and improve the logic in tbb_machine.h near lines 246-248;
Theoretically, if gcc on ARMv8 supports built-in atomics, you can use gcc_generic.h on ARMv8 (see tbb_machine.h:249)
It looks like that you do not need to improve make files but I'd recommend running make test to be sure that modified TBB works correctly on your system.
[UPDATE] TBB has been ported to ARMv8 since version 2018 U5.
Latest update August 2018,
Check out my git: https://github.com/abhiTronix/TBB_Raspberry_pi
Latest binary (2018 - Update 4) of TBB for the Raspberry Pi exclusively for Raspberry Pi (.deb) file
compiled for a Raspberry Pi 2/3 Model B/B+ running Raspbian Stretch.
Enjoy ;)

Driver, 32-bit in arm.

I'm do a project to control a gpib-usb converter from national instruments. I will run the app on raspberry pi 2 using a windows 10 iot core. On this configuration, is only possible to do a universal app to run. That's what i do.
The library is in c/c++, so comes with a gpib-32.obj.
Here is the trouble, when i compile my universal app on raspberry pi, give me the error Error LNK1112 module machine type 'X86' conflicts with target machine type 'ARM'.
There is somehow i can do this app run? If i delete this file, the library don't work.
regards, vitor.
Your choices are to either recompile the library from the source code using the gcc that's on the raspberry pi or use C#.
When using the raspberry pi, I use the debian (raspbian) linux build. I researched the windows 10 for raspberry pi and found it to be a cruel joke intended to sabotage the raspberry pi project.
I have good luck running mono on the raspberry pi to get c# programs running without recompiling the program for the raspberry pi.
I hope this guides you in the right direction.

Serial Communication in OpenCV

I am building an application involving identification of color of object and then sorting it with the help of a robotic hand manipulator. The code for Color Identification is ready in OpenCV, what I do not know is how to transfer this data to my Arduino UNO board connected by USB. I have made this kind of application previously in MATLAB, but have no idea how to do it in OpenCV. Do we have any way to send data over Serial port in OpenCV?
Have you considered using OpenFrameworks? I personally haven't played around with OpenCV but I have played around with serial communications to arduinos on OF. OF also includes the OpenCV library so you can link your work with it.
Prerequisites :Install opencv with python bindings.I usually work on Mac Os.Its pretty easy installing opencv with python bindings on mac using macports.I have no idea about windows and linux but there is no shortage of tutorials to do so.Just google.
And about python,don't worry,You can learn a lot of python in 2 days.Google python classes are definitely a good start.
Check this out for different python opencv methods.And this is a good site for starting opencv with python