Skip to content

Instantly share code, notes, and snippets.

@abgoswam
Created January 31, 2023 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abgoswam/9f62d9e727353a6eaa3d4cea53d09a55 to your computer and use it in GitHub Desktop.
Save abgoswam/9f62d9e727353a6eaa3d4cea53d09a55 to your computer and use it in GitHub Desktop.
import * as ort from 'onnxruntime-web';
// use an async context to call onnxruntime functions.
async function main() {
ort.InferenceSession
const session = await ort.InferenceSession.create('./model4.onnx', {
executionProviders: ["wasm"],
});
// prepare feeds. use model input names as keys.
const feeds = {
float32_input: new ort.Tensor('float32', new Array<number>(221).fill(1), [1, 221]),
};
const model_outputs = await session.run(feeds);
let probabilityAccept = Number(model_outputs['probabilities']['data'][1]);
console.log(probabilityAccept);
}
main();
@abgoswam
Copy link
Author

running the above snip is successful:

npx ts-node trial_onnxruntime_web_1.ts 
0.27018171548843384

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment