Closed alawasoft closed 3 months ago
Please try without CharPointer
Thank you for your response.
The Session class implementation in the javacpp onnxruntime bindings indeed requires a Pointer for the model path. Here is the relevant portion of the Session class:
package org.bytedeco.onnxruntime;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class)
public class Session extends SessionImpl {
static { Loader.load(); }
public Session(Pointer p) { super(p); }
public Session(@Const @ByRef Env env, @Cast("const ORTCHAR_T*") Pointer model_path, @Const @ByRef SessionOptions options) {
super((Pointer)null);
allocate(env, model_path, options);
}
private native void allocate(@Const @ByRef Env env, @Cast("const ORTCHAR_T*") Pointer model_path, @Const @ByRef SessionOptions options);
}
As you can see, the constructor for Session expects a Pointer for the model path. Therefore, using CharPointer to convert the string path to a Pointer seems necessary.
Does this sample code work: https://github.com/bytedeco/javacpp-presets/blob/master/onnxruntime/samples/CXXApiSample.java#L41
I've overlooked this example. thank you for pointing out, BytePointer indeed works well ! thank you !
From what I understand about ONNX Runtime's API, yes
I am encountering a Protobuf parsing error when attempting to load an ONNX model using javacpp on Linux. The same model loads successfully on Windows. Despite trying several solutions, the issue persists.
Environment Operating System: Linux (Ubuntu 20.04) Java Version: OpenJDK 17 ONNX Runtime Version: 1.16.3 Local Protobuf Version: 3.21.12 JavaCV Version: 1.5.10
this exact code works in windows-x86-64, but not the linux-amd64 version.
the onnx model file is exactly the same as the one ran on windows.