Saturday, November 25, 2023
HomeiOS Developmentmaui - Onnxruntime doesn't work on actual IOS system

maui – Onnxruntime doesn’t work on actual IOS system


I’ve aplication in .web Maui the place im making an attempt to make use of onnx mannequin.

All is okay on android actual system and iOS simulator (made on macos with intel procesor) however when I attempt to begin InferenceSession app is beeing termined.

thats code Im utilizing

utilizing Microsoft.ML.OnnxRuntime;

namespace Check
{

public partial class MainPage : ContentPage
{
    int rely = 0;


    Listing<string> classNames;
    InferenceSession session;
    Job initTask;
    byte[] mannequin;



    public MainPage()
    {
        InitializeComponent();
    }

    personal void OnCounterClicked(object sender, EventArgs e)
    {
        InitTask();
        classNames = LoadLabels();
    }


    public void InitTask()
    {
        var meeting = GetType().Meeting;
        var resourceNames = meeting.GetManifestResourceNames();
        foreach (var resourceName in resourceNames)
        {
            Console.WriteLine(resourceName);
        }

        var modelStream = meeting.GetManifestResourceStream("Check.model2.onnx");
        var modelMemoryStream = new MemoryStream();

        modelStream.CopyTo(modelMemoryStream);
        mannequin = modelMemoryStream.ToArray();

        attempt
        {
            session = new InferenceSession(mannequin: mannequin);
            var kk = 6;
            var oo = 4;
            var pp = kk - oo;
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error creating InferenceSession: " + ex.Message);
            Console.WriteLine("Stack Hint: " + ex.StackTrace);
            if (ex.InnerException != null)
            {
                Console.WriteLine("Interior Exception: " + ex.InnerException.Message);
                Console.WriteLine("Interior Stack Hint: " + ex.InnerException.StackTrace);
            }
        }
    }
    personal Listing<string> LoadLabels()
    {
        utilizing var stream = FileSystem.OpenAppPackageFileAsync("cclabel.txt").Consequence;
        utilizing var reader = new StreamReader(stream);

        Listing<string> labels = new Listing<string>();
        string line;
        whereas ((line = reader.ReadLine()) != null)
        {
            labels.Add(line);
        }
        return labels;
    }
}

}

and right here ale logs

2023-11-24 12:43:50.712 Xamarin.PreBuilt.iOS[4423:2205361] Error creating InferenceSession: The sort initializer for ‘Microsoft.ML.OnnxRuntime.NativeMethods’ threw an exception.

2023-11-24 12:43:50.716 Xamarin.PreBuilt.iOS[4423:2205361] Interior Stack Hint: at Microsoft.ML.OnnxRuntime.NativeMethods..cctor()

2023-11-24 12:43:50.716 Xamarin.PreBuilt.iOS[4423:2205361] Interior Exception: __Internal

2023-11-24 12:43:50.715 Xamarin.PreBuilt.iOS[4423:2205361] Stack Hint: at Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
at Microsoft.ML.OnnxRuntime.InferenceSession..ctor(Byte[] mannequin)
at Check.MainPage.InitTask() in D:GitTestMainPage.xaml.cs:line 56

The app has been terminated.

I attempted few fashions with completely different dimension and sort. Tried to load mannequin on few manner additionally.
Tried few vesions of onnxruntime.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments