Image classification with ONNX, .Net and MAUI
My Repo: Here
Microsoft Example Repo: Here
I'm quite sure, like me, many people think that ALL artificial intelligence is "impossibly" resource intensive for computers and then default to giving up on the idea of its viability and usability on smaller edge devices like cellphones. But with ONNX, it's entirely possible.
Download the repository provided, you could use the original repository provided by Microsoft, but mine uses the Camera view component so, just a slight improvement so that you don't have to capture an image in the native camera - tapping the live viewfinder will produce the results. Mine is less perfect, but it drives the point home.
This model is trained on 1000+ images for classification, I have not personally gotten the hang of on device training as detailed in this episode by Baiju Meswani (again these videos and developers are massively underrated). I will get it shortly though and when I do I'll provide some useful insights and a more simplified tutorial on how to go about it.
Maui Camera View
The community toolkit contains a camera view component that makes having the live viewfinder a possibility for this project.
Gerald Versluis has a super detailed video tutorial for the instalation and usage of this amazingly useful component. If you haven't heard of him before you stumbled onto me, you're missing out!
Building
Using Visual Studio 2022, the latest version should have what you need, however the MAUI workload should be installed. See here for more information.
If you get any errors during building about missing platform workloads a simple way to resolve is to open a terminal from Visual Studio 2022 (View->Terminal) and run the command:
dotnet workload restore
Thank you to Microsoft for open sourcing this and providing sample code for us to remain relevant in our fields, so much fun to play with! Mike Parker and his team, legends at what you do. Watch the stand up here, more human beings need to watch these!
Subscribe to my newsletter
Read articles from Kevin Loggenberg directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Kevin Loggenberg
Kevin Loggenberg
With an unwavering passion for metrics and an innate talent for problem-solving, I possess a wealth of experience as a seasoned full-stack developer. Over the course of my extensive tenure in software development, I have honed my skills and cultivated a deep understanding of the intricacies involved in solving complex challenges. Also, I like AI.