You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ML-For-Beginners/4-Classification/4-Applied/solution/index.html

37 lines
1.4 KiB

<!DOCTYPE html>
<html>
<header>
<title>ONNX Runtime JavaScript examples: Quick Start - Web (using script tag)</title>
</header>
<body>
<!-- import ONNXRuntime Web from CDN -->
<!--script src="./dist/ort.min.js"></script-->
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.8.0-dev.20210608.0/dist/ort.min.js"></script>
<script>
// use an async context to call onnxruntime functions.
async function main() {
try {
// create a new session and load the specific model.
//
const session = await ort.InferenceSession.create('./model.onnx');
const input = new ort.Tensor(new Float32Array([5, 10, 15, 20, 25, 30, 23, 35, 50, 200]), [1, 10]);
const feeds = { float_input: input };
// feed inputs and run
const results = await session.run(feeds);
// read from results
const output = JSON.stringify(results);
document.write(`data of result tensor 'c': ${output}`);
} catch (e) {
document.write(`failed to inference ONNX model: ${e}.`);
}
}
main();
</script>
</body>
</html>