Microsoft.ML and Xamarin Forms

k 1 Reputation point
2021-09-28T15:18:20.7+00:00

Hello,

I trained a Model with Microsoft ML for Image classification and want to classify images with different categories in my Xamarin Forms Prism App.

With this Method I want to classifiy the selected Image (see picture)135855-methodxama.png

The problem is that I got an error for the path of the MLModel1.zip. (see picture)135958-methodxamaerror.png
135919-methodxamasolutionexplorer.png
How I get solve this problem?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kyle Wang 5,531 Reputation points Microsoft External Staff
    2021-09-29T08:01:48.793+00:00

    Hi jm-5055,

    Welcome to our Microsoft Q&A platform!

    To access the file under Xamarin.Forms project, you need to set the file's Build Action to EmbeddedResource first.
    And use the following code to get the file stream.

    var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;  
    Stream stream = assembly.GetManifestResourceStream("myassembly.test.txt");  
    

    For more info, you can refer to the documentation: File Handling in Xamarin.Forms.

    Regards,
    Kyle


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.