Git Product home page Git Product logo

energy164 / bitmaponnxprediction Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 0.0 7 KB

An ML.NET-based C# application demonstrating offline bitmap image classification using a Custom Vision ONNX model from Azure

Home Page: https://blog.hompus.nl/2020/06/19/classify-a-bitmap-with-your-downloaded-custom-vision-onnx-model/

License: MIT License

C# 100.00%
azure azure-cognitive-services azure-custom-vision bitmap csharp image-classification machine-learning mlnet offline-models onnx

bitmaponnxprediction's Introduction

BitmapOnnxPrediction

BitmapOnnxPrediction is a C# application that demonstrates how to classify bitmap images using a pre-trained ONNX model from Azure's Custom Vision service with the help of ML.NET.

The Custom Vision service is one of the Azure Cognitive Services provided by Microsoft. With Custom Vision, you can train a model with your own image data. While the portal provides a Prediction API to classify images, there might be scenarios where an offline model is preferred for reasons such as performance, connectivity, security, and costs.

Features

  • Load and preprocess images suitable for ONNX model prediction.
  • Classify bitmap images using a pre-trained ONNX model.
  • Display the classification label in the console.

Getting Started

Prerequisites

  • .NET SDK
  • Microsoft.ML NuGet package
  • An ONNX model from the Azure Custom Vision portal. If you don't have a model yet, consider following the quickstart on "How to build a classifier with Custom Vision".

Setup

  1. Clone the repository:

    git clone https://github.com/eNeRGy164/BitmapOnnxPrediction.git
  2. Navigate to the project directory and build the solution:

    cd BitmapOnnxPrediction/src
    dotnet build
  3. Run the application:

    dotnet run

Note: Ensure you have the "model.onnx" file in the appropriate directory as indicated in the code.

Steps Covered in the Blog Post

  1. Exporting the trained model: Learn how to obtain the model from the custom vision portal.
  2. Setting up the application: Get insights about setting up the application.
  3. Adding support classes: Understand the necessary support classes for the application.
  4. Building the prediction engine: Dive deep into how the prediction engine is constructed.
  5. Classifying a bitmap: Follow the final steps to classify a bitmap.

For a detailed walkthrough, refer to the blog post.

License

This project is licensed under the MIT License. See the LICENSE file for details.

bitmaponnxprediction's People

Contributors

energy164 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bitmaponnxprediction's Issues

Worked great until upgrade

Hi, I used this example to load in a pretrained multi class classifier in ONNX.

It was working fine for a while but today I upgraded the ONNX to 2.0.1 from 1.7.1 and now I receive an exception on this line:
var data = mlContext.Data.LoadFromEnumerable(new List());

Exception:
data.loadfromenumerable could not determine an idataview type

Because the imageInputData list is null I guess. I'm not too sure about it. What else can I make it?

Any advice would be appreciated. Thank you.

Validation samples

Found this example and tried a model exported from teachablemachine to SavedModel and then tf2onnx.
With 10 images of two class each (left hand 10 pics, right hand 10 pics) I get 100% hitrate on website prior to export
using the training sample as prediction input.
Using tf2onnx 1.9.3 when converting to onnx I get a warning (Runtime warning) but it looks good else. (Tried 1.10 latest also)
Using the slight modified source code I do not get 100% hitrate with same input for prediction, about 50/60 % and unreliable.

No clue on how to validate onnx model.

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.