Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] How should I get wasm file? #19829

Open
Iven10252158 opened this issue Mar 8, 2024 · 3 comments
Open

[Web] How should I get wasm file? #19829

Iven10252158 opened this issue Mar 8, 2024 · 3 comments
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template stale issues that have not been addressed in a while; categorized by a bot

Comments

@Iven10252158
Copy link

Iven10252158 commented Mar 8, 2024

Describe the issue

I use vue3+vite and load onnxruntime-web plugin. I meet some error. I get wasm file failed.

I wondering to know how should i get wasm file?
@fs-eire
截圖 2024-03-08 下午4 03 29

My Vue3+Vite Version:
vue:"^3.4.15",
vite: "~3.0.4",
onnxruntime-web: "^1.17.1",
vite-plugin-static-copy: "^1.0.1",

In my vite.config.ts
import { viteStaticCopy } from 'vite-plugin-static-copy'

export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
return defineConfig({
base: process.env.VITE_APP_BASE_URL,
plugins: [
vue(),
viteStaticCopy({
targets: [
{
src: "./node_modules/onnxruntime-web/dist/*.wasm",
dest: "./",
},
],
}),
removeConsole(),
}),
],
css: {postcss},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},
}

To reproduce

In My Vue app
import * as ort from 'onnxruntime-web';
const modelDir = 'https://mode-marie-ai-2023.s3.ap-northeast-1.amazonaws.com/inspiration_generator/onnx/sam_onnx_quantized_vit_h.onnx'
onMounted(async () => {
console.log('onMounted')
try {
if (modelDir === undefined) return
const modelUrl:string = modelDir
const aaa = await ort.InferenceSession.create(modelUrl)
console.log('completed')
} catch (error) {
console.log(error)
}
})

Urgency

urgent!

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.17.1

Execution Provider

Other / Unknown

@Iven10252158 Iven10252158 added the platform:web issues related to ONNX Runtime web; typically submitted using template label Mar 8, 2024
@fs-eire
Copy link
Contributor

fs-eire commented Mar 8, 2024

you may need to figure out what is the actual path of .wasm files are served.

If the browser log, it tries to get the files at https://localhost:5173/admin/ort-wasm-simd.wasm, and this URL is not valid.

In your config, I see you copy the files to "./". Not sure how this will map to the actual deploy path. You need to figure out this.

Since your script tries to get the .wasm files from path "https://localhost:5173/admin/", I assume your bundle.js is in the same path. You may either figure out how to deploy the .wasm files to the same path, or use ort.env.wasm.wasmPaths to override the wasm paths if you know where it is.

Copy link
Contributor

github-actions bot commented Apr 8, 2024

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Apr 8, 2024
@Mirror-Yu
Copy link

I also encountered this problem, using the onnx model, but reporting an error that wasm could not find,Have you solved it yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

3 participants