onnx-web-upscale / README.md
notaneimu's picture
Remove HF static build step
293a8ad
|
Raw History Blame Contribute Delete
2.92 kB
metadata
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:

bun install

Start the local Vite dev server:

bun run dev

Then open the local URL printed by Vite.

To verify the production bundle locally:

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:

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:

uv sync

Then run the converter from the local uv environment:

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.