machinelearning icon indicating copy to clipboard operation
machinelearning copied to clipboard

UWP Application

Open Jahanaray opened this issue 8 years ago • 10 comments

Why Can't I use ML.NET in UWP apps?

Jahanaray avatar Oct 19 '18 16:10 Jahanaray

@GalOshri would probably be able to answer this question.

artidoro avatar Oct 26 '18 21:10 artidoro

Hi @Jahanaray, is there a specific error you are encountering?

I just tried creating a UWP app targeting the "Windows 10 Fall Creators Update" as the min version (based on this and using x64. I was able to train an ML.NET model and use it for predictions. x86 support for ML.NET is in progress.

/cc @eerhardt in case there is a known issue

GalOshri avatar Oct 26 '18 22:10 GalOshri

ML.NET is a netstandard2.0 library. So you need to use a UWP version that supports .NET Standard 2.0. See https://blogs.msdn.microsoft.com/dotnet/2017/10/10/announcing-uwp-support-for-net-standard-2-0/ for more details.

eerhardt avatar Oct 29 '18 14:10 eerhardt

@GalOshri @eerhardt Thanks for your kind response and sorry for late reply. I am using last version of UWP sdk which is 17134 (x64). I know it's weird but it seems the problem is in copying the trained library (model.zip) into debug folder, I have done this manually (copying the library into debug folder!) and it worked. Maybe I should mention that it doesn't work normally, until I put my code into a try_catch. I guess (it's only my guess) it has something with my windows and sdk update because when I had the last version once I tested ML.NET on UWP app and it worked.

Jahanaray avatar Nov 01 '18 14:11 Jahanaray

I know it's weird but it seems the problem is in copying the trained library (model.zip) into debug folder, I have done this manually (copying the library into debug folder!) and it worked.

@Jahanaray - do other files get copied to the debug folder correctly? Like if you add a .txt file to your project, set its properties to be Copy to Output Directory = Copy Always? Does the .txt file get copied correctly?

eerhardt avatar Nov 01 '18 14:11 eerhardt

@eerhardt - Good point and funny mistake for me! I didn't consider this possibility, since I have test this out before. After checking out again, it turned out that problem is not from ML.NET and is global, I can't read even a text file! So do you have any suggestion in that case?

Jahanaray avatar Nov 01 '18 16:11 Jahanaray

Unfortunately, no, I don't have very good suggestions for it. Maybe try asking your question on stackoverflow, or through the "Send Feedback" option in Visual Studio.

Does the problem reproduce in even a Console Application? If so, then I would say your Visual Studio installation may have a problem. If it is only UWP projects, then it may be specific to the UWP sdk you installed.

Closing as this doesn't appear to be an issue with ML.NET.

eerhardt avatar Nov 01 '18 16:11 eerhardt

Thanks, it is just with UWP app, I may have to reinstall my sdk or VS.

Jahanaray avatar Nov 01 '18 16:11 Jahanaray

@eerhardt @GalOshri - (maybe helpful for others) I checked the problem again after solving the problem in copying library (model.zip), it seems the main problem was causing by updating to the new version of ML.NET. I make my model library using console app with previous version of ML.NET and was trying to read it using new version of ML.NET. It turns out it's not possible and you should train it again using new version of ML.NET.

Jahanaray avatar Nov 01 '18 20:11 Jahanaray

Adding a related sample app which mentions related issues: https://xamlbrewer.wordpress.com/2019/01/25/machine-learning-with-ml-net-in-uwp-clustering/

CESARDELATORRE avatar Jan 25 '19 20:01 CESARDELATORRE