Aspnetcore: Please add Blazor sample with ML.NET

Created on 14 Sep 2018  路  13Comments  路  Source: dotnet/aspnetcore

Blazor allows us to use .NET Core features. Now that the .NET Core supports machine learning, it would be very helpful to learn how we can use ML.NET features with Blazor on the client side.

If this works, we could perform machine learning on the client side or server side using our web apps.

area-blazor

Most helpful comment

Confirmed ML.NET on Wasm fails.

You can't load at traied model, it throws exceptions.

All 13 comments

ML.NET has only 64 bit version (read here https://github.com/dotnet/machinelearning) and I think that Wasm is currently only 32 bit. From here (https://webassembly.org/docs/future-features/)
To support larger sizes, the wasm64 mode of WebAssembly will be added in the future, supporting much greater linear memory sizes using 64-bit linear memory indices. wasm32 and wasm64 are both just modes of WebAssembly, to be selected by a flag in a module header, and don鈥檛 imply any semantics differences outside of how linear memory is handled. Platforms will also have APIs for querying which of wasm32 and wasm64 are supported.

It will not work.

I know nothing about ML.NET, but you probably need a fast processor with a few cores to learn efficiently. Currently Blazor on the client is interpreted, not compiled (so it is slow) and as far as I know there is no support for multithreading in WebAssembly yet.

Blazor doesn't support .net core targeting assemblies, only .netstandard2

Thanks for your responses everyone, hopefully in the future as both technologies mature we will be use them together on the client side. In the meantime I'm sure we will be able to make it work on the server side where these limitations don't exist.

Perhaps the community can release an example which uses Blazor for simplifying data input for training data supplied on a grid etc and then processing the data on the server side to get the best of both worlds?

ML.NET has been updated and now supports x86 from version 0.7, perhaps this opens up an opportunity to use it together with Blazor?

In either case (if not possible) it would be useful if there was a sample shown which shows ML.NET running on the server side but Blazor triggering functions from the client side.

E.g. a .net standard project that executes a procedure in a .net core project (referenced library)

@tauheedul
Here's an example using Razor Components (or Blazor Server Side)

https://github.com/EdCharbeneau/BlazorShcMLDotnet/

Hi @EdCharbeneau thank you, I will give this a try :)

Confirmed ML.NET on Wasm fails.

You can't load at traied model, it throws exceptions.

It's probably because ML.NET doesn't support x32 yet if I remember correctly. Though I do recall it's on their milestone in the coming releases so might be interesting to try again after that.

Thank you for your example @EdCharbeneau! I forked the repo and am experimenting with it for learning both frameworks better

Hi @RyoukoKonpaku ML.NET 0.7 supports x86 applications, the issue is ML.NET targets .NET Core and Blazor is .NET Standard so it will throw an exception of some kind on the client side. Eds pattern for usage with ML.NET seems like the best approach using it on the server side at the moment

@tauheedul Ah thanks for the clarification.

If you would like to see the errors (console reports about 57 of them) you can see the branch. https://github.com/EdCharbeneau/BlazorShcMLDotnet/tree/client-wa

Beware there's an unfinished provider/loader concept in there. I gave up on it when the errors started pouring from the console.

It's also worth pointing out that if you absolutely must use Blazor client side (wasm), then you could run ML.NET inside of a Web API and call it via Http. I know it's not ideal, but at least it's not a sea of exceptions ;)

Hi @EdCharbeneau I read the first part of your comment and was thinking Web API and then I read the last line and you suggested what I was thinking haha. Great minds!

Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.

Was this page helpful?
0 / 5 - 0 ratings