[js/rn] Support load external data (#20090)

Support load external data by passing local model path
This commit is contained in:
Hans 2024-04-05 20:55:03 +08:00 committed by GitHub
parent f61cca1b8f
commit 6abfb6b928
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -199,6 +199,12 @@ public class OnnxruntimeModule extends ReactContextBaseJavaModule implements Lif
if (modelData != null && modelData.length > 0) {
// load model via model data array
ortSession = ortEnvironment.createSession(modelData, sessionOptions);
} else if (uri.startsWith("file://") || uri.startsWith("/")) {
// load model from local
if (uri.startsWith("file://")) {
uri = uri.substring(7);
}
ortSession = ortEnvironment.createSession(uri, sessionOptions);
} else {
// load model via model path string uri
InputStream modelStream =