_loadModel(modelPath) {
var _this = this;
if (!modelPath) {
console.error('model path is null!');
return Promise.reject(new Error('model path is null!'));
}
let modelFile = modelPath;
console.log('...wxwxwx...modelFile', modelFile);
return new Promise((resolve, reject) => {
this.wxInferenceSession = wx.createInferenceSession({
model: modelFile,
precisionLevel: 4,
allowNPU: false,
allowQuantize: false
});
// 监听 error 事件
this.wxInferenceSession.onError((error) => {
console.error('Model loading error:', error);
});
this.wxInferenceSession.onLoad(() => {
this.ready = true;
resolve();
});
});
},
模型路径是否正确,是否成功保存到本机? errMsg: "createInferenceSession:fail model path invalid : failed to find model on path xxx
使用的模型
https://github.com/onnx/models
/blob/main/Generative_AI/gptneox_Opset16_transformers/gptneox_Opset16.onnx