Code Monkey home page Code Monkey logo

hololens2-machine-learning's Introduction

HoloLens-2-Machine-Learning

Using the EfficientNetB0 model, trained on the ImageNet 1000 class dataset, for image classification. Model inference is run directly on the HoloLens 2 using its onboard CPU.

About

  • Optimal performance is achieved using version 19041 builds. In this sample I am using build 19041.1161 (Windows Holographic, version 20H2 - August 2021 Update) which can be downloaded from MSFT via the following link and installed using the Advanced Recovery Companion
  • Tested with Unity 2019.4 LTS, Visual Studio 2019, and the HoloLens 2
  • Building off of the WinMLExperiments sample from Rene Schulte
  • Input video frames of size (224, 224) for online inference
  • Pretrained TensorFlow-Keras implementation of the EfficientNetB0 framework was converted directly to ONNX format for use in this sample

Run sample

  • Open sample in Unity
  • Switch build platform to Universal Windows Platform, select HoloLens for target device, and ARM64 as the target platform
  • Build Visual Studio project and open .sln file
  • Copy the onnx-models\model.onnx file to the Builds\HoloLens-2-Machine-Learning\Assets folder
  • Import to Visual Studio project as an existing file, place in the assets folder
  • In the asset properties window (as below), confirm that the Content field has its boolean value set to True. This enables the ONNX model to be loaded at runtime from the Visual Studio assets folder

  • Build the sample in Release mode for ARM64 and deploy to the HoloLens 2 to test
  • Prediction labels are pulled from the parsed ImageNet labels .json file (which includes 1000 image net classes)
  • Output includes the predicted label, its associated probability and the inference time in milliseconds

Model conversion to ONNX

  • See sample conversion from official TensorFlow efficientnet weights to ONNX format in README file

hololens2-machine-learning's People

Contributors

doughtmw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hololens2-machine-learning's Issues

Parameter is incorrect when using own trained model

We trained our own model with one class using tensorflow 2.2 with keras and converted the model to .onnx by following your instructions. our model is trained with 1 class when we use this new model, in the hololens, this message appears " Error init. The Parameter is incorrect".
Could you let me know which parameter is incorrect ?

Thank you

Certificate expired

Hi,

I am encountering the following issue:

InvalidOperationException: Certificate Assets/WSATestCertificate.pfx is expired and cannot be used for a UWP build. To fix this, either delete it or select a different certificate in the player settings.

I also tried to create a certificate myself, which works, but when I want to run the sln file on visual studio, it says that the certificate is missing.

Is there any solution to this?

Thank you.

Issue with model.onnx

Good morning,
This project seems interesting.
I am trying to run the example but I am having some problems with the model.onnx file.
I followed the README instructions and added the file under Assets, but it gives me the error Error init: Unable to find the specified file.

The only thing I have different from your instructions is the absence of the icon next to the file and the absence of the Document field in the settings under File Type.

I don't know, maybe I'm missing something in the Visual Studio configuration?

I will add an images

Issue

Thank you very much

Issue with input size for WinML models

Hi Mitchell!

Just tried out your modified sample. BTW, love what you are doing here. 👍

I made sure the ONNX model is part of the assets and it can be loaded and the labels file but it still won't work. I don't have much time to debug it myself but see below exception which could be causing this. Maybe just a model update with the wrong dimensions or input binding name?

Exception thrown at 0x00007FF943D345FC (KernelBase.dll) in HoloLens-2-Machine-Learning.exe: WinRT originate error - 0x80070057 : 'Got invalid dimensions for input: input_2 for the following indices
 index: 0 Got: 1 Expected: 0
 Please fix either the inputs or the model.'.
Exception thrown at 0x00007FF943D345FC in HoloLens-2-Machine-Learning.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000010032FF280.

unity main camera scripts

Hello,

I’m interested about HoloLens2 and I want to try this project in Unity but main camera doesn’t have any scripts .
Can you guide me on this ?!
Which scripts I have to use?!

Thank you !

How to unproject a 2D point in an captured image back to its accurate location in the physical world?

Hi all,

I'm creating HoloLens2 software that detects corners in an image and then shows their actual location in the world. However, there may be slight deviations between the projected points and their actual location, which increase with distance from the user. As following figure shows.

image

Here's my code snippet for projecting the detected corners: I convert the corners from image to screen coordinates, then to NDC for unprojection. Next, I use the inverse of the projection matrix to convert the points from NDC to Camera space and then from Camera space to World space using the camera-to-world matrix. Finally, I instantiate the detected points using a Ray and RaycastHit.

image

For getting the cameraToWorldMatrix and projectionMatrix, i referred to XRIV work.

From my side, i guess it may be the reason that the depth information is not estimated properly or the value of cameraToWorldMatrix and projectionMatrix are not correct. However, i have made efforts on this two reasons, but failed.

May dear friends could give me some insights about how to mitigate this projecting devation, i show my great appreciation here in advance!

Error init: Unable to find the specified file

Deploy tensorflow model in Hololens 2. Sucessful deployment. But after opening application in Hololens2, display shows that "Error init: Unable to find the specified file". What should I do?

Error Init: Unable to find the specified file

Respected Sir,
I have followed the each and every step mentioned in the Github Sample
and after the Deployment into HL2, the application is not detecting the
sample Image provided. Could this be an issue due to the HL2 Build Version.
I am using a Higher Build 20348, Windows Holographic version 21H2.
I understand that the application is not getting access to the HL2 Camera too.
Is there any constraints to the size of the Image being displayed on the Screen?
Please do help me with this issue.
Sincerely,
Avinash Shanmugam

Image not getting predicted

Hi,

I have build the project and deployed into the HL2 device but when i scan the French bull dog the image which is there along with the project, its not scanning, rather it shows no probability and results even after 2 -3 mins.

I followed all the steps and added the .onx file into my visual studio before i take a build, still not able to solve this.

Can someone please tell me what exactly i am doing wrong ?

"Value does not fall within the expected range"

Hi, so I'm trying to deploy it with my onnx file on the hololens 2 but after I implement and open in hololens, Status blocked: "Value does not fall within the expected range" shows up and nothing happenes... do you know how to fix this problem? The only thing I made changed is just adding my onnx file to the asset folder.

Video Frame settings question.

Dear. Michell Doughty.
Hello. I ran the sample you uploaded. I distributed it to Hololens 2, and it works very well.
I just have a question. Is there a reason why you set the size of the video frame to (224, 224)?
To stare at the image hololens for verification, I have to stick close to the monitor.
Is this because of the size of the video frame? Can I increase the size of the video frame?
I look forward to hearing from you. Thank you.

Can't use custom ONNX file

I have tried to use several ONNX files to run in this example, but i am not able to. I am only able to run it with the one that is given i the repo. Any suggestions on what I could do to upload and use my own?

Object reference not set to an instance of an object

Hi,

We are using our own pre-trained model and we also replaced the labels.json file with our own. We are getting an error on hololens saying "Object reference not set to an instance of an object". Any help?

Thanks

Run on GPU

Hi, I want to run the model on GPU. I notice some annotating code about GPU in model.cs. I try to use that code, but it doesn't work. Would you help me with that? Thank you!

EfficientDet D0 how to run

Hi as the Efficientnet B0 is working in this code. I trained efficientDet D0 and i want to run that using your code to run in hololens. Could you please let me know is it possible to run EfficientDet D0 with your code ? If possible, then what changes I need to do in your code. I am trying to modify your code to run my EffcientDet model by visualizing my model using https://netron.app/. If you kindly provide your suggestions then it would be helpful for me.

Thank you

Running on GPU - Prediction not happening

Respected Sir,

Sorry to post with so many Questions. I tried to run the Application on GPU. It is way faster than Running on CPU
but when it is running on GPU, there seems to be no prediction happening and therefore the Text is not being rendered.
It would be really great if you could shed some light upon it. As per the documentation I understand that the session is being
created on the GPU for Evaluation, but should I also load the model in GPU? But upon running on GPU, the Predictions are not
happening. It would be great to have a reply

Detection vs Probablity Threshold

Respected Sir,

Sorry to post with many Questions. I just wanted to know some general Information in coding. What is the difference between Detection Threshold and Probablity Threshold? I tried adapting the codes to my own custom model which had 3 labels/Classes. Upon Detection sometimes I am getting predictions over 100 % and it takes too much of time to give a right Prediction and the probablity keeps changing very rapidly? Sometimes even when I dont look at the desired Image, there is always some Prediction happening rather than being null or no Predictions. I just wanted to know wheter this is all related to Probablity and Detection Thresholds. Are they both the same or different? How to determine an optimal probablity and Detection Thresholds? Please do provide me some Tips if possible.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.