我正在尝试将 .onnx 文件加载到 javascript 会话中。我收到的错误是 TypeError: unrecognized operator 'ReduceL2',但这个链接https://github.com/onnx/onnx/blob/master/docs/Operators.md说 onnx 支持 'ReduceL2'。我猜这可能与 webGL 不支持它有关。是否有任何解决方法或更好的方法可以在浏览器中运行模型?对 javascript 来说非常新。
Javascript代码:
async function runExample() {
// Create an ONNX inference session with WebGL backend.
const session = new onnx.InferenceSession({ backendHint: 'webgl' });
// Load an ONNX model. This model is Resnet50 that takes a 1*3*224*224 image and classifies it.
await session.loadModel("./pathtomodel");
抛出的错误:
Uncaught (in promise) TypeError: unrecognized operator 'ReduceL2'
at t.createOperator (session-handler.ts:222)
at t.resolve (session-handler.ts:86)
at e.initializeOps (session.ts:252)
at session.ts:92
at t.event (instrument.ts:294)
at e.initialize (session.ts:81)
at e.<anonymous> (session.ts:63)
at inference-session-impl.ts:16
at Object.next (inference-session-impl.ts:16)
at a (inference-session-impl.ts:16)