javascript - onnxruntime-web fails to find ort-wasm-simd.wasm, doesn't use my static folder in SvelteKit - Stack Overflo

Uncaught (in promise) Error: no available backend found. ERR: at t.resolveBackend (backend-impl.js:91:1

Uncaught (in promise) Error: no available backend found. ERR: 
    at t.resolveBackend (backend-impl.js:91:11)
    at async i.create (inference-session-impl.js:175:15)
    at async createSAM (SAM.ts:59:19)
    at async init (http://localhost:5001/src/routes/(app)/app/project/[projectId]/auto-detect/+page.svelte?t=1695723086870:936:9)

In the console I see this:

Error: Not found: /app/project/MpUQMHCfHANBXyvH/ort-wasm-simd.wasm

This is the only place where I'm specifying a path:

const session = await InferenceSession.create('/sam_onnx_quantized.onnx')

Changing it to an absolute path with http://localhost:5001/sam_... didn't make a difference.

I have this file both in my /static folder, and in node_modules/onnx-runtime-web/dist. It should not be looking for the file in the current page's path.

I don't know what happened, this used to work. I had to delete node_modules and package-lock and do npm install for a different issue, maybe it broke after that.

Uncaught (in promise) Error: no available backend found. ERR: 
    at t.resolveBackend (backend-impl.js:91:11)
    at async i.create (inference-session-impl.js:175:15)
    at async createSAM (SAM.ts:59:19)
    at async init (http://localhost:5001/src/routes/(app)/app/project/[projectId]/auto-detect/+page.svelte?t=1695723086870:936:9)

In the console I see this:

Error: Not found: /app/project/MpUQMHCfHANBXyvH/ort-wasm-simd.wasm

This is the only place where I'm specifying a path:

const session = await InferenceSession.create('/sam_onnx_quantized.onnx')

Changing it to an absolute path with http://localhost:5001/sam_... didn't make a difference.

I have this file both in my /static folder, and in node_modules/onnx-runtime-web/dist. It should not be looking for the file in the current page's path.

I don't know what happened, this used to work. I had to delete node_modules and package-lock and do npm install for a different issue, maybe it broke after that.

Share Improve this question asked Sep 26, 2023 at 10:28 Nikolay DyankovNikolay Dyankov 7,26811 gold badges65 silver badges89 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Here's a specific example that worked for me based on André's post:

import { env } from 'onnxruntime-web';
env.wasm.wasmPaths = {
  'ort-wasm.wasm': '/public/ort-wasm.wasm',
  'ort-wasm-simd.wasm': '/public/ort-wasm-simd.wasm',
  'ort-wasm-threaded.wasm': '/public/ort-wasm-threaded.wasm',
  // Add other WASM files as needed
};

You can set the basepath for onnx-web wasm files using the wasmPath property on the ONNX env object like this:

env.wasm.wasmPaths = path/to/wasm/files

This feature is documented in the API Docs

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744255261a4565366.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信