| set -eu | |
| root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) | |
| repo_root=$(CDPATH= cd -- "$root/../.." && pwd) | |
| local_ort_dist="$root/node_modules/onnxruntime-web/dist" | |
| repo_ort_dist="$repo_root/node_modules/.bun/onnxruntime-web@1.27.0/node_modules/onnxruntime-web/dist" | |
| if [ -d "$local_ort_dist" ]; then | |
| ort_dist="$local_ort_dist" | |
| else | |
| ort_dist="$repo_ort_dist" | |
| fi | |
| if [ ! -d "$ort_dist" ]; then | |
| printf '%s\n' "Missing ONNX Runtime Web. Run npm install in $root." >&2 | |
| exit 1 | |
| fi | |
| mkdir -p "$root/.cache" | |
| ln -sfn "$ort_dist" "$root/.cache/ort" | |
| cd "$root" | |
| if [ -x .venv/bin/python ]; then | |
| python=.venv/bin/python | |
| else | |
| python=python3 | |
| fi | |
| exec "$python" serve_browser.py | |