Computer vision inference in C# with ONNX Runtime!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we are going to look at how you can use c sharp for inferencing with resnet 50. first we're going to go over to onyxruntime.ai tutorials from there we're going to click api basics we're going to jump to c sharp and then we're going to click on the image recognition with resnet 50. so this also has all of the source code available in our onyx runtime c-sharp samples and additionally we have it available in a template as well so if you go to onyx runtime dash c-sharp cv dash template you can also get started quickly by you doing use this template and start working right in your repo so let's take a look at what is made up of this particular example so the first thing is we have some prerequisites you're going to need the model from the onyx model zoo you're gonna need at least.net core 3.1 or higher and then it says download this picture of a dog which you can but also it is available in the source in github and in the template as well so one of the hard parts when you are starting to do different pre-processing in languages that aren't python or aren't used heavily for data science is finding different libraries to help you do the pre-processing that you need in order to reshape your image or pre-process it whatever kind of pre-processing you need this is a good library for handling all the different types of transformations you'll need for your data for processing once we have our image into our rgb24 type then we are going to need to resize if you take a look here you can see that um we're using image.mutate we are using resize and then we are setting it to the 224x224 which is what we need for the resnet model your model may be something different or may need a different shape so just to keep that in mind and now that we have our image and we've resized it it's time to turn it into a tensor uh so we are going to be using the dense tensor object that is part of the onyx runtime library and we are going to be pre-processing based on the requirements of the model so if we go take a look at the model zoo this gives us some information about what the input is that is needed for our model so you can see that we were able to take the mean and standard deviation that was used to normalize and process their data within python and now we are just applying that in a c-sharp format next we're going to create the inputs for the model so from here we need the named onyx value which is a class from our onyx runtime library we're going to create from tensor we're going to give it the input label which is data for this model and then also our input data that we just created so our tensor that we just created we're going to start an inference session with the model path and then we're going to run that inference session we're going to get back our results we're going to get the soft max in this lambda you can see we're creating a new prediction object that is the label and the confidence then we're order by descending to get our highest confidence at the top and then we're taking the top ten and so if we're going to run this example on this adorable golden retriever we can see that it is 92 percent confident that this is a golden retriever be sure to head over to our github our docs and our templates in order to get that source code and get started using c sharp with onyx runtime
Info
Channel: ONNX Runtime
Views: 4,528
Rating: undefined out of 5
Keywords:
Id: Z8SX5oXF7dM
Channel Id: undefined
Length: 3min 31sec (211 seconds)
Published: Fri Dec 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.