Microsoft.ML.OnnxRuntime.OnnxRuntimeException on OCR any image

Hello. We are evaluating your product to integrate in our application, but I’m getting the same exception does not matter what I do in RecognizeImage call.

We installed aspose.ocr in Visual Studio 2022 via NuGet in our .NET Framework 4.7.2 project, x86 build. Then issued this code:

        foreach (var bitmap in bitmaps)
        {
            using (var ms = new MemoryStream())
            {
                bitmap.Save(ms, ImageFormat.Tiff);
                bitmap.Save("C:\\maschine\\ocr.tiff", ImageFormat.Tiff);
                var result = engine.RecognizeImage("C:\\maschine\\ocr.tiff", new RecognitionSettings(Language.Deu));
                var text = result.GetSpellCheckCorrectedText(SpellCheckLanguage.Deu);
                Console.WriteLine(text);
            }

        }

Basically we have an array of Bitmap and want OCR them. Our first try was to OCR from the MemoryStream, and then we tried saving into file, and with different images (they are invoices). RecognizeInvoice fails as well.

The exception is:

Microsoft.ML.OnnxRuntime.OnnxRuntimeException: ‘[ErrorCode:RuntimeException] Non-zero status code returned while running ConvInteger node. Name:‘Conv_656_quant’ Status Message: bad allocation’

And relevant call stack:

This exception was originally thrown at this call stack:
    Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(System.IntPtr) in NativeApiStatus.shared.cs
    Microsoft.ML.OnnxRuntime.InferenceSession.RunImpl(Microsoft.ML.OnnxRuntime.RunOptions, System.IntPtr[], System.IntPtr[], System.IntPtr[], Microsoft.ML.OnnxRuntime.DisposableList<System.IDisposable>) in InferenceSession.shared.cs
    Microsoft.ML.OnnxRuntime.InferenceSession.Run(System.Collections.Generic.IReadOnlyCollection<Microsoft.ML.OnnxRuntime.NamedOnnxValue>, System.Collections.Generic.IReadOnlyCollection<string>, Microsoft.ML.OnnxRuntime.RunOptions) in InferenceSession.shared.cs
    Microsoft.ML.OnnxRuntime.InferenceSession.Run(System.Collections.Generic.IReadOnlyCollection<Microsoft.ML.OnnxRuntime.NamedOnnxValue>, System.Collections.Generic.IReadOnlyCollection<string>) in InferenceSession.shared.cs
    Microsoft.ML.OnnxRuntime.InferenceSession.Run(System.Collections.Generic.IReadOnlyCollection<Microsoft.ML.OnnxRuntime.NamedOnnxValue>) in InferenceSession.shared.cs
    [External Code]

Installed version is 23.1.0.0. App memory usage goes from about 80 MB to near 1 GB while running the RecognizeImage method. Any help is welcome.

@rfog

The exception can be caused due to incorrect version of OnnxRuntime. Please create a new console application targeting x64 mode of debugging and install Aspose.OCR using NuGet Package manager. In case issue still persists, please share same application with us so that we can also try to reproduce the issue in our environment and address it accordingly.