--- title: ONNX Runtime Web Image Upscale in Browser emoji: 🔍 colorFrom: blue colorTo: indigo sdk: static app_file: dist/index.html pinned: false --- # ONNX Runtime Web Inspector Static browser app for loading a local `.onnx` model and image, running inference with `onnxruntime-web`, and comparing the latest output to the previous run. ## Files - `index.html` — Vite entry HTML used for local dev and production builds. - `src/` — Vue 3 app source (`script setup` components, composables, and shared helpers). - `dist/` — production build output generated by Vite. Hugging Face Static Spaces should serve `dist/index.html`. - `package.json` — Bun scripts and frontend dependencies. - `vite.config.ts` — Vite config with Vue and Tailwind 4. - `tsconfig.json` — TypeScript config for the Vue app. - `convert_openmodeldb_to_onnx.py` — Python script for exporting OpenModelDB-compatible `.pth` / `.safetensors` image models to ONNX. - `pyproject.toml` — local `uv` project metadata and pinned Python compatibility. - `uv.lock` — locked dependency resolution for reproducible `uv sync`. - `requirements.txt` — exact local dependency snapshot for `uv pip install -r`. ## Run the web app Install frontend dependencies once: ```bash bun install ``` Start the local Vite dev server: ```bash bun run dev ``` Then open the local URL printed by Vite. To verify the production bundle locally: ```bash bun run build bun run preview ``` ## Hugging Face Static Space This repository is configured as a `static` Space and must serve the built Vite output, not the source `index.html`. The YAML front matter at the top of this `README.md` includes: - `app_build_command: bun install && bun run build` - `app_file: dist/index.html` That makes Hugging Face: 1. Install the Bun dependencies. 2. Build the app into `dist/`. 3. Serve `dist/index.html`, which correctly references the hashed files in `dist/assets/`. If you change the frontend build output location, update `app_file` to match. ## Convert a checkpoint to ONNX Set up a local `uv` environment first: ```bash uv python install 3.11.11 uv venv --python 3.11.11 --seed source .venv/bin/activate uv pip install -r requirements.txt ``` Or, if you prefer the locked project metadata route: ```bash uv sync ``` Then run the converter from the local `uv` environment: ```bash uv run python ./convert_openmodeldb_to_onnx.py /path/to/model.safetensors --output /path/to/model.onnx --seed 42 ``` Useful flags: - `--width` / `--height` control the dummy trace size. - `--device cuda` exports on GPU when needed. - `--static-shape` disables dynamic height/width axes. - `--no-check` skips `onnx.checker`. ## Notes - The web app currently binds only the first model input and expects it to be a `float32` image tensor. - The Python converter targets OpenModelDB-style image models supported by `spandrel` / `spandrel-extra-arches`.