https://github.com/danielfrg/astro-react-onnx-template
Template for an Astro website that loads an ONNX model, all in client side
https://github.com/danielfrg/astro-react-onnx-template
Last synced: about 1 year ago
JSON representation
Template for an Astro website that loads an ONNX model, all in client side
- Host: GitHub
- URL: https://github.com/danielfrg/astro-react-onnx-template
- Owner: danielfrg
- License: apache-2.0
- Created: 2025-02-22T17:58:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-23T17:59:02.000Z (over 1 year ago)
- Last Synced: 2025-04-12T05:58:07.069Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://danielfrg.github.io/astro-react-onnx-template/
- Size: 318 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Astro React ONNX runtime template
Template for an Astro website that loads an ONNX model and uses ONNX runtime
to run it, all in client side.
- Creates a test model is that doubles a vector
- Web Worker that loads the models and communicates with a React Component
Demo: [danielfrg.github.io/astro-react-onnx-template](https://danielfrg.github.io/astro-react-onnx-template/)

## Create the test model
This is done using Python, since most models are done in Python.
```
cd python
uv sync
uv run python gen_double_model.py
```
Optimization: For most models you want to pass the models through a simplifier
like [`onnxsim`](https://github.com/daquexian/onnx-simplifier/)
and possible also convert them to ORT:
```
onnxsim model model.sim.onnx
uv run python -m onnxruntime.tools.convert_onnx_models_to_ort model.onnx
```
## Web setup
Regular astro website:
```
npm install
```
Copy the WASM ONNX Runtime from `node_modules` to the to the `/public` dir so
they can be loaded.
```
just copy-onnx-wasm
```
```
npm run dev
```