Loading...
Loading...
Implements high-performance local machine learning inference in the browser using ONNX Runtime Web. Use this skill when the user needs privacy-first, low-latency, or offline AI capabilities (e.g., image classification, object detection, or NLP) without server-side processing.
npx skill4agent add thongnt0208/browser-onnx-skills browser-onnxnpm install onnxruntime-webonnxruntime-web@devort.envort.env.wasm.numThreadsort.env.wasm.proxy = trueort.env.wasm.wasmPathsort.env.webgpu.profiling = { mode: 'default' }import * as ort from 'onnxruntime-web';
const session = await ort.InferenceSession.create('./model.onnx', {
executionProviders: ['webgpu', 'wasm'], // Prioritize GPU, fallback to CPU
graphOptimizationLevel: 'all' // Enable all graph-level optimizations
});new ort.Tensor('float32', float32Data,)enableGraphCapture: trueort.Tensor.fromGpuBuffer()preferredOutputLocation: 'gpu-buffer'ArrayBufferconst session = await ort.InferenceSession.create(modelUrl, {
externalData: [{ path: './model.data', data: dataUrl }]
});tensor.dispose()